@@ -264,27 +264,35 @@ int main(void) {
264
264
bool passed = true ;
265
265
using BinOp = esimd_test::BinaryOp;
266
266
267
+ bool SupportsDouble = dev.has (aspect::fp64);
268
+ bool SupportsHalf = dev.has (aspect::fp16);
269
+
267
270
auto arith_ops = esimd_test::ArithBinaryOpsNoDiv;
268
271
passed &= test<unsigned char , int , 1 , BinOp, VSf, IDf>(arith_ops, q);
269
272
passed &= test<char , float , 7 , BinOp, VEf, IDf>(arith_ops, q, 0 .000001f );
270
- if (dev. has (aspect::fp64) )
273
+ if (SupportsDouble )
271
274
passed &= test<short , double , 7 , BinOp, VEf, IDf>(arith_ops, q, 1e-15 );
272
275
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)
276
281
passed &= test<double , half, 7 , BinOp, VSf, IDf>(arith_ops, q);
277
282
passed &= test<short , uint64_t , 7 , BinOp, VSf, IDf>(arith_ops, q);
278
283
#ifdef USE_BF16
279
284
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 );
281
287
#endif // USE_BF16
282
288
#ifdef USE_TF32
283
289
passed &= test<tfloat32, float , 32 , BinOp, VEf, IDf>(arith_ops, q, 0 .000001f );
284
290
passed &=
285
291
test<tfloat32, tfloat32, 32 , BinOp, VEf, IDf>(arith_ops, q, 0 .000001f );
286
292
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 );
288
296
passed &= test<tfloat32, unsigned char , 32 , BinOp, VEf, IDf>(arith_ops, q,
289
297
0 .000001f );
290
298
passed &= test<tfloat32, short , 32 , BinOp, VEf, IDf>(arith_ops, q, 0 .000001f );
@@ -294,27 +302,31 @@ int main(void) {
294
302
passed &= test<unsigned char , int , 1 , BinOp, VSf, IDf>(div_op, q);
295
303
passed &= test<char , float , 7 , BinOp, VEf, IDf>(div_op, q, 0 .000001f );
296
304
#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 );
299
307
#endif // WA_BUG
300
308
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 );
303
313
#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 );
306
316
#endif // WA_BUG
307
317
passed &= test<short , uint64_t , 7 , BinOp, VSf, IDf>(div_op, q);
308
318
#ifdef USE_BF16
309
319
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 );
311
322
#endif // USE_BF16
312
323
313
324
#ifdef USE_TF32
314
325
passed &= test<tfloat32, float , 32 , BinOp, VEf, IDf>(div_op, q, 0 .000001f );
315
326
passed &= test<tfloat32, tfloat32, 32 , BinOp, VEf, IDf>(div_op, q, 0 .000001f );
316
327
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 );
318
330
passed &=
319
331
test<tfloat32, unsigned char , 32 , BinOp, VEf, IDf>(div_op, q, 0 .000001f );
320
332
passed &= test<tfloat32, short , 32 , BinOp, VEf, IDf>(div_op, q, 0 .000001f );
@@ -351,24 +363,28 @@ int main(void) {
351
363
auto cmp_ops = esimd_test::CmpOps;
352
364
passed &= test<unsigned char , int , 1 , CmpOp, VSf, IDf>(cmp_ops, q);
353
365
passed &= test<char , float , 7 , CmpOp, VSf, IDf>(cmp_ops, q);
354
- if (dev. has (aspect::fp64) )
366
+ if (SupportsDouble )
355
367
passed &= test<short , double , 7 , CmpOp, VSf, IDf>(cmp_ops, q);
356
368
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)
360
374
passed &= test<double , half, 7 , CmpOp, VSf, IDf>(cmp_ops, q);
361
375
passed &= test<short , uint64_t , 7 , CmpOp, VSf, IDf>(cmp_ops, q);
362
376
#ifdef USE_BF16
363
377
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);
365
380
#endif // USE_BF16
366
381
367
382
#ifdef USE_TF32
368
383
passed &= test<tfloat32, float , 32 , CmpOp, VSf, IDf>(cmp_ops, q);
369
384
passed &= test<tfloat32, tfloat32, 32 , CmpOp, VSf, IDf>(cmp_ops, q);
370
385
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);
372
388
passed &= test<tfloat32, unsigned char , 32 , CmpOp, VSf, IDf>(cmp_ops, q);
373
389
passed &= test<tfloat32, short , 32 , CmpOp, VSf, IDf>(cmp_ops, q);
374
390
#endif // USE_TF32
0 commit comments