Skip to content

Conversation

@alexeyvoronov-intel
Copy link
Contributor

@alexeyvoronov-intel alexeyvoronov-intel commented Jun 13, 2019

[SYCL] A fix for a redefinition in nan builtin helper on MSVC compiler

Before this patch the helper did explicitly map integer types to
suitable floating point type.
aka
template<> struct helper<cl_int> { using type = cl_int;}
But this does not work on Windows compiler x64 because there is
cl_long defined as an alias of long long. And this helper did generate
the redefinition error.

Fixed by change the mapping rules of the helper to mapping by size
comparing of integer and floating point types.
aka

  template<T>
  struct helper<T, enable_if_t<sizeof(T) == sizeof(cl_float), T>>
  { using type = cl_float; }

Signed-off-by: Alexey Voronov alexey.voronov@intel.com

@bader
Copy link
Contributor

bader commented Jun 14, 2019

@alexeyvoronov, could you clarify in the commit message why "Update ..." is required?
Is this just a non-functional refactoring to make code more readable or it fixes some issue?

@alexeyvoronov-intel alexeyvoronov-intel force-pushed the private/avoronov/fix_type_traits branch from df50584 to c413c06 Compare June 14, 2019 16:55
Before this patch the helper did explicitly map integer types to
suitable floating point type.
aka
  template<> struct helper<cl_int> { using type = cl_int;}
But this does not work on Windows compiler x64 because there is
cl_long defined as an alias of long long. And this helper did generate
the redefinition error.

Fixed by change the mapping rules of the helper to mapping by size
comparing of integer and floating point types.
aka
  template<T>
  struct helper<T, enable_if_t<sizeof(T) == sizeof(cl_float), T>>
  { using type = cl_float; }

Signed-off-by: Alexey Voronov <alexey.voronov@intel.com>
@alexeyvoronov-intel alexeyvoronov-intel force-pushed the private/avoronov/fix_type_traits branch from c413c06 to 69fb305 Compare June 14, 2019 17:00
@alexeyvoronov-intel alexeyvoronov-intel changed the title [SYCL] Update nan built-in return type helper. [SYCL] A fix for a redefinition in nan builtin helper on MSVC compiler Jun 14, 2019
@alexeyvoronov-intel
Copy link
Contributor Author

@alexeyvoronov, could you clarify in the commit message why "Update ..." is required?
Is this just a non-functional refactoring to make code more readable or it fixes some issue?

Added the description.

@bader
Copy link
Contributor

bader commented Jun 14, 2019

But this does not work on Windows compiler x64 because there is
cl_long defined as an alias of long long. And this helper did generate
the redefinition error.

This is a bug in cl_long definition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants