Skip to content

Commit 6947974

Browse files
committed
Use the convert function only if we are converting from a boolean or a previously vectorized dtype.
1 parent ebf07b2 commit 6947974

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

loopy/target/opencl.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,14 +550,15 @@ def wrap_in_typecast(self, actual_type, needed_dtype, s):
550550
return s
551551

552552
registry = self.codegen_state.ast_builder.target.get_dtype_registry()
553-
if self.codegen_state.target.is_vector_dtype(needed_dtype) and \
554-
self.codegen_state.target.is_vector_dtype(actual_type):
553+
if self.codegen_state.target.is_vector_dtype(needed_dtype):
555554
# OpenCL does not let you do explicit vector type casts between vector
556555
# types. Instead you need to call their function which is of the form
557556
# <desttype> convert_<desttype><n>(src) where n
558557
# is the number of elements in the vector which is the same as in src.
559-
cast = var("convert_%s" % registry.dtype_to_ctype(needed_dtype))
560-
return cast(s)
558+
if self.codegen_state.target.is_vector_dtype(actual_type) or \
559+
actual_type.dtype.kind == "b":
560+
cast = var("convert_%s" % registry.dtype_to_ctype(needed_dtype))
561+
return cast(s)
561562

562563
return super().wrap_in_typecast(actual_type, needed_dtype, s)
563564

0 commit comments

Comments
 (0)