|
| 1 | +// RUN: %clangxx -fsycl %s -o %t.out |
| 2 | +// RUN: %GPU_RUN_PLACEHOLDER %t.out |
| 3 | + |
| 4 | +// RUN: %clangxx -fsycl -fno-builtin -fsycl-device-lib-jit-link %s -o %t.out |
| 5 | +// RUN: %GPU_RUN_PLACEHOLDER %t.out |
| 6 | +// |
| 7 | +// UNSUPPORTED: cuda || hip |
| 8 | + |
| 9 | +#include "imf_utils.hpp" |
| 10 | + |
| 11 | +extern "C" { |
| 12 | +_iml_half_internal __imf_double2half(double); |
| 13 | +} |
| 14 | + |
| 15 | +int main() { |
| 16 | + |
| 17 | + sycl::queue device_queue(sycl::default_selector_v); |
| 18 | + std::cout << "Running on " |
| 19 | + << device_queue.get_device().get_info<sycl::info::device::name>() |
| 20 | + << "\n"; |
| 21 | + |
| 22 | + if (!device_queue.get_device().has(sycl::aspect::fp64)) { |
| 23 | + std::cout << "Test skipped on platform without fp64 support." << std::endl; |
| 24 | + return 0; |
| 25 | + } |
| 26 | + |
| 27 | + if (!device_queue.get_device().has(sycl::aspect::fp16)) { |
| 28 | + std::cout << "Test skipped on platform without fp16 support." << std::endl; |
| 29 | + return 0; |
| 30 | + } |
| 31 | + |
| 32 | + { |
| 33 | + std::initializer_list<uint64_t> input_vals = { |
| 34 | + 0, // 0 |
| 35 | + 0x7FF0000000000000, // +infinity |
| 36 | + 0xFFF0000000000000, // -infinity |
| 37 | + 0x4026800000000000, // 11.25 |
| 38 | + 0x409025643C8E4F03, // 1033.3478872524 |
| 39 | + 0x40EFFC0000000000, // 65504 |
| 40 | + 0xC0EFFC0000000000, // -65504 |
| 41 | + 0xC0D38814311F5D54, // -20000.31549820055245 |
| 42 | + 0x409F9B8D12ACEFA7, // 2022.887766554 |
| 43 | + 0x40ee120000000000, // 61584 |
| 44 | + 0xC0EE160000000000, // -61616 |
| 45 | + 0x40FAA93000000000, // 109203 |
| 46 | + 0xC1A7D8B7FF20E365, // -200039423.56423487283 |
| 47 | + 0x3C370EF54646D497, // 1.25e-18 |
| 48 | + 0xBCB1B3CFC61ACF52, // -2.4567e-16 |
| 49 | + 0x39F036448D68D482, // 1.2789e-29 |
| 50 | + 0xB99C100A89BE0A2D, // -3.45899e-31 |
| 51 | + }; |
| 52 | + std::initializer_list<uint16_t> ref_vals = { |
| 53 | + 0, 0x7C00, 0xFC00, 0x49A0, 0x6409, 0x7BFF, 0xFBFF, 0xF4E2, 0x67E7, |
| 54 | + 0x7B84, 0xFB86, 0x7C00, 0xFC00, 0, 0x8000, 0, 0x8000}; |
| 55 | + |
| 56 | + test_host(input_vals, ref_vals, F_Half4(__imf_double2half)); |
| 57 | + test(device_queue, input_vals, ref_vals, F_Half4(__imf_double2half)); |
| 58 | + } |
| 59 | + |
| 60 | + return 0; |
| 61 | +} |
0 commit comments