Emit vector constant for vector index#921
Conversation
…a previously vectorized dtype.
9b6a609 to
141d9d7
Compare
loopy/target/opencl.py
Outdated
| # is the number of elements in the vector which is the same as in src. | ||
| # https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_C.html#explicit-casts | ||
| if self.codegen_state.target.is_vector_dtype(actual_type) or \ | ||
| actual_type.dtype.kind == "b": |
There was a problem hiding this comment.
What is this bool handling doing here?
There was a problem hiding this comment.
The type, actual_type is computed using the expression before the vector literal is inserted. I think the better solution would be to update the type inference system to use the vectorized version of the expression instead.
loopy/target/opencl.py
Outdated
| vector_type = self.codegen_state.target.vector_dtype(index_type, | ||
| length) | ||
| conditional_needed_loopy_type = to_loopy_type(vector_type) | ||
| except UnvectorizableError: |
There was a problem hiding this comment.
Why are we suppressing exceptions here in the first place?
There was a problem hiding this comment.
We know that VectorizabilityChecker has succeeded at least once before. However, it is unclear that it will pass for the current expression which may be for a different part of the code. So out of caution, I thought it would be best to rerun the VectorizabilityChecker. If the VectorizabilityChecker succeeds then we need to ensure the proper typing of the vector conditional. If it fails, then the expression is not a vector and so we just handle the case like normal.
Fixes #870.