Skip to content
Snippets Groups Projects
Commit 75f08116 authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Track pyopencl's complex-as-struct change

parent 0627aa0e
No related branches found
No related tags found
No related merge requests found
...@@ -376,14 +376,14 @@ class LoopyCCodeMapper(RecursiveMapper): ...@@ -376,14 +376,14 @@ class LoopyCCodeMapper(RecursiveMapper):
cast_type = "cfloat_t" cast_type = "cfloat_t"
else: else:
if dtype == np.complex128: if dtype == np.complex128:
cast_type = "cdouble_t" cast_type = "cdouble"
elif dtype == np.complex64: elif dtype == np.complex64:
cast_type = "cfloat_t" cast_type = "cfloat"
else: else:
raise RuntimeError("unsupported complex type in expression " raise RuntimeError("unsupported complex type in expression "
"generation: %s" % type(expr)) "generation: %s" % type(expr))
return "(%s) (%s, %s)" % (cast_type, repr(expr.real), repr(expr.imag)) return "%s_new(%s, %s)" % (cast_type, repr(expr.real), repr(expr.imag))
else: else:
if type_context == "f": if type_context == "f":
return repr(float(expr))+"f" return repr(float(expr))+"f"
...@@ -490,11 +490,20 @@ class LoopyCCodeMapper(RecursiveMapper): ...@@ -490,11 +490,20 @@ class LoopyCCodeMapper(RecursiveMapper):
if 'c' == self.infer_type(child).kind] if 'c' == self.infer_type(child).kind]
real_sum = self.join_rec(" + ", reals, PREC_SUM, type_context) real_sum = self.join_rec(" + ", reals, PREC_SUM, type_context)
complex_sum = self.join_rec(
" + ", complexes, PREC_SUM, type_context, tgt_dtype) if len(complexes) == 1:
myprec = PREC_SUM
else:
myprec = PREC_NONE
complex_sum = self.rec(complexes[0], myprec, type_context, tgt_dtype)
for child in complexes[1:]:
complex_sum = "%s_add(%s, %s)" % (
tgt_name, complex_sum,
self.rec(child, PREC_NONE, type_context, tgt_dtype))
if real_sum: if real_sum:
result = "%s_fromreal(%s) + %s" % (tgt_name, real_sum, complex_sum) result = "%s_radd(%s, %s)" % (tgt_name, real_sum, complex_sum)
else: else:
result = complex_sum result = complex_sum
...@@ -545,8 +554,7 @@ class LoopyCCodeMapper(RecursiveMapper): ...@@ -545,8 +554,7 @@ class LoopyCCodeMapper(RecursiveMapper):
self.rec(child, PREC_NONE, type_context, tgt_dtype)) self.rec(child, PREC_NONE, type_context, tgt_dtype))
if real_prd: if real_prd:
# elementwise semantics are correct result = "%s_rmul(%s, %s)" % (tgt_name, real_prd, complex_prd)
result = "%s*%s" % (real_prd, complex_prd)
else: else:
result = complex_prd result = complex_prd
...@@ -591,9 +599,10 @@ class LoopyCCodeMapper(RecursiveMapper): ...@@ -591,9 +599,10 @@ class LoopyCCodeMapper(RecursiveMapper):
if not (n_complex or d_complex): if not (n_complex or d_complex):
return base_impl(expr, enclosing_prec, type_context) return base_impl(expr, enclosing_prec, type_context)
elif n_complex and not d_complex: elif n_complex and not d_complex:
# elementwise semantics are correct return "%s_divider(%s, %s)" % (
return base_impl(expr, enclosing_prec, type_context, self.complex_type_name(tgt_dtype),
num_tgt_dtype=tgt_dtype) self.rec(expr.numerator, PREC_NONE, type_context, tgt_dtype),
self.rec(expr.denominator, PREC_NONE, type_context))
elif not n_complex and d_complex: elif not n_complex and d_complex:
return "%s_rdivide(%s, %s)" % ( return "%s_rdivide(%s, %s)" % (
self.complex_type_name(tgt_dtype), self.complex_type_name(tgt_dtype),
......
...@@ -25,4 +25,4 @@ VERSION = (2014, 1) ...@@ -25,4 +25,4 @@ VERSION = (2014, 1)
VERSION_STATUS = "" VERSION_STATUS = ""
VERSION_TEXT = ".".join(str(x) for x in VERSION) + VERSION_STATUS VERSION_TEXT = ".".join(str(x) for x in VERSION) + VERSION_STATUS
DATA_MODEL_VERSION = "v6" DATA_MODEL_VERSION = "v7"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment