From df7dbba8857048f11f39e42c06e0cf750fcd7be0 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Fri, 30 Mar 2012 18:44:44 -0400 Subject: [PATCH] Find sensible default for whether to allow complex-valued variables. --- loopy/codegen/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/loopy/codegen/__init__.py b/loopy/codegen/__init__.py index 872c0e582..f2c04e2aa 100644 --- a/loopy/codegen/__init__.py +++ b/loopy/codegen/__init__.py @@ -188,7 +188,7 @@ class POD(PODBase): # {{{ main code generation entrypoint def generate_code(kernel, with_annotation=False, - allow_complex=False): + allow_complex=None): from cgen import (FunctionBody, FunctionDeclaration, Value, ArrayOf, Module, Block, Line, Const, LiteralLines, Initializer) @@ -196,6 +196,11 @@ def generate_code(kernel, with_annotation=False, from cgen.opencl import (CLKernel, CLGlobal, CLRequiredWorkGroupSize, CLLocal, CLImage, CLConstant) + allow_complex = False + for var in kernel.args + list(kernel.temporary_variables.itervalues()): + if var.dtype.kind == "c": + allow_complex = True + from loopy.codegen.expression import LoopyCCodeMapper ccm = (LoopyCCodeMapper(kernel, with_annotation=with_annotation, allow_complex=allow_complex) -- GitLab