Skip to content

sycl::half arithmetic operator promotes results to float  #6028

@TApplencourt

Description

@TApplencourt

Describe the bug

sycl::half arithmetic operator promotes results to float

To Reproduce

$cat test.cpp
#include <type_traits>
#include <sycl/sycl.hpp>
int main() {
   sycl::queue myQueue;
   myQueue.submit([&](sycl::handler& cgh) {
    sycl::device dev = myQueue.get_device();
    if (dev.has(sycl::aspect::fp16)) {
       cgh.single_task([=]{
            static_assert(std::is_same_v<decltype(sycl::half(1)), sycl::half>,"Not a sycl::half");
            static_assert(std::is_same_v<decltype(sycl::half(1) *  sycl::half(1) ), sycl::half>,"Not a sycl::half");
     });
    };
   });
   return 0;
}
$dpcpp test.cpp
test.cpp:11:13: error: static_assert failed due to requirement 'std::is_same_v<float, sycl::detail::half_impl::half>' "Not a sycl::half"
            static_assert(std::is_same_v<decltype(sycl::half(1) *  sycl::half(1) ), sycl::half>,"Not a sycl::half");
            ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Environment (please complete the following information):

  • OS: Linux
  • Target device and vendor: Intel GPU
  • DPC++ version: Intel(R) oneAPI DPC++/C++ Compiler 2022.1.0 (2022.1.0.20220224)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions