From a5c5a1a9f9b78806b81e4cc35038a10daf922e98 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 21 Jul 2011 12:03:09 -0500 Subject: [PATCH] Generalize image access to float64. --- loopy/__init__.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/loopy/__init__.py b/loopy/__init__.py index 5dab8596f..2c822705a 100644 --- a/loopy/__init__.py +++ b/loopy/__init__.py @@ -1157,15 +1157,21 @@ class LoopyCCodeMapper(CCodeMapper): arg = self.kernel.arg_dict[expr.aggregate.name] if isinstance(arg, ImageArg): - if arg.dtype != np.float32: - raise NotImplementedError( - "non-float32 images not supported for now") - assert isinstance(expr.index, tuple) - return ("read_imagef(%s, loopy_sampler, (float%d)(%s)).x" + + base_access = ("read_imagef(%s, loopy_sampler, (float%d)(%s))" % (arg.name, arg.dimensions, ", ".join(self.rec(idx, PREC_NONE) for idx in expr.index[::-1]))) + + if arg.dtype == np.float32: + return base_access+".x" + elif arg.dtype == np.float64: + return "as_double(%s.xy)" % base_access + else: + raise NotImplementedError( + "non-floating-point images not supported for now") + else: # ArrayArg index_expr = expr.index -- GitLab