-
Notifications
You must be signed in to change notification settings - Fork 802
Open
Labels
Description
Describe the bug
Swizzled vector types can't be passed directly to length() because detail::is_gengeohalf<T>::value is false for these types.
From this StackOverflow question.
To Reproduce
#define SYCL_SIMPLE_SWIZZLES
#include <CL/sycl.hpp>
using namespace sycl;
int main(){
float3 myVec{1.0, 0.0, 2.0};
auto len = length(myVec.zy());
}The above code fails to compile because it cant deduce typename T of length (should be float2?) If one instead has
auto len = length<float2>(myVec.zy());it works fine.
Additional context
length() is defined in builtins.hpp:
// float length (gengeofloat p)
template <typename T,
typename = detail::enable_if_t<detail::is_gengeofloat<T>::value, T>>
float length(T p) __NOEXC {
return __sycl_std::__invoke_length<float>(p);
}and detail::is_gengeofloat<T> is only true for type_list<float, vec<float, 1>, vec<float, 2>, vec<float, 3>, vec<float, 4>>.
I'm not sure if the solution is to include the SwizzleOp types in geo_float_list or to define a specialization for length etc for SwizzleOp types, but as the StackOverflow OP points out, this somewhat defeats the purpose of swizzle convenience operations.