Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTAD bug in vector length #6402

Open
joeatodd opened this issue Jul 6, 2022 · 2 comments · Fixed by #10014
Open

CTAD bug in vector length #6402

joeatodd opened this issue Jul 6, 2022 · 2 comments · Fixed by #10014
Labels
bug Something isn't working confirmed

Comments

@joeatodd
Copy link
Contributor

joeatodd commented Jul 6, 2022

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.

@joeatodd joeatodd added the bug Something isn't working label Jul 6, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2023

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be automatically closed in 30 days.

@KornevNikita
Copy link
Contributor

Re-opening as the patch was reverted. But #10198 should solve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants