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

Commit 4e80749

Browse files
committed
[SYCL] Add lit test for integer math function abs, labs, llabs
Signed-off-by: haonanya <[email protected]>
1 parent f7036ed commit 4e80749

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

SYCL/DeviceLib/cmath_test.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,25 +192,41 @@ void device_integer_math_test(s::queue &deviceQueue) {
192192
ldiv_t result_l[1];
193193
lldiv_t result_ll[1];
194194

195+
int result_i2[1];
196+
long int result_l2[1];
197+
long long int result_ll2[1];
198+
195199
{
196200
s::buffer<div_t, 1> buffer1(result_i, s::range<1>{1});
197201
s::buffer<ldiv_t, 1> buffer2(result_l, s::range<1>{1});
198202
s::buffer<lldiv_t, 1> buffer3(result_ll, s::range<1>{1});
203+
s::buffer<int, 1> buffer4(result_i2, s::range<1>{1});
204+
s::buffer<long int, 1> buffer5(result_l2, s::range<1>{1});
205+
s::buffer<long long int, 1> buffer6(result_ll2, s::range<1>{1});
199206
deviceQueue.submit([&](s::handler &cgh) {
200207
auto res_i_access = buffer1.get_access<sycl_write>(cgh);
201208
auto res_l_access = buffer2.get_access<sycl_write>(cgh);
202209
auto res_ll_access = buffer3.get_access<sycl_write>(cgh);
210+
auto res_i2_access = buffer4.get_access<sycl_write>(cgh);
211+
auto res_l2_access = buffer5.get_access<sycl_write>(cgh);
212+
auto res_ll2_access = buffer6.get_access<sycl_write>(cgh);
203213
cgh.single_task<class DeviceIntMathTest>([=]() {
204214
res_i_access[0] = std::div(99, 4);
205215
res_l_access[0] = std::ldiv(10000, 23);
206216
res_ll_access[0] = std::lldiv(200000000, 47);
217+
res_i2_access[0] = std::abs(-111);
218+
res_l2_access[0] = std::labs(10000);
219+
res_ll2_access[0] = std::llabs(-2000000);
207220
});
208221
});
209222
}
210223

211224
assert(result_i[0].quot == 24 && result_i[0].rem == 3);
212225
assert(result_l[0].quot == 434 && result_l[0].rem == 18);
213226
assert(result_ll[0].quot == 4255319 && result_ll[0].rem == 7);
227+
assert(result_i2[0] == 111);
228+
assert(result_l2[0] == 10000);
229+
assert(result_ll2[0] == 2000000);
214230
}
215231

216232
int main() {

0 commit comments

Comments
 (0)