@@ -505,23 +505,27 @@ inline hipError_t inclusive_scan(void* temporary_storage,
505
505
const hipStream_t stream = 0,
506
506
bool debug_synchronous = false)
507
507
{
508
+ // AccType may be const or a reference. Get the non-const, non-reference type.
509
+ // This is necessary because we may need to assign to instances of this type or create pointers to it.
510
+ using safe_acc_type = typename std::remove_const<typename std::remove_reference<AccType>::type>::type;
511
+
508
512
// input_type() is a dummy initial value (not used)
509
513
return detail::scan_impl<detail::lookback_scan_determinism::default_determinism,
510
514
false ,
511
515
Config,
512
516
InputIterator,
513
517
OutputIterator,
514
- AccType ,
518
+ safe_acc_type ,
515
519
BinaryFunction,
516
- AccType >(temporary_storage,
517
- storage_size,
518
- input,
519
- output,
520
- AccType {},
521
- size,
522
- scan_op,
523
- stream,
524
- debug_synchronous);
520
+ safe_acc_type >(temporary_storage,
521
+ storage_size,
522
+ input,
523
+ output,
524
+ safe_acc_type {},
525
+ size,
526
+ scan_op,
527
+ stream,
528
+ debug_synchronous);
525
529
}
526
530
527
531
// / \brief Bitwise-reproducible parallel inclusive scan primitive for device level.
@@ -546,22 +550,26 @@ inline hipError_t deterministic_inclusive_scan(void* temporary_stora
546
550
const hipStream_t stream = 0,
547
551
bool debug_synchronous = false)
548
552
{
553
+ // AccType may be const or a reference. Get the non-const, non-reference type.
554
+ // This is necessary because we may need to assign to instances of this type or create pointers to it.
555
+ using safe_acc_type = typename std::remove_const<typename std::remove_reference<AccType>::type>::type;
556
+
549
557
return detail::scan_impl<detail::lookback_scan_determinism::deterministic,
550
558
false ,
551
559
Config,
552
560
InputIterator,
553
561
OutputIterator,
554
- AccType ,
562
+ safe_acc_type ,
555
563
BinaryFunction,
556
- AccType >(temporary_storage,
557
- storage_size,
558
- input,
559
- output,
560
- AccType {},
561
- size,
562
- scan_op,
563
- stream,
564
- debug_synchronous);
564
+ safe_acc_type >(temporary_storage,
565
+ storage_size,
566
+ input,
567
+ output,
568
+ safe_acc_type {},
569
+ size,
570
+ scan_op,
571
+ stream,
572
+ debug_synchronous);
565
573
}
566
574
567
575
// / \brief Parallel exclusive scan primitive for device level.
@@ -672,22 +680,26 @@ inline hipError_t exclusive_scan(void* temporary_storage,
672
680
const hipStream_t stream = 0,
673
681
bool debug_synchronous = false)
674
682
{
683
+ // AccType may be const or a reference. Get the non-const, non-reference type.
684
+ // This is necessary because we may need to assign to instances of this type or create pointers to it.
685
+ using safe_acc_type = typename std::remove_const<typename std::remove_reference<AccType>::type>::type;
686
+
675
687
return detail::scan_impl<detail::lookback_scan_determinism::default_determinism,
676
688
true ,
677
689
Config,
678
690
InputIterator,
679
691
OutputIterator,
680
692
InitValueType,
681
693
BinaryFunction,
682
- AccType >(temporary_storage,
683
- storage_size,
684
- input,
685
- output,
686
- initial_value,
687
- size,
688
- scan_op,
689
- stream,
690
- debug_synchronous);
694
+ safe_acc_type >(temporary_storage,
695
+ storage_size,
696
+ input,
697
+ output,
698
+ initial_value,
699
+ size,
700
+ scan_op,
701
+ stream,
702
+ debug_synchronous);
691
703
}
692
704
693
705
// / \brief Bitwise-reproducible parallel exclusive scan primitive for device level.
@@ -714,22 +726,26 @@ inline hipError_t deterministic_exclusive_scan(void* temporary_sto
714
726
const hipStream_t stream = 0,
715
727
bool debug_synchronous = false)
716
728
{
729
+ // AccType may be const or a reference. Get the non-const, non-reference type.
730
+ // This is necessary because we may need to assign to instances of this type or create pointers to it.
731
+ using safe_acc_type = typename std::remove_const<typename std::remove_reference<AccType>::type>::type;
732
+
717
733
return detail::scan_impl<detail::lookback_scan_determinism::deterministic,
718
734
true ,
719
735
Config,
720
736
InputIterator,
721
737
OutputIterator,
722
738
InitValueType,
723
739
BinaryFunction,
724
- AccType >(temporary_storage,
725
- storage_size,
726
- input,
727
- output,
728
- initial_value,
729
- size,
730
- scan_op,
731
- stream,
732
- debug_synchronous);
740
+ safe_acc_type >(temporary_storage,
741
+ storage_size,
742
+ input,
743
+ output,
744
+ initial_value,
745
+ size,
746
+ scan_op,
747
+ stream,
748
+ debug_synchronous);
733
749
}
734
750
735
751
// / @}
0 commit comments