@@ -190,6 +190,14 @@ class handler {
190
190
return Storage;
191
191
}
192
192
193
+ void throwIfActionIsCreated () {
194
+ if (detail::CG::NONE != MCGType)
195
+ throw sycl::runtime_error (" Attempt to set multiple actions for the "
196
+ " command group. Command group must consist of "
197
+ " a single kernel or explicit memory operation." ,
198
+ CL_INVALID_OPERATION);
199
+ }
200
+
193
201
// The method extracts and prepares kernel arguments from the lambda using
194
202
// integration header.
195
203
void
@@ -676,6 +684,7 @@ class handler {
676
684
// single_task version with a kernel represented as a lambda.
677
685
template <typename KernelName = detail::auto_name, typename KernelType>
678
686
void single_task (KernelType KernelFunc) {
687
+ throwIfActionIsCreated ();
679
688
using NameT =
680
689
typename detail::get_kernel_name_t <KernelName, KernelType>::name;
681
690
#ifdef __SYCL_DEVICE_ONLY__
@@ -693,6 +702,7 @@ class handler {
693
702
template <typename KernelName = detail::auto_name, typename KernelType,
694
703
int Dims>
695
704
void parallel_for (range<Dims> NumWorkItems, KernelType KernelFunc) {
705
+ throwIfActionIsCreated ();
696
706
using NameT =
697
707
typename detail::get_kernel_name_t <KernelName, KernelType>::name;
698
708
#ifdef __SYCL_DEVICE_ONLY__
@@ -706,6 +716,7 @@ class handler {
706
716
707
717
// Similar to single_task, but passed lambda will be executed on host.
708
718
template <typename FuncT> void run_on_host_intel (FuncT Func) {
719
+ throwIfActionIsCreated ();
709
720
MNDRDesc.set (range<1 >{1 });
710
721
711
722
MArgs = std::move (MAssociatedAccesors);
@@ -719,6 +730,7 @@ class handler {
719
730
int Dims>
720
731
void parallel_for (range<Dims> NumWorkItems, id<Dims> WorkItemOffset,
721
732
KernelType KernelFunc) {
733
+ throwIfActionIsCreated ();
722
734
using NameT =
723
735
typename detail::get_kernel_name_t <KernelName, KernelType>::name;
724
736
#ifdef __SYCL_DEVICE_ONLY__
@@ -735,6 +747,7 @@ class handler {
735
747
template <typename KernelName = detail::auto_name, typename KernelType,
736
748
int Dims>
737
749
void parallel_for (nd_range<Dims> ExecutionRange, KernelType KernelFunc) {
750
+ throwIfActionIsCreated ();
738
751
using NameT =
739
752
typename detail::get_kernel_name_t <KernelName, KernelType>::name;
740
753
#ifdef __SYCL_DEVICE_ONLY__
@@ -750,6 +763,7 @@ class handler {
750
763
int Dims>
751
764
void parallel_for_work_group (range<Dims> NumWorkGroups,
752
765
KernelType KernelFunc) {
766
+ throwIfActionIsCreated ();
753
767
using NameT =
754
768
typename detail::get_kernel_name_t <KernelName, KernelType>::name;
755
769
#ifdef __SYCL_DEVICE_ONLY__
@@ -766,6 +780,7 @@ class handler {
766
780
void parallel_for_work_group (range<Dims> NumWorkGroups,
767
781
range<Dims> WorkGroupSize,
768
782
KernelType KernelFunc) {
783
+ throwIfActionIsCreated ();
769
784
using NameT =
770
785
typename detail::get_kernel_name_t <KernelName, KernelType>::name;
771
786
#ifdef __SYCL_DEVICE_ONLY__
@@ -780,6 +795,7 @@ class handler {
780
795
// single_task version with a kernel represented as a sycl::kernel.
781
796
// The kernel invocation method has no functors and cannot be called on host.
782
797
void single_task (kernel SyclKernel) {
798
+ throwIfActionIsCreated ();
783
799
verifySyclKernelInvoc (SyclKernel);
784
800
MNDRDesc.set (range<1 >{1 });
785
801
MSyclKernel = detail::getSyclObjImpl (std::move (SyclKernel));
@@ -792,6 +808,7 @@ class handler {
792
808
// functors and cannot be called on host.
793
809
template <int Dims>
794
810
void parallel_for (range<Dims> NumWorkItems, kernel SyclKernel) {
811
+ throwIfActionIsCreated ();
795
812
verifySyclKernelInvoc (SyclKernel);
796
813
MSyclKernel = detail::getSyclObjImpl (std::move (SyclKernel));
797
814
MNDRDesc.set (std::move (NumWorkItems));
@@ -805,6 +822,7 @@ class handler {
805
822
template <int Dims>
806
823
void parallel_for (range<Dims> NumWorkItems, id<Dims> workItemOffset,
807
824
kernel SyclKernel) {
825
+ throwIfActionIsCreated ();
808
826
verifySyclKernelInvoc (SyclKernel);
809
827
MSyclKernel = detail::getSyclObjImpl (std::move (SyclKernel));
810
828
MNDRDesc.set (std::move (NumWorkItems), std::move (workItemOffset));
@@ -817,6 +835,7 @@ class handler {
817
835
// method has no functors and cannot be called on host.
818
836
template <int Dims>
819
837
void parallel_for (nd_range<Dims> NDRange, kernel SyclKernel) {
838
+ throwIfActionIsCreated ();
820
839
verifySyclKernelInvoc (SyclKernel);
821
840
MSyclKernel = detail::getSyclObjImpl (std::move (SyclKernel));
822
841
MNDRDesc.set (std::move (NDRange));
@@ -833,6 +852,7 @@ class handler {
833
852
// which is used otherwise.
834
853
template <typename KernelName = detail::auto_name, typename KernelType>
835
854
void single_task (kernel SyclKernel, KernelType KernelFunc) {
855
+ throwIfActionIsCreated ();
836
856
using NameT =
837
857
typename detail::get_kernel_name_t <KernelName, KernelType>::name;
838
858
#ifdef __SYCL_DEVICE_ONLY__
@@ -855,6 +875,7 @@ class handler {
855
875
int Dims>
856
876
void parallel_for (kernel SyclKernel, range<Dims> NumWorkItems,
857
877
KernelType KernelFunc) {
878
+ throwIfActionIsCreated ();
858
879
using NameT =
859
880
typename detail::get_kernel_name_t <KernelName, KernelType>::name;
860
881
#ifdef __SYCL_DEVICE_ONLY__
@@ -877,6 +898,7 @@ class handler {
877
898
int Dims>
878
899
void parallel_for (kernel SyclKernel, range<Dims> NumWorkItems,
879
900
id<Dims> WorkItemOffset, KernelType KernelFunc) {
901
+ throwIfActionIsCreated ();
880
902
using NameT =
881
903
typename detail::get_kernel_name_t <KernelName, KernelType>::name;
882
904
#ifdef __SYCL_DEVICE_ONLY__
@@ -899,6 +921,7 @@ class handler {
899
921
int Dims>
900
922
void parallel_for (kernel SyclKernel, nd_range<Dims> NDRange,
901
923
KernelType KernelFunc) {
924
+ throwIfActionIsCreated ();
902
925
using NameT =
903
926
typename detail::get_kernel_name_t <KernelName, KernelType>::name;
904
927
#ifdef __SYCL_DEVICE_ONLY__
@@ -924,6 +947,7 @@ class handler {
924
947
int Dims>
925
948
void parallel_for_work_group (kernel SyclKernel, range<Dims> NumWorkGroups,
926
949
KernelType KernelFunc) {
950
+ throwIfActionIsCreated ();
927
951
using NameT =
928
952
typename detail::get_kernel_name_t <KernelName, KernelType>::name;
929
953
#ifdef __SYCL_DEVICE_ONLY__
@@ -943,6 +967,7 @@ class handler {
943
967
void parallel_for_work_group (kernel SyclKernel, range<Dims> NumWorkGroups,
944
968
range<Dims> WorkGroupSize,
945
969
KernelType KernelFunc) {
970
+ throwIfActionIsCreated ();
946
971
using NameT =
947
972
typename detail::get_kernel_name_t <KernelName, KernelType>::name;
948
973
#ifdef __SYCL_DEVICE_ONLY__
@@ -977,6 +1002,7 @@ class handler {
977
1002
access::placeholder IsPlaceholder = access::placeholder::false_t >
978
1003
void copy (accessor<T_Src, Dims, AccessMode, AccessTarget, IsPlaceholder> Src,
979
1004
shared_ptr_class<T_Dst> Dst) {
1005
+ throwIfActionIsCreated ();
980
1006
static_assert (isValidTargetForExplicitOp (AccessTarget),
981
1007
" Invalid accessor target for the copy method." );
982
1008
// Make sure data shared_ptr points to is not released until we finish
@@ -993,6 +1019,7 @@ class handler {
993
1019
void
994
1020
copy (shared_ptr_class<T_Src> Src,
995
1021
accessor<T_Dst, Dims, AccessMode, AccessTarget, IsPlaceholder> Dst) {
1022
+ throwIfActionIsCreated ();
996
1023
static_assert (isValidTargetForExplicitOp (AccessTarget),
997
1024
" Invalid accessor target for the copy method." );
998
1025
// Make sure data shared_ptr points to is not released until we finish
@@ -1008,6 +1035,7 @@ class handler {
1008
1035
access::placeholder IsPlaceholder = access::placeholder::false_t >
1009
1036
void copy (accessor<T_Src, Dims, AccessMode, AccessTarget, IsPlaceholder> Src,
1010
1037
T_Dst *Dst) {
1038
+ throwIfActionIsCreated ();
1011
1039
static_assert (isValidTargetForExplicitOp (AccessTarget),
1012
1040
" Invalid accessor target for the copy method." );
1013
1041
#ifndef __SYCL_DEVICE_ONLY__
@@ -1047,6 +1075,7 @@ class handler {
1047
1075
void
1048
1076
copy (const T_Src *Src,
1049
1077
accessor<T_Dst, Dims, AccessMode, AccessTarget, IsPlaceholder> Dst) {
1078
+ throwIfActionIsCreated ();
1050
1079
static_assert (isValidTargetForExplicitOp (AccessTarget),
1051
1080
" Invalid accessor target for the copy method." );
1052
1081
#ifndef __SYCL_DEVICE_ONLY__
@@ -1124,6 +1153,7 @@ class handler {
1124
1153
accessor<T_Dst, Dims_Dst, AccessMode_Dst, AccessTarget_Dst,
1125
1154
IsPlaceholder_Dst>
1126
1155
Dst) {
1156
+ throwIfActionIsCreated ();
1127
1157
static_assert (isValidTargetForExplicitOp (AccessTarget_Src),
1128
1158
" Invalid source accessor target for the copy method." );
1129
1159
static_assert (isValidTargetForExplicitOp (AccessTarget_Dst),
@@ -1177,6 +1207,7 @@ class handler {
1177
1207
access::placeholder IsPlaceholder = access::placeholder::false_t >
1178
1208
void
1179
1209
update_host (accessor<T, Dims, AccessMode, AccessTarget, IsPlaceholder> Acc) {
1210
+ throwIfActionIsCreated ();
1180
1211
static_assert (isValidTargetForExplicitOp (AccessTarget),
1181
1212
" Invalid accessor target for the update_host method." );
1182
1213
MCGType = detail::CG::UPDATE_HOST;
@@ -1198,6 +1229,7 @@ class handler {
1198
1229
access::placeholder IsPlaceholder = access::placeholder::false_t >
1199
1230
void fill (accessor<T, Dims, AccessMode, AccessTarget, IsPlaceholder> Dst,
1200
1231
const T &Pattern) {
1232
+ throwIfActionIsCreated ();
1201
1233
// TODO add check:T must be an integral scalar value or a SYCL vector type
1202
1234
static_assert (isValidTargetForExplicitOp (AccessTarget),
1203
1235
" Invalid accessor target for the fill method." );
@@ -1229,6 +1261,7 @@ class handler {
1229
1261
1230
1262
// Copy memory from the source to the destination.
1231
1263
void memcpy (void *Dest, const void *Src, size_t Count) {
1264
+ throwIfActionIsCreated ();
1232
1265
MSrcPtr = const_cast <void *>(Src);
1233
1266
MDstPtr = Dest;
1234
1267
MLength = Count;
@@ -1237,6 +1270,7 @@ class handler {
1237
1270
1238
1271
// Fill the memory pointed to by the destination with the given bytes.
1239
1272
void memset (void *Dest, int Value, size_t Count) {
1273
+ throwIfActionIsCreated ();
1240
1274
MDstPtr = Dest;
1241
1275
MPattern.push_back ((char )Value);
1242
1276
MLength = Count;
@@ -1245,6 +1279,7 @@ class handler {
1245
1279
1246
1280
// Prefetch the memory pointed to by the pointer.
1247
1281
void prefetch (const void *Ptr, size_t Count) {
1282
+ throwIfActionIsCreated ();
1248
1283
MDstPtr = const_cast <void *>(Ptr);
1249
1284
MLength = Count;
1250
1285
MCGType = detail::CG::PREFETCH_USM;
0 commit comments