Skip to content

Commit a810ac1

Browse files
authored
[SYCL] Add lit test for integer math function abs, labs, llabs (intel#184)
Signed-off-by: haonanya <[email protected]>
1 parent c2464fe commit a810ac1

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

SYCL/DeviceLib/cmath_test.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsycl %s -o %t.out
1+
// RUN: %clangxx -fsycl -fno-builtin %s -o %t.out
22
// RUN: %HOST_RUN_PLACEHOLDER %t.out
33
// RUN: %CPU_RUN_PLACEHOLDER %t.out
44
// RUN: %ACC_RUN_PLACEHOLDER %t.out
@@ -170,25 +170,41 @@ void device_integer_math_test(s::queue &deviceQueue) {
170170
ldiv_t result_l[1];
171171
lldiv_t result_ll[1];
172172

173+
int result_i2[1];
174+
long int result_l2[1];
175+
long long int result_ll2[1];
176+
173177
{
174178
s::buffer<div_t, 1> buffer1(result_i, s::range<1>{1});
175179
s::buffer<ldiv_t, 1> buffer2(result_l, s::range<1>{1});
176180
s::buffer<lldiv_t, 1> buffer3(result_ll, s::range<1>{1});
181+
s::buffer<int, 1> buffer4(result_i2, s::range<1>{1});
182+
s::buffer<long int, 1> buffer5(result_l2, s::range<1>{1});
183+
s::buffer<long long int, 1> buffer6(result_ll2, s::range<1>{1});
177184
deviceQueue.submit([&](s::handler &cgh) {
178185
auto res_i_access = buffer1.get_access<sycl_write>(cgh);
179186
auto res_l_access = buffer2.get_access<sycl_write>(cgh);
180187
auto res_ll_access = buffer3.get_access<sycl_write>(cgh);
188+
auto res_i2_access = buffer4.get_access<sycl_write>(cgh);
189+
auto res_l2_access = buffer5.get_access<sycl_write>(cgh);
190+
auto res_ll2_access = buffer6.get_access<sycl_write>(cgh);
181191
cgh.single_task<class DeviceIntMathTest>([=]() {
182192
res_i_access[0] = std::div(99, 4);
183193
res_l_access[0] = std::ldiv(10000, 23);
184194
res_ll_access[0] = std::lldiv(200000000, 47);
195+
res_i2_access[0] = std::abs(-111);
196+
res_l2_access[0] = std::labs(10000);
197+
res_ll2_access[0] = std::llabs(-2000000);
185198
});
186199
});
187200
}
188201

189202
assert(result_i[0].quot == 24 && result_i[0].rem == 3);
190203
assert(result_l[0].quot == 434 && result_l[0].rem == 18);
191204
assert(result_ll[0].quot == 4255319 && result_ll[0].rem == 7);
205+
assert(result_i2[0] == 111);
206+
assert(result_l2[0] == 10000);
207+
assert(result_ll2[0] == 2000000);
192208
}
193209

194210
int main() {

0 commit comments

Comments
 (0)