-
Notifications
You must be signed in to change notification settings - Fork 715
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL] Fix float-to-half conversion for minimum subnormal on host (#7401
) Currently when converting a floating point value representing the minimum subnormal value for half to a half on host will result in 0 rather than the expected minimum value. This is due to a faulty check for the minimum supported single-precision exponent when converting. This commit fixes this check. Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
- Loading branch information
1 parent
45d516c
commit 514708b
Showing
2 changed files
with
26 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,25 @@ | ||
// RUN: %clangxx -fsycl %s -o %t.out | ||
// RUN: %t.out | ||
// | ||
// Checks that sycl::half on host can correctly cast its minimum subnormal value | ||
// to and from a floating point value. | ||
|
||
#include <sycl/sycl.hpp> | ||
|
||
int main() { | ||
sycl::half SubnormalMin = | ||
sycl::bit_cast<sycl::half>((uint16_t)0b0000000000000001u); | ||
sycl::half ConvertedSubnormalMin = | ||
static_cast<sycl::half>(static_cast<float>(SubnormalMin)); | ||
|
||
if (SubnormalMin != ConvertedSubnormalMin) { | ||
std::cout << "Failed! (0x" << std::hex | ||
<< sycl::bit_cast<uint16_t>(SubnormalMin) << " != 0x" | ||
<< sycl::bit_cast<uint16_t>(ConvertedSubnormalMin) << ")" | ||
<< std::endl; | ||
return 1; | ||
} | ||
|
||
std::cout << "Passed!" << std::endl; | ||
return 0; | ||
} |