From 3f882dedcbc3ce86743e4b37fd371b61f5a0ec4d Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Tue, 2 Apr 2013 16:59:00 -0400 Subject: [PATCH] Make type declaration and arg list processing of ScanTemplate same as ElementwiseTemplate. --- pyopencl/elementwise.py | 3 ++- pyopencl/scan.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pyopencl/elementwise.py b/pyopencl/elementwise.py index 7b7f5340..694a735c 100644 --- a/pyopencl/elementwise.py +++ b/pyopencl/elementwise.py @@ -326,7 +326,8 @@ class ElementwiseTemplate(KernelTemplateBase): name=renderer(self.name), options=list(options), preamble=( type_decl_preamble - + "\n" + renderer(self.preamble + "\n" + more_preamble)), + + "\n" + + renderer(self.preamble + "\n" + more_preamble)), auto_preamble=False) # }}} diff --git a/pyopencl/scan.py b/pyopencl/scan.py index a56f6a07..9692233d 100644 --- a/pyopencl/scan.py +++ b/pyopencl/scan.py @@ -1543,6 +1543,11 @@ class ScanTemplate(KernelTemplateBase): options=(), devices=None, scan_cls=GenericScanKernel): renderer = self.get_renderer(type_aliases, var_values, context, options) + arg_list = renderer.render_argument_list(self.arguments, more_arguments) + + type_decl_preamble = renderer.get_type_decl_preamble( + context.devices[0], declare_types, arg_list) + return scan_cls(context, renderer.type_aliases["scan_t"], renderer.render_argument_list(self.arguments, more_arguments), renderer(self.input_expr), renderer(self.scan_expr), renderer(self.neutral), @@ -1551,7 +1556,11 @@ class ScanTemplate(KernelTemplateBase): input_fetch_exprs=self.input_fetch_exprs, index_dtype=renderer.type_aliases.get("index_t", np.int32), name_prefix=renderer(self.name_prefix), options=list(options), - preamble=renderer(more_preamble+"\n"+self.preamble), devices=devices) + preamble=( + type_decl_preamble + + "\n" + + renderer(self.preamble + "\n" + more_preamble)), + devices=devices) # }}} -- GitLab