@@ -200,9 +200,9 @@ using is_int_to_int =
200
200
std::is_integral<R>::value>;
201
201
202
202
template <typename T, typename R>
203
- using is_sint_to_sint = std::integral_constant<
204
- bool , is_sigeninteger<T>::value &&
205
- is_sigeninteger<R>::value>;
203
+ using is_sint_to_sint =
204
+ std::integral_constant< bool , is_sigeninteger<T>::value &&
205
+ is_sigeninteger<R>::value>;
206
206
207
207
template <typename T, typename R>
208
208
using is_uint_to_uint =
@@ -240,11 +240,12 @@ using is_float_to_float =
240
240
std::integral_constant<bool , detail::is_floating_point<T>::value &&
241
241
detail::is_floating_point<R>::value>;
242
242
template <typename T>
243
- using is_standart_type =
244
- std::integral_constant< bool , detail::is_sgentype<T>::value &&
245
- !std::is_same<T, long long >::value && !std::is_same<T, unsigned long long >::value>;
243
+ using is_standart_type = std::integral_constant<
244
+ bool , detail::is_sgentype<T>::value && !std::is_same<T, long long >::value &&
245
+ !std::is_same<T, unsigned long long >::value>;
246
246
247
- template <typename T, typename R, rounding_mode roundingMode, typename OpenCLT, typename OpenCLR>
247
+ template <typename T, typename R, rounding_mode roundingMode, typename OpenCLT,
248
+ typename OpenCLR>
248
249
detail::enable_if_t <std::is_same<T, R>::value, R> convertImpl (T Value) {
249
250
return Value;
250
251
}
@@ -253,7 +254,8 @@ detail::enable_if_t<std::is_same<T, R>::value, R> convertImpl(T Value) {
253
254
254
255
// Note for float to half conversions, static_cast calls the conversion operator
255
256
// implemented for host that takes care of the precision requirements.
256
- template <typename T, typename R, rounding_mode roundingMode, typename OpenCLT, typename OpenCLR>
257
+ template <typename T, typename R, rounding_mode roundingMode, typename OpenCLT,
258
+ typename OpenCLR>
257
259
detail::enable_if_t <!std::is_same<T, R>::value &&
258
260
(is_int_to_int<T, R>::value ||
259
261
is_int_to_float<T, R>::value ||
@@ -264,7 +266,8 @@ convertImpl(T Value) {
264
266
}
265
267
266
268
// float to int
267
- template <typename T, typename R, rounding_mode roundingMode, typename OpenCLT, typename OpenCLR>
269
+ template <typename T, typename R, rounding_mode roundingMode, typename OpenCLT,
270
+ typename OpenCLR>
268
271
detail::enable_if_t <is_float_to_int<T, R>::value, R> convertImpl (T Value) {
269
272
switch (roundingMode) {
270
273
// Round to nearest even is default rounding mode for floating-point types
@@ -312,26 +315,28 @@ template <rounding_mode Mode>
312
315
using Rtn = detail::bool_constant<Mode == rounding_mode::rtn>;
313
316
314
317
// convert signed and unsigned types with an equal size and diff names
315
- template <typename T, typename R, rounding_mode roundingMode, typename OpenCLT, typename OpenCLR>
316
- detail::enable_if_t <
317
- !std::is_same<T, R>::value && (is_sint_to_sint<T, R>::value ||
318
- is_uint_to_uint<T, R>::value) &&
319
- std::is_same<OpenCLT, OpenCLR>::value,
320
- R>
318
+ template <typename T, typename R, rounding_mode roundingMode, typename OpenCLT,
319
+ typename OpenCLR>
320
+ detail::enable_if_t <!std::is_same<T, R>::value &&
321
+ (is_sint_to_sint<T, R>::value ||
322
+ is_uint_to_uint<T, R>::value) &&
323
+ std::is_same<OpenCLT, OpenCLR>::value,
324
+ R>
321
325
convertImpl (T Value) {
322
326
return static_cast <R>(Value);
323
327
}
324
328
325
329
// signed to signed
326
330
#define __SYCL_GENERATE_CONVERT_IMPL (DestType ) \
327
- template <typename T, typename R, rounding_mode roundingMode, typename OpenCLT, typename OpenCLR> \
328
- detail::enable_if_t < \
329
- !std::is_same<T, R>::value && is_sint_to_sint<T, R>::value && \
330
- (std::is_same<OpenCLR, DestType>::value || \
331
- std::is_same<OpenCLR, signed char >::value && \
332
- std::is_same<DestType, char >::value) && \
333
- !std::is_same<OpenCLT, OpenCLR>::value, \
334
- R> \
331
+ template <typename T, typename R, rounding_mode roundingMode, \
332
+ typename OpenCLT, typename OpenCLR> \
333
+ detail::enable_if_t <!std::is_same<T, R>::value && \
334
+ is_sint_to_sint<T, R>::value && \
335
+ (std::is_same<OpenCLR, DestType>::value || \
336
+ std::is_same<OpenCLR, signed char >::value && \
337
+ std::is_same<DestType, char >::value) && \
338
+ !std::is_same<OpenCLT, OpenCLR>::value, \
339
+ R> \
335
340
convertImpl (T Value) { \
336
341
OpenCLT OpValue = cl::sycl::detail::convertDataToType<T, OpenCLT>(Value); \
337
342
return __spirv_SConvert##_R##DestType (OpValue); \
@@ -347,12 +352,13 @@ __SYCL_GENERATE_CONVERT_IMPL(longlong)
347
352
348
353
// unsigned to unsigned
349
354
#define __SYCL_GENERATE_CONVERT_IMPL (DestType ) \
350
- template <typename T, typename R, rounding_mode roundingMode, typename OpenCLT, typename OpenCLR> \
351
- detail::enable_if_t < \
352
- !std::is_same<T, R>::value && is_uint_to_uint<T, R>::value && \
353
- std::is_same<OpenCLR, DestType>::value && \
354
- !std::is_same<OpenCLT, OpenCLR>::value, \
355
- R> \
355
+ template <typename T, typename R, rounding_mode roundingMode, \
356
+ typename OpenCLT, typename OpenCLR> \
357
+ detail::enable_if_t <!std::is_same<T, R>::value && \
358
+ is_uint_to_uint<T, R>::value && \
359
+ std::is_same<OpenCLR, DestType>::value && \
360
+ !std::is_same<OpenCLT, OpenCLR>::value, \
361
+ R> \
356
362
convertImpl (T Value) { \
357
363
OpenCLT OpValue = cl::sycl::detail::convertDataToType<T, OpenCLT>(Value); \
358
364
return __spirv_UConvert##_R##DestType (OpValue); \
@@ -366,14 +372,16 @@ __SYCL_GENERATE_CONVERT_IMPL(ulong)
366
372
#undef __SYCL_GENERATE_CONVERT_IMPL
367
373
368
374
// unsigned to (from) signed
369
- template <typename T, typename R, rounding_mode roundingMode, typename OpenCLT, typename OpenCLR>
375
+ template <typename T, typename R, rounding_mode roundingMode, typename OpenCLT,
376
+ typename OpenCLR>
370
377
detail::enable_if_t <is_sint_to_from_uint<T, R>::value, R> convertImpl (T Value) {
371
378
return static_cast <R>(Value);
372
379
}
373
380
374
381
// sint to float
375
382
#define __SYCL_GENERATE_CONVERT_IMPL (SPIRVOp, DestType ) \
376
- template <typename T, typename R, rounding_mode roundingMode, typename OpenCLT, typename OpenCLR> \
383
+ template <typename T, typename R, rounding_mode roundingMode, \
384
+ typename OpenCLT, typename OpenCLR> \
377
385
detail::enable_if_t < \
378
386
is_sint_to_float<T, R>::value && std::is_same<R, DestType>::value, R> \
379
387
convertImpl (T Value) { \
@@ -406,7 +414,8 @@ __SYCL_GENERATE_CONVERT_IMPL(UToF, double)
406
414
// float to float
407
415
#define __SYCL_GENERATE_CONVERT_IMPL (DestType, RoundingMode, \
408
416
RoundingModeCondition) \
409
- template <typename T, typename R, rounding_mode roundingMode, typename OpenCLT, typename OpenCLR> \
417
+ template <typename T, typename R, rounding_mode roundingMode, \
418
+ typename OpenCLT, typename OpenCLR> \
410
419
detail::enable_if_t <!std::is_same<T, R>::value && \
411
420
is_float_to_float<T, R>::value && \
412
421
std::is_same<R, DestType>::value && \
@@ -434,11 +443,12 @@ __SYCL_GENERATE_CONVERT_IMPL_FOR_ROUNDING_MODE(rtn, Rtn)
434
443
// float to int
435
444
#define __SYCL_GENERATE_CONVERT_IMPL (SPIRVOp, DestType, RoundingMode, \
436
445
RoundingModeCondition) \
437
- template <typename T, typename R, rounding_mode roundingMode, typename OpenCLT, typename OpenCLR> \
446
+ template <typename T, typename R, rounding_mode roundingMode, \
447
+ typename OpenCLT, typename OpenCLR> \
438
448
detail::enable_if_t <is_float_to_int<T, R>::value && \
439
- (std::is_same<OpenCLR, DestType>::value || \
440
- std::is_same<OpenCLR, signed char >::value && \
441
- std::is_same<DestType, char >::value) && \
449
+ (std::is_same<OpenCLR, DestType>::value || \
450
+ std::is_same<OpenCLR, signed char >::value && \
451
+ std::is_same<DestType, char >::value) && \
442
452
RoundingModeCondition<roundingMode>::value, \
443
453
R> \
444
454
convertImpl (T Value) { \
@@ -471,16 +481,17 @@ __SYCL_GENERATE_CONVERT_IMPL_FOR_ROUNDING_MODE(rtn, Rtn)
471
481
#undef __SYCL_GENERATE_CONVERT_IMPL_FOR_ROUNDING_MODE
472
482
#undef __SYCL_GENERATE_CONVERT_IMPL
473
483
474
- // Back up
475
- template <typename T, typename R, rounding_mode roundingMode, typename OpenCLT, typename OpenCLR>
476
- detail::enable_if_t <
477
- (!is_standart_type<T>::value && !is_standart_type<OpenCLT>::value ||
478
- !is_standart_type<R>::value && !is_standart_type<OpenCLR>::value) &&
479
- !std::is_same<OpenCLT, OpenCLR>::value,
480
- R>
481
- convertImpl (T Value) {
482
- return static_cast <R>(Value);
483
- }
484
+ // Back up
485
+ template <typename T, typename R, rounding_mode roundingMode, typename OpenCLT,
486
+ typename OpenCLR>
487
+ detail::enable_if_t <
488
+ (!is_standart_type<T>::value && !is_standart_type<OpenCLT>::value ||
489
+ !is_standart_type<R>::value && !is_standart_type<OpenCLR>::value) &&
490
+ !std::is_same<OpenCLT, OpenCLR>::value,
491
+ R>
492
+ convertImpl (T Value) {
493
+ return static_cast <R>(Value);
494
+ }
484
495
485
496
#endif // __SYCL_DEVICE_ONLY__
486
497
@@ -794,7 +805,9 @@ template <typename Type, int NumElements> class vec {
794
805
using OpenCLR = detail::ConvertToOpenCLType_t<convertT>;
795
806
for (size_t I = 0 ; I < NumElements; ++I) {
796
807
Result.setValue (
797
- I, detail::convertImpl<DataT, convertT, roundingMode, OpenCLT, OpenCLR>(getValue (I)));
808
+ I,
809
+ detail::convertImpl<DataT, convertT, roundingMode, OpenCLT, OpenCLR>(
810
+ getValue (I)));
798
811
}
799
812
return Result;
800
813
}
0 commit comments