Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

[SYCL] Disable Signbit issue for NAN #653

Merged
merged 4 commits into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions SYCL/DeviceLib/built-ins/vector_relational.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,26 +339,24 @@ int main() {

// signbit
{
s::cl_int4 r{0};
s::cl_int3 r{0};
{
s::buffer<s::cl_int4, 1> BufR(&r, s::range<1>(1));
s::buffer<s::cl_int3, 1> BufR(&r, s::range<1>(1));
s::queue myQueue;
myQueue.submit([&](s::handler &cgh) {
auto AccR = BufR.get_access<s::access::mode::write>(cgh);
cgh.single_task<class signbitF4>([=]() {
AccR[0] = s::signbit(s::cl_float4{0.5f, -12.0f, NAN, INFINITY});
cgh.single_task<class signbitF3>([=]() {
AccR[0] = s::signbit(s::cl_float3{0.5f, -12.0f, INFINITY});
});
});
}
s::cl_int r1 = r.x();
s::cl_int r2 = r.y();
s::cl_int r3 = r.z();
s::cl_int r4 = r.w();

assert(r1 == 0);
assert(r2 == -1);
assert(r3 == 0);
assert(r4 == 0);
}

// any.
Expand Down
9 changes: 2 additions & 7 deletions SYCL/DeviceLib/cmath_fp64_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// FIXME unsupported on windows (opencl) until fix of libdevice fails
// UNSUPPORTED: windows && opencl
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %HOST_RUN_PLACEHOLDER %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
Expand All @@ -15,12 +13,12 @@ namespace s = cl::sycl;
constexpr s::access::mode sycl_read = s::access::mode::read;
constexpr s::access::mode sycl_write = s::access::mode::write;

#define TEST_NUM 63
#define TEST_NUM 61

double ref[TEST_NUM] = {
1, 0, 0, 0, 0, 0, 0, 1, 1, 0.5, 0, 2, 0, 0, 1, 0, 2, 0, 0, 0, 0,
0, 1, 0, 1, 2, 0, 1, 2, 5, 0, 0, 0, 0, 0.5, 0.5, NAN, NAN, 2, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

double refIptr = 1;

Expand Down Expand Up @@ -97,9 +95,6 @@ template <class T> void device_cmath_test(s::queue &deviceQueue) {

res_access[i++] = !(std::signbit(infinity) == 0);
res_access[i++] = !(std::signbit(minus_infinity) != 0);
res_access[i++] = !(std::signbit(nan) == 0);
res_access[i++] = !(std::signbit(minus_nan) != 0);

res_access[i++] = !(std::isunordered(minus_nan, nan) != 0);
res_access[i++] = !(std::isunordered(minus_infinity, infinity) == 0);
res_access[i++] = !(std::isgreater(minus_infinity, infinity) == 0);
Expand Down
15 changes: 5 additions & 10 deletions SYCL/DeviceLib/cmath_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// FIXME unsupported on windows (opencl) until fix of libdevice fails
// UNSUPPORTED: windows && opencl
// RUN: %clangxx -fsycl -fno-builtin %s -o %t.out
// RUN: %HOST_RUN_PLACEHOLDER %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
Expand All @@ -15,12 +13,12 @@ namespace s = cl::sycl;
constexpr s::access::mode sycl_read = s::access::mode::read;
constexpr s::access::mode sycl_write = s::access::mode::write;

#define TEST_NUM 61
#define TEST_NUM 59

float ref[TEST_NUM] = {1, 0, 0, 0, 0, 0, 0, 1, 1, 0.5, 0, 0, 1, 0, 2, 0,
0, 0, 0, 0, 1, 0, 1, 2, 0, 1, 2, 5, 0, 0, 0, 0,
0.5, 0.5, NAN, NAN, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
float ref[TEST_NUM] = {1, 0, 0, 0, 0, 0, 0, 1, 1, 0.5, 0, 0, 1, 0, 2,
0, 0, 0, 0, 0, 1, 0, 1, 2, 0, 1, 2, 5, 0, 0,
0, 0, 0.5, 0.5, NAN, NAN, 2, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

float refIptr = 1;

Expand Down Expand Up @@ -90,9 +88,6 @@ template <class T> void device_cmath_test_1(s::queue &deviceQueue) {

res_access[i++] = !(std::signbit(infinity) == 0);
res_access[i++] = !(std::signbit(minus_infinity) != 0);
res_access[i++] = !(std::signbit(nan) == 0);
res_access[i++] = !(std::signbit(minus_nan) != 0);

res_access[i++] = !(std::isunordered(minus_nan, nan) != 0);
res_access[i++] = !(std::isunordered(minus_infinity, infinity) == 0);
res_access[i++] = !(std::isgreater(minus_infinity, infinity) == 0);
Expand Down
9 changes: 2 additions & 7 deletions SYCL/DeviceLib/math_fp64_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// FIXME unsupported on windows (opencl) until fix of libdevice fails
// UNSUPPORTED: windows && opencl
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %HOST_RUN_PLACEHOLDER %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
Expand All @@ -15,12 +13,12 @@ namespace s = cl::sycl;
constexpr s::access::mode sycl_read = s::access::mode::read;
constexpr s::access::mode sycl_write = s::access::mode::write;

#define TEST_NUM 63
#define TEST_NUM 61

double ref_val[TEST_NUM] = {
1, 0, 0, 0, 0, 0, 0, 1, 1, 0.5, 0, 2, 0, 0, 1, 0, 2, 0, 0, 0, 0,
0, 1, 0, 1, 2, 0, 1, 2, 5, 0, 0, 0, 0, 0.5, 0.5, NAN, NAN, 2, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

double refIptr = 1;

Expand Down Expand Up @@ -98,9 +96,6 @@ void device_math_test(s::queue &deviceQueue) {

res_access[i++] = !(signbit(infinity) == 0);
res_access[i++] = !(signbit(minus_infinity) != 0);
res_access[i++] = !(signbit(nan) == 0);
res_access[i++] = !(signbit(minus_nan) != 0);

res_access[i++] = !(isunordered(minus_nan, nan) != 0);
res_access[i++] = !(isunordered(minus_infinity, infinity) == 0);
res_access[i++] = !(isgreater(minus_infinity, infinity) == 0);
Expand Down
13 changes: 4 additions & 9 deletions SYCL/DeviceLib/math_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// FIXME unsupported on windows (opencl) until fix of libdevice fails
// UNSUPPORTED: windows && opencl
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %HOST_RUN_PLACEHOLDER %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
Expand All @@ -15,12 +13,12 @@ namespace s = cl::sycl;
constexpr s::access::mode sycl_read = s::access::mode::read;
constexpr s::access::mode sycl_write = s::access::mode::write;

#define TEST_NUM 61
#define TEST_NUM 59

float ref_val[TEST_NUM] = {
1, 0, 0, 0, 0, 0, 0, 1, 1, 0.5, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 1,
0, 1, 2, 0, 1, 2, 5, 0, 0, 0, 0, 0.5, 0.5, NAN, NAN, 2, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
1, 0, 0, 0, 0, 0, 0, 1, 1, 0.5, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0,
1, 0, 1, 2, 0, 1, 2, 5, 0, 0, 0, 0, 0.5, 0.5, NAN, NAN, 2, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

float refIptr = 1;

Expand Down Expand Up @@ -90,9 +88,6 @@ void device_math_test(s::queue &deviceQueue) {

res_access[i++] = !(signbit(infinity) == 0);
res_access[i++] = !(signbit(minus_infinity) != 0);
res_access[i++] = !(signbit(nan) == 0);
res_access[i++] = !(signbit(minus_nan) != 0);

res_access[i++] = !(isunordered(minus_nan, nan) != 0);
res_access[i++] = !(isunordered(minus_infinity, infinity) == 0);
res_access[i++] = !(isgreater(minus_infinity, infinity) == 0);
Expand Down