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

[SYCL] Add lit test for integer math function abs, labs, llabs #184

Merged
merged 2 commits into from
Apr 28, 2021
Merged
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
18 changes: 17 additions & 1 deletion SYCL/DeviceLib/cmath_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %clangxx -fsycl -fno-builtin %s -o %t.out
// RUN: %HOST_RUN_PLACEHOLDER %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %ACC_RUN_PLACEHOLDER %t.out
Expand Down Expand Up @@ -192,25 +192,41 @@ void device_integer_math_test(s::queue &deviceQueue) {
ldiv_t result_l[1];
lldiv_t result_ll[1];

int result_i2[1];
long int result_l2[1];
long long int result_ll2[1];

{
s::buffer<div_t, 1> buffer1(result_i, s::range<1>{1});
s::buffer<ldiv_t, 1> buffer2(result_l, s::range<1>{1});
s::buffer<lldiv_t, 1> buffer3(result_ll, s::range<1>{1});
s::buffer<int, 1> buffer4(result_i2, s::range<1>{1});
s::buffer<long int, 1> buffer5(result_l2, s::range<1>{1});
s::buffer<long long int, 1> buffer6(result_ll2, s::range<1>{1});
deviceQueue.submit([&](s::handler &cgh) {
auto res_i_access = buffer1.get_access<sycl_write>(cgh);
auto res_l_access = buffer2.get_access<sycl_write>(cgh);
auto res_ll_access = buffer3.get_access<sycl_write>(cgh);
auto res_i2_access = buffer4.get_access<sycl_write>(cgh);
auto res_l2_access = buffer5.get_access<sycl_write>(cgh);
auto res_ll2_access = buffer6.get_access<sycl_write>(cgh);
cgh.single_task<class DeviceIntMathTest>([=]() {
res_i_access[0] = std::div(99, 4);
res_l_access[0] = std::ldiv(10000, 23);
res_ll_access[0] = std::lldiv(200000000, 47);
res_i2_access[0] = std::abs(-111);
res_l2_access[0] = std::labs(10000);
res_ll2_access[0] = std::llabs(-2000000);
});
});
}

assert(result_i[0].quot == 24 && result_i[0].rem == 3);
assert(result_l[0].quot == 434 && result_l[0].rem == 18);
assert(result_ll[0].quot == 4255319 && result_ll[0].rem == 7);
assert(result_i2[0] == 111);
assert(result_l2[0] == 10000);
assert(result_ll2[0] == 2000000);
}

int main() {
Expand Down