From a670c4c4bfa9557d2ae059c31aa773cf0f02ec12 Mon Sep 17 00:00:00 2001 From: Cedric Nugteren Date: Sat, 22 Oct 2016 16:14:56 +0200 Subject: All enums in the C API are now prefixed with CLBlast to avoid potential name clashes with other projects --- scripts/generator/generator/cpp.py | 14 ++++++++------ scripts/generator/generator/doc.py | 2 +- scripts/generator/generator/routine.py | 22 ++++++++++++++++++++-- 3 files changed, 29 insertions(+), 9 deletions(-) (limited to 'scripts/generator') diff --git a/scripts/generator/generator/cpp.py b/scripts/generator/generator/cpp.py index a0d43667..9f3089f5 100644 --- a/scripts/generator/generator/cpp.py +++ b/scripts/generator/generator/cpp.py @@ -73,7 +73,7 @@ def clblast_c_h(routine): """The C API header (.h)""" result = NL + "// " + routine.description + ": " + routine.short_names() + NL for flavour in routine.flavours: - result += routine.routine_header_c(flavour, 31, " PUBLIC_API") + ";" + NL + result += routine.routine_header_c(flavour, 38, " PUBLIC_API") + ";" + NL return result @@ -82,13 +82,15 @@ def clblast_c_cc(routine): result = NL + "// " + routine.name.upper() + NL for flavour in routine.flavours: template = "<" + flavour.template + ">" if routine.no_scalars() else "" - indent = " " * (45 + routine.length() + len(template)) - result += routine.routine_header_c(flavour, 20, "") + " {" + NL + indent = " " * (16 + routine.length() + len(template)) + result += routine.routine_header_c(flavour, 27, "") + " {" + NL result += " try {" + NL - result += " return static_cast(clblast::" + routine.name.capitalize() + template + "(" + result += " return static_cast(" + NL + result += " clblast::" + routine.name.capitalize() + template + "(" result += ("," + NL + indent).join([a for a in routine.arguments_cast(flavour, indent)]) - result += "," + NL + indent + "queue, event));" + NL - result += " } catch (...) { return static_cast(clblast::DispatchExceptionForC()); }" + NL + result += "," + NL + indent + "queue, event)" + NL + result += " );" + NL + result += " } catch (...) { return static_cast(clblast::DispatchExceptionForC()); }" + NL result += "}" + NL return result diff --git a/scripts/generator/generator/doc.py b/scripts/generator/generator/doc.py index 8657ed0d..c77ec1a0 100644 --- a/scripts/generator/generator/doc.py +++ b/scripts/generator/generator/doc.py @@ -32,7 +32,7 @@ def generate(routine): result += "C API:" + NL result += "```" + NL for flavour in routine.flavours: - result += routine.routine_header_c(flavour, 20, "") + NL + result += routine.routine_header_c(flavour, 27, "") + NL result += "```" + NL + NL # Routine arguments diff --git a/scripts/generator/generator/routine.py b/scripts/generator/generator/routine.py index a4e682c2..2fa5e9d6 100644 --- a/scripts/generator/generator/routine.py +++ b/scripts/generator/generator/routine.py @@ -349,6 +349,13 @@ class Routine: return [", ".join(definitions)] return [] + def options_def_c(self): + """As above, but now for the C API""" + if self.options: + definitions = ["const CLBlast" + convert.option_to_clblast(o) + " " + o for o in self.options] + return [", ".join(definitions)] + return [] + def options_def_wrapper_clblas(self): """As above, but now using clBLAS data-types""" if self.options: @@ -453,6 +460,17 @@ class Routine: list(chain(*[self.buffer_def(b) for b in self.scalar_buffers_second()])) + list(chain(*[self.scalar_def(s, flavour) for s in self.other_scalars()]))) + def arguments_def_c(self, flavour): + """As above, but for the C API""" + return (self.options_def_c() + self.sizes_def() + + list(chain(*[self.buffer_def(b) for b in self.scalar_buffers_first()])) + + self.scalar_def("alpha", flavour) + + list(chain(*[self.buffer_def(b) for b in self.buffers_first()])) + + self.scalar_def("beta", flavour) + + list(chain(*[self.buffer_def(b) for b in self.buffers_second()])) + + list(chain(*[self.buffer_def(b) for b in self.scalar_buffers_second()])) + + list(chain(*[self.scalar_def(s, flavour) for s in self.other_scalars()]))) + def arguments_def_wrapper_clblas(self, flavour): """As above, but clBLAS wrapper plain data-types""" return (self.options_def_wrapper_clblas() + self.sizes_def() + @@ -523,8 +541,8 @@ class Routine: def routine_header_c(self, flavour, spaces, extra_qualifier): """As above, but now for C""" indent = " " * (spaces + self.length()) - result = "StatusCode" + extra_qualifier + " CLBlast" + flavour.name + self.name + "(" - result += (",\n" + indent).join([a for a in self.arguments_def(flavour)]) + result = "CLBlastStatusCode" + extra_qualifier + " CLBlast" + flavour.name + self.name + "(" + result += (",\n" + indent).join([a for a in self.arguments_def_c(flavour)]) result += ",\n" + indent + "cl_command_queue* queue, cl_event* event)" return result -- cgit v1.2.3