Skip to content

Commit 6b6f1b4

Browse files
authored
Merge pull request intel#1400 from kbobrovs/esimd_epsilon
[ESIMD][CMPLRTST-18535] Allow small epsilon in FP division result comparison. (intel#1359)
2 parents c8f9365 + c544a4a commit 6b6f1b4

File tree

1 file changed

+36
-20
lines changed

1 file changed

+36
-20
lines changed

SYCL/ESIMD/api/bin_and_cmp_ops_heavy.cpp

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -264,27 +264,35 @@ int main(void) {
264264
bool passed = true;
265265
using BinOp = esimd_test::BinaryOp;
266266

267+
bool SupportsDouble = dev.has(aspect::fp64);
268+
bool SupportsHalf = dev.has(aspect::fp16);
269+
267270
auto arith_ops = esimd_test::ArithBinaryOpsNoDiv;
268271
passed &= test<unsigned char, int, 1, BinOp, VSf, IDf>(arith_ops, q);
269272
passed &= test<char, float, 7, BinOp, VEf, IDf>(arith_ops, q, 0.000001f);
270-
if (dev.has(aspect::fp64))
273+
if (SupportsDouble)
271274
passed &= test<short, double, 7, BinOp, VEf, IDf>(arith_ops, q, 1e-15);
272275
passed &= test<float, float, 32, BinOp, VEf, IDf>(arith_ops, q, 0.000001f);
273-
passed &= test<half, char, 1, BinOp, verify_n, IDf>(arith_ops, q, 1);
274-
passed &= test<half, unsigned int, 32, BinOp, VSf, IDf>(arith_ops, q, 1);
275-
if (dev.has(aspect::fp64))
276+
if (SupportsHalf)
277+
passed &= test<half, char, 1, BinOp, verify_n, IDf>(arith_ops, q, 1);
278+
if (SupportsHalf)
279+
passed &= test<half, unsigned int, 32, BinOp, VSf, IDf>(arith_ops, q, 1);
280+
if (SupportsDouble && SupportsHalf)
276281
passed &= test<double, half, 7, BinOp, VSf, IDf>(arith_ops, q);
277282
passed &= test<short, uint64_t, 7, BinOp, VSf, IDf>(arith_ops, q);
278283
#ifdef USE_BF16
279284
passed &= test<bfloat16, int, 8, BinOp, VSf, IDf>(arith_ops, q);
280-
passed &= test<half, bfloat16, 7, BinOp, VEfa, IDf>(arith_ops, q, 0.03);
285+
if (SupportsHalf)
286+
passed &= test<half, bfloat16, 7, BinOp, VEfa, IDf>(arith_ops, q, 0.03);
281287
#endif // USE_BF16
282288
#ifdef USE_TF32
283289
passed &= test<tfloat32, float, 32, BinOp, VEf, IDf>(arith_ops, q, 0.000001f);
284290
passed &=
285291
test<tfloat32, tfloat32, 32, BinOp, VEf, IDf>(arith_ops, q, 0.000001f);
286292
passed &= test<char, tfloat32, 32, BinOp, VEf, IDf>(arith_ops, q, 0.000001f);
287-
passed &= test<tfloat32, half, 32, BinOp, VEf, IDf>(arith_ops, q, 0.000001f);
293+
if (SupportsHalf)
294+
passed &=
295+
test<tfloat32, half, 32, BinOp, VEf, IDf>(arith_ops, q, 0.000001f);
288296
passed &= test<tfloat32, unsigned char, 32, BinOp, VEf, IDf>(arith_ops, q,
289297
0.000001f);
290298
passed &= test<tfloat32, short, 32, BinOp, VEf, IDf>(arith_ops, q, 0.000001f);
@@ -294,27 +302,31 @@ int main(void) {
294302
passed &= test<unsigned char, int, 1, BinOp, VSf, IDf>(div_op, q);
295303
passed &= test<char, float, 7, BinOp, VEf, IDf>(div_op, q, 0.000001f);
296304
#ifndef WA_BUG
297-
if (dev.has(aspect::fp64))
298-
passed &= test<short, double, 7, BinOp, VSf, IDf>(div_op, q);
305+
if (SupportsDouble)
306+
passed &= test<short, double, 7, BinOp, VEf, IDf>(div_op, q, 0.000001f);
299307
#endif // WA_BUG
300308
passed &= test<float, float, 32, BinOp, VEf, IDf>(div_op, q, 0.000001f);
301-
passed &= test<half, char, 1, BinOp, verify_n, IDf>(div_op, q, 1);
302-
passed &= test<half, unsigned int, 32, BinOp, VSf, IDf>(div_op, q, 1);
309+
if (SupportsHalf)
310+
passed &= test<half, char, 1, BinOp, verify_n, IDf>(div_op, q, 1);
311+
if (SupportsHalf)
312+
passed &= test<half, unsigned int, 32, BinOp, VSf, IDf>(div_op, q, 1);
303313
#ifndef WA_BUG
304-
if (dev.has(aspect::fp64))
305-
passed &= test<double, half, 7, BinOp, VSf, IDf>(div_op, q);
314+
if (SupportsDouble && SupportsHalf)
315+
passed &= test<double, half, 7, BinOp, VEf, IDf>(div_op, q, 0.000001f);
306316
#endif // WA_BUG
307317
passed &= test<short, uint64_t, 7, BinOp, VSf, IDf>(div_op, q);
308318
#ifdef USE_BF16
309319
passed &= test<bfloat16, short, 8, BinOp, VSf, IDf>(div_op, q);
310-
passed &= test<half, bfloat16, 7, BinOp, VEfa, IDf>(div_op, q, 0.03);
320+
if (SupportsHalf)
321+
passed &= test<half, bfloat16, 7, BinOp, VEfa, IDf>(div_op, q, 0.03);
311322
#endif // USE_BF16
312323

313324
#ifdef USE_TF32
314325
passed &= test<tfloat32, float, 32, BinOp, VEf, IDf>(div_op, q, 0.000001f);
315326
passed &= test<tfloat32, tfloat32, 32, BinOp, VEf, IDf>(div_op, q, 0.000001f);
316327
passed &= test<char, tfloat32, 32, BinOp, VEf, IDf>(div_op, q, 0.000001f);
317-
passed &= test<tfloat32, half, 32, BinOp, VEf, IDf>(div_op, q, 0.000001f);
328+
if (SupportsHalf)
329+
passed &= test<tfloat32, half, 32, BinOp, VEf, IDf>(div_op, q, 0.000001f);
318330
passed &=
319331
test<tfloat32, unsigned char, 32, BinOp, VEf, IDf>(div_op, q, 0.000001f);
320332
passed &= test<tfloat32, short, 32, BinOp, VEf, IDf>(div_op, q, 0.000001f);
@@ -351,24 +363,28 @@ int main(void) {
351363
auto cmp_ops = esimd_test::CmpOps;
352364
passed &= test<unsigned char, int, 1, CmpOp, VSf, IDf>(cmp_ops, q);
353365
passed &= test<char, float, 7, CmpOp, VSf, IDf>(cmp_ops, q);
354-
if (dev.has(aspect::fp64))
366+
if (SupportsDouble)
355367
passed &= test<short, double, 7, CmpOp, VSf, IDf>(cmp_ops, q);
356368
passed &= test<float, float, 32, CmpOp, VSf, IDf>(cmp_ops, q);
357-
passed &= test<half, char, 1, CmpOp, VSf, IDf>(cmp_ops, q, 1);
358-
passed &= test<half, unsigned int, 32, CmpOp, VSf, IDf>(cmp_ops, q, 1);
359-
if (dev.has(aspect::fp64))
369+
if (SupportsHalf)
370+
passed &= test<half, char, 1, CmpOp, VSf, IDf>(cmp_ops, q, 1);
371+
if (SupportsHalf)
372+
passed &= test<half, unsigned int, 32, CmpOp, VSf, IDf>(cmp_ops, q, 1);
373+
if (SupportsDouble)
360374
passed &= test<double, half, 7, CmpOp, VSf, IDf>(cmp_ops, q);
361375
passed &= test<short, uint64_t, 7, CmpOp, VSf, IDf>(cmp_ops, q);
362376
#ifdef USE_BF16
363377
passed &= test<bfloat16, int, 32, CmpOp, VSf, IDf>(cmp_ops, q);
364-
passed &= test<half, bfloat16, 7, CmpOp, VSf, IDf>(cmp_ops, q);
378+
if (SupportsHalf)
379+
passed &= test<half, bfloat16, 7, CmpOp, VSf, IDf>(cmp_ops, q);
365380
#endif // USE_BF16
366381

367382
#ifdef USE_TF32
368383
passed &= test<tfloat32, float, 32, CmpOp, VSf, IDf>(cmp_ops, q);
369384
passed &= test<tfloat32, tfloat32, 32, CmpOp, VSf, IDf>(cmp_ops, q);
370385
passed &= test<char, tfloat32, 32, CmpOp, VSf, IDf>(cmp_ops, q);
371-
passed &= test<tfloat32, half, 32, CmpOp, VSf, IDf>(cmp_ops, q);
386+
if (SupportsHalf)
387+
passed &= test<tfloat32, half, 32, CmpOp, VSf, IDf>(cmp_ops, q);
372388
passed &= test<tfloat32, unsigned char, 32, CmpOp, VSf, IDf>(cmp_ops, q);
373389
passed &= test<tfloat32, short, 32, CmpOp, VSf, IDf>(cmp_ops, q);
374390
#endif // USE_TF32

0 commit comments

Comments
 (0)