@@ -475,39 +475,69 @@ struct sub_group {
475
475
__SYCL_DEPRECATED (" Collectives in the sub-group class are deprecated. Use "
476
476
" sycl::intel::broadcast instead." )
477
477
EnableIfIsScalarArithmetic<T> broadcast (T x, id<1 > local_id) const {
478
+ #ifdef __SYCL_DEVICE_ONLY__
478
479
return sycl::detail::spirv::GroupBroadcast<sub_group>(x, local_id);
480
+ #else
481
+ (void )x;
482
+ (void )local_id;
483
+ throw runtime_error (" Sub-groups are not supported on host device." ,
484
+ PI_INVALID_DEVICE);
485
+ #endif
479
486
}
480
487
481
488
template <typename T, class BinaryOperation >
482
489
__SYCL_DEPRECATED (" Collectives in the sub-group class are deprecated. Use "
483
490
" sycl::intel::reduce instead." )
484
491
EnableIfIsScalarArithmetic<T> reduce (T x, BinaryOperation op) const {
492
+ #ifdef __SYCL_DEVICE_ONLY__
485
493
return sycl::detail::calc<T, __spv::GroupOperation::Reduce,
486
494
__spv::Scope::Subgroup>(
487
495
typename sycl::detail::GroupOpTag<T>::type (), x, op);
496
+ #else
497
+ (void )x;
498
+ (void )op;
499
+ throw runtime_error (" Sub-groups are not supported on host device." ,
500
+ PI_INVALID_DEVICE);
501
+ #endif
488
502
}
489
503
490
504
template <typename T, class BinaryOperation >
491
505
__SYCL_DEPRECATED (" Collectives in the sub-group class are deprecated. Use "
492
506
" sycl::intel::reduce instead." )
493
507
EnableIfIsScalarArithmetic<T> reduce (T x, T init, BinaryOperation op) const {
508
+ #ifdef __SYCL_DEVICE_ONLY__
494
509
return op (init, reduce (x, op));
510
+ #else
511
+ (void )x;
512
+ (void )init;
513
+ (void )op;
514
+ throw runtime_error (" Sub-groups are not supported on host device." ,
515
+ PI_INVALID_DEVICE);
516
+ #endif
495
517
}
496
518
497
519
template <typename T, class BinaryOperation >
498
520
__SYCL_DEPRECATED (" Collectives in the sub-group class are deprecated. Use "
499
521
" sycl::intel::exclusive_scan instead." )
500
522
EnableIfIsScalarArithmetic<T> exclusive_scan (T x, BinaryOperation op) const {
523
+ #ifdef __SYCL_DEVICE_ONLY__
501
524
return sycl::detail::calc<T, __spv::GroupOperation::ExclusiveScan,
502
525
__spv::Scope::Subgroup>(
503
526
typename sycl::detail::GroupOpTag<T>::type (), x, op);
527
+ #else
528
+ (void )x;
529
+ (void )op;
530
+ throw runtime_error (" Sub-groups are not supported on host device." ,
531
+ PI_INVALID_DEVICE);
532
+ #endif
504
533
}
505
534
506
535
template <typename T, class BinaryOperation >
507
536
__SYCL_DEPRECATED (" Collectives in the sub-group class are deprecated. Use "
508
537
" sycl::intel::exclusive_scan instead." )
509
538
EnableIfIsScalarArithmetic<T> exclusive_scan (T x, T init,
510
539
BinaryOperation op) const {
540
+ #ifdef __SYCL_DEVICE_ONLY__
511
541
if (get_local_id ().get (0 ) == 0 ) {
512
542
x = op (init, x);
513
543
}
@@ -516,26 +546,48 @@ struct sub_group {
516
546
scan = init;
517
547
}
518
548
return scan;
549
+ #else
550
+ (void )x;
551
+ (void )init;
552
+ (void )op;
553
+ throw runtime_error (" Sub-groups are not supported on host device." ,
554
+ PI_INVALID_DEVICE);
555
+ #endif
519
556
}
520
557
521
558
template <typename T, class BinaryOperation >
522
559
__SYCL_DEPRECATED (" Collectives in the sub-group class are deprecated. Use "
523
560
" sycl::intel::inclusive_scan instead." )
524
561
EnableIfIsScalarArithmetic<T> inclusive_scan (T x, BinaryOperation op) const {
562
+ #ifdef __SYCL_DEVICE_ONLY__
525
563
return sycl::detail::calc<T, __spv::GroupOperation::InclusiveScan,
526
564
__spv::Scope::Subgroup>(
527
565
typename sycl::detail::GroupOpTag<T>::type (), x, op);
566
+ #else
567
+ (void )x;
568
+ (void )op;
569
+ throw runtime_error (" Sub-groups are not supported on host device." ,
570
+ PI_INVALID_DEVICE);
571
+ #endif
528
572
}
529
573
530
574
template <typename T, class BinaryOperation >
531
575
__SYCL_DEPRECATED (" Collectives in the sub-group class are deprecated. Use "
532
576
" sycl::intel::inclusive_scan instead." )
533
577
EnableIfIsScalarArithmetic<T> inclusive_scan (T x, BinaryOperation op,
534
578
T init) const {
579
+ #ifdef __SYCL_DEVICE_ONLY__
535
580
if (get_local_id ().get (0 ) == 0 ) {
536
581
x = op (init, x);
537
582
}
538
583
return inclusive_scan (x, op);
584
+ #else
585
+ (void )x;
586
+ (void )op;
587
+ (void )init;
588
+ throw runtime_error (" Sub-groups are not supported on host device." ,
589
+ PI_INVALID_DEVICE);
590
+ #endif
539
591
}
540
592
541
593
protected:
0 commit comments