forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL] Fix nextafter with half on host (intel#10558)
Currently the host-side implementation of sycl::nextafter with sycl::half uses the float variant of std::nextafter. However, due to the conversion between half and float, the result may be unexpected. Likewise, KhronosGroup/SYCL-Docs#440 removes the reference to single-precision floating point results. Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
- Loading branch information
1 parent
474461c
commit 1f10f35
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// RUN: %clangxx -fsycl %s -o %t.out | ||
// RUN: %t.out | ||
// | ||
// Checks that sycl::nextafter with sycl::half on host correctly converts based | ||
// on half-precision. | ||
|
||
#include <sycl/sycl.hpp> | ||
|
||
void check(uint16_t x, uint16_t y, uint16_t ref) { | ||
assert(sycl::nextafter(sycl::bit_cast<sycl::half>(x), | ||
sycl::bit_cast<sycl::half>(y)) == | ||
sycl::bit_cast<sycl::half>(ref)); | ||
} | ||
|
||
int main() { | ||
check(0x0, 0x0, 0x0); | ||
check(0x1, 0x1, 0x1); | ||
check(0x8001, 0x8001, 0x8001); | ||
check(0x0, 0x1, 0x1); | ||
check(0x8000, 0x8001, 0x8001); | ||
check(0x0, 0x8001, 0x8001); | ||
check(0x8000, 0x1, 0x1); | ||
check(0x8001, 0x0, 0x0); | ||
check(0x1, 0x8000, 0x8000); | ||
check(0x8001, 0x1, 0x0); | ||
check(0x1, 0x8001, 0x8000); | ||
|
||
std::cout << "Passed!" << std::endl; | ||
return 0; | ||
} |