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

Commit 4e1d6e4

Browse files
committed
test case for expected NAN behaviour.
1 parent 6856b89 commit 4e1d6e4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

SYCL/BFloat16/bfloat16_builtins.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,26 @@ bool check(float a, float b) {
200200
TEST_BUILTIN_3_ARR_IMPL(NAME, 4) \
201201
TEST_BUILTIN_3_ARR_IMPL(NAME, 5)
202202

203+
#define TEST_BUILTIN_2_NAN(NAME) \
204+
{ \
205+
buffer<int> err_buf(&err, 1); \
206+
buffer<float> nan_buf(&check_nan, 1); \
207+
q.submit([&](handler &cgh) { \
208+
accessor<int, 1, access::mode::write, target::device> ERR(err_buf, cgh); \
209+
accessor<float, 1, access::mode::write, target::device> checkNAN( \
210+
nan_buf, cgh); \
211+
cgh.single_task([=]() { \
212+
checkNAN[0] = make_fp32(NAME(bfloat16{NAN}, bfloat16{NAN}).raw()); \
213+
if ((make_fp32(NAME(bfloat16{2}, bfloat16{NAN}).raw()) != 2) || \
214+
(make_fp32(NAME(bfloat16{NAN}, bfloat16{2}).raw()) != 2)) { \
215+
ERR[0] = 1; \
216+
} \
217+
}); \
218+
}); \
219+
} \
220+
assert(err == 0); \
221+
assert(std::isnan(check_nan));
222+
203223
int main() {
204224
queue q;
205225

@@ -222,6 +242,10 @@ int main() {
222242
TEST_BUILTIN_2(fmin);
223243
TEST_BUILTIN_2(fmax);
224244
TEST_BUILTIN_3(fma);
245+
246+
float check_nan = 0;
247+
TEST_BUILTIN_2_NAN(fmin);
248+
TEST_BUILTIN_2_NAN(fmax);
225249
}
226250
return 0;
227251
}

0 commit comments

Comments
 (0)