@@ -70,9 +70,9 @@ inline __SYCL_CONSTEXPR_HALF uint16_t float2Half(const float &Val) {
70
70
Exp16 = 0x1f ;
71
71
} else if (__builtin_expect (Exp32Diff > -14 , 0 )) {
72
72
// normal range for half type
73
- Exp16 = Exp32Diff + 15 ;
73
+ Exp16 = static_cast < uint16_t >( Exp32Diff) + 15 ;
74
74
// convert 23-bit mantissa to 10-bit mantissa.
75
- Frac16 = Frac32 >> 13 ;
75
+ Frac16 = static_cast < uint16_t >( Frac32 >> 13 ) ;
76
76
// Round the mantissa as given in OpenCL spec section : 6.1.1.1 The half
77
77
// data type.
78
78
// Round to nearest.
@@ -85,7 +85,8 @@ inline __SYCL_CONSTEXPR_HALF uint16_t float2Half(const float &Val) {
85
85
Frac16 += Frac16 & 1 ;
86
86
} else if (__builtin_expect (Exp32Diff > -25 , 0 )) {
87
87
// subnormals
88
- Frac16 = (Frac32 | (uint32_t (1 ) << 23 )) >> (-Exp32Diff - 1 );
88
+ Frac16 = static_cast <uint16_t >((Frac32 | (uint32_t (1 ) << 23 )) >>
89
+ (-Exp32Diff - 1 ));
89
90
}
90
91
91
92
if (__builtin_expect (Exp32 == 0xff && Frac32 != 0 , 0 )) {
@@ -133,7 +134,7 @@ inline __SYCL_CONSTEXPR_HALF float half2Float(const uint16_t &Val) {
133
134
Exp32 = 113 - OffSet;
134
135
}
135
136
136
- uint32_t Frac32 = Frac16 << 13 ;
137
+ uint32_t Frac32 = static_cast < uint32_t >( Frac16 << 13 ) ;
137
138
138
139
uint32_t Bits = 0 ;
139
140
Bits |= Sign;
@@ -312,72 +313,72 @@ class [[__sycl_detail__::__uses_aspects__(aspect::fp16)]] half {
312
313
__SYCL_CONSTEXPR_HALF friend half operator op (const half lhs, \
313
314
const int rhs) { \
314
315
half rtn = lhs; \
315
- rtn op_eq rhs; \
316
+ rtn op_eq half ( static_cast < float >( rhs)); \
316
317
return rtn; \
317
318
} \
318
319
__SYCL_CONSTEXPR_HALF friend half operator op (const int lhs, \
319
320
const half rhs) { \
320
- half rtn = lhs; \
321
+ half rtn ( static_cast < float >( lhs)); \
321
322
rtn op_eq rhs; \
322
323
return rtn; \
323
324
} \
324
325
__SYCL_CONSTEXPR_HALF friend half operator op (const half lhs, \
325
326
const long rhs) { \
326
327
half rtn = lhs; \
327
- rtn op_eq rhs; \
328
+ rtn op_eq half ( static_cast < float >( rhs)); \
328
329
return rtn; \
329
330
} \
330
331
__SYCL_CONSTEXPR_HALF friend half operator op (const long lhs, \
331
332
const half rhs) { \
332
- half rtn = lhs; \
333
+ half rtn ( static_cast < float >( lhs)); \
333
334
rtn op_eq rhs; \
334
335
return rtn; \
335
336
} \
336
337
__SYCL_CONSTEXPR_HALF friend half operator op (const half lhs, \
337
338
const long long rhs) { \
338
339
half rtn = lhs; \
339
- rtn op_eq rhs; \
340
+ rtn op_eq half ( static_cast < float >( rhs)); \
340
341
return rtn; \
341
342
} \
342
343
__SYCL_CONSTEXPR_HALF friend half operator op (const long long lhs, \
343
344
const half rhs) { \
344
- half rtn = lhs; \
345
+ half rtn ( static_cast < float >( lhs)); \
345
346
rtn op_eq rhs; \
346
347
return rtn; \
347
348
} \
348
349
__SYCL_CONSTEXPR_HALF friend half operator op (const half &lhs, \
349
350
const unsigned int &rhs) { \
350
351
half rtn = lhs; \
351
- rtn op_eq rhs; \
352
+ rtn op_eq half ( static_cast < float >( rhs)); \
352
353
return rtn; \
353
354
} \
354
355
__SYCL_CONSTEXPR_HALF friend half operator op (const unsigned int &lhs, \
355
356
const half &rhs) { \
356
- half rtn = lhs; \
357
+ half rtn ( static_cast < float >( lhs)); \
357
358
rtn op_eq rhs; \
358
359
return rtn; \
359
360
} \
360
361
__SYCL_CONSTEXPR_HALF friend half operator op (const half &lhs, \
361
362
const unsigned long &rhs) { \
362
363
half rtn = lhs; \
363
- rtn op_eq rhs; \
364
+ rtn op_eq half ( static_cast < float >( rhs)); \
364
365
return rtn; \
365
366
} \
366
367
__SYCL_CONSTEXPR_HALF friend half operator op (const unsigned long &lhs, \
367
368
const half &rhs) { \
368
- half rtn = lhs; \
369
+ half rtn ( static_cast < float >( lhs)); \
369
370
rtn op_eq rhs; \
370
371
return rtn; \
371
372
} \
372
373
__SYCL_CONSTEXPR_HALF friend half operator op ( \
373
374
const half &lhs, const unsigned long long &rhs) { \
374
375
half rtn = lhs; \
375
- rtn op_eq rhs; \
376
+ rtn op_eq half ( static_cast < float >( rhs)); \
376
377
return rtn; \
377
378
} \
378
379
__SYCL_CONSTEXPR_HALF friend half operator op (const unsigned long long &lhs, \
379
380
const half &rhs) { \
380
- half rtn = lhs; \
381
+ half rtn ( static_cast < float >( lhs)); \
381
382
rtn op_eq rhs; \
382
383
return rtn; \
383
384
}
@@ -412,51 +413,51 @@ class [[__sycl_detail__::__uses_aspects__(aspect::fp16)]] half {
412
413
} \
413
414
__SYCL_CONSTEXPR_HALF friend bool operator op (const half &lhs, \
414
415
const int &rhs) { \
415
- return lhs.getFPRep () op rhs; \
416
+ return lhs.getFPRep () op static_cast < float >( rhs); \
416
417
} \
417
418
__SYCL_CONSTEXPR_HALF friend bool operator op (const int &lhs, \
418
419
const half &rhs) { \
419
- return lhs op rhs.getFPRep (); \
420
+ return static_cast < float >( lhs) op rhs.getFPRep (); \
420
421
} \
421
422
__SYCL_CONSTEXPR_HALF friend bool operator op (const half &lhs, \
422
423
const long &rhs) { \
423
- return lhs.getFPRep () op rhs; \
424
+ return lhs.getFPRep () op static_cast < float >( rhs); \
424
425
} \
425
426
__SYCL_CONSTEXPR_HALF friend bool operator op (const long &lhs, \
426
427
const half &rhs) { \
427
- return lhs op rhs.getFPRep (); \
428
+ return static_cast < float >( lhs) op rhs.getFPRep (); \
428
429
} \
429
430
__SYCL_CONSTEXPR_HALF friend bool operator op (const half &lhs, \
430
431
const long long &rhs) { \
431
- return lhs.getFPRep () op rhs; \
432
+ return lhs.getFPRep () op static_cast < float >( rhs); \
432
433
} \
433
434
__SYCL_CONSTEXPR_HALF friend bool operator op (const long long &lhs, \
434
435
const half &rhs) { \
435
- return lhs op rhs.getFPRep (); \
436
+ return static_cast < float >( lhs) op rhs.getFPRep (); \
436
437
} \
437
438
__SYCL_CONSTEXPR_HALF friend bool operator op (const half &lhs, \
438
439
const unsigned int &rhs) { \
439
- return lhs.getFPRep () op rhs; \
440
+ return lhs.getFPRep () op static_cast < float >( rhs); \
440
441
} \
441
442
__SYCL_CONSTEXPR_HALF friend bool operator op (const unsigned int &lhs, \
442
443
const half &rhs) { \
443
- return lhs op rhs.getFPRep (); \
444
+ return static_cast < float >( lhs) op rhs.getFPRep (); \
444
445
} \
445
446
__SYCL_CONSTEXPR_HALF friend bool operator op (const half &lhs, \
446
447
const unsigned long &rhs) { \
447
- return lhs.getFPRep () op rhs; \
448
+ return lhs.getFPRep () op static_cast < float >( rhs); \
448
449
} \
449
450
__SYCL_CONSTEXPR_HALF friend bool operator op (const unsigned long &lhs, \
450
451
const half &rhs) { \
451
- return lhs op rhs.getFPRep (); \
452
+ return static_cast < float >( lhs) op rhs.getFPRep (); \
452
453
} \
453
454
__SYCL_CONSTEXPR_HALF friend bool operator op ( \
454
455
const half &lhs, const unsigned long long &rhs) { \
455
- return lhs.getFPRep () op rhs; \
456
+ return lhs.getFPRep () op static_cast < float >( rhs); \
456
457
} \
457
458
__SYCL_CONSTEXPR_HALF friend bool operator op (const unsigned long long &lhs, \
458
459
const half &rhs) { \
459
- return lhs op rhs.getFPRep (); \
460
+ return static_cast < float >( lhs) op rhs.getFPRep (); \
460
461
}
461
462
OP (==)
462
463
OP (!=)
0 commit comments