@@ -172,12 +172,8 @@ SYCL_ACCESSOR_IMPL(!isTargetHostAccess(accessTarget) &&
172
172
173
173
dataT *Data;
174
174
175
- // Device accessors must be associated with a command group handler.
176
- // The handler though can be nullptr at the creation point if the
177
- // accessor is a placeholder accessor.
178
- accessor_impl (dataT *Data, handler *Handler = nullptr )
179
- : Data (Data)
180
- {}
175
+ // Device accessor constructor.
176
+ accessor_impl (dataT *Data) : Data (Data) {}
181
177
182
178
// Returns the number of accessed elements.
183
179
size_t get_count () const { return 1 ; }
@@ -216,12 +212,9 @@ SYCL_ACCESSOR_IMPL(!isTargetHostAccess(accessTarget) &&
216
212
range<dimensions> MemRange;
217
213
id<dimensions> Offset;
218
214
219
- // Device accessors must be associated with a command group handler.
220
- // The handler though can be nullptr at the creation point if the
221
- // accessor is a placeholder accessor.
215
+ // Device accessor constructor.
222
216
accessor_impl (dataT * Data, range<dimensions> AccessRange,
223
- range<dimensions> MemRange, handler *Handler = nullptr ,
224
- id<dimensions> Offset = {})
217
+ range<dimensions> MemRange, id<dimensions> Offset = {})
225
218
: Data (Data), AccessRange (AccessRange), MemRange (MemRange),
226
219
Offset (Offset) {}
227
220
@@ -259,12 +252,10 @@ SYCL_ACCESSOR_IMPL(accessTarget == access::target::local &&
259
252
260
253
dataT *Data;
261
254
262
- accessor_impl (handler * Handler)
263
- : ByteSize (sizeof (dataT))
264
- {
255
+ accessor_impl (handler &Handler)
256
+ : ByteSize (sizeof (dataT)) {
265
257
#ifndef __SYCL_DEVICE_ONLY__
266
- assert (Handler != nullptr && " Handler is nullptr" );
267
- if (Handler->is_host ()) {
258
+ if (Handler.is_host ()) {
268
259
dataBuf = std::make_shared<vector_class<dataT>>(1 );
269
260
Data = dataBuf->data ();
270
261
}
@@ -315,12 +306,11 @@ SYCL_ACCESSOR_IMPL(accessTarget == access::target::local &&
315
306
// duplication and complication of the code even more.
316
307
id<dimensions> Offset;
317
308
318
- accessor_impl (range<dimensions> Range, handler * Handler)
309
+ accessor_impl (range<dimensions> Range, handler & Handler)
319
310
: AccessRange (Range), MemRange (Range),
320
311
ByteSize (Range.size () * sizeof (dataT)) {
321
312
#ifndef __SYCL_DEVICE_ONLY__
322
- assert (Handler != nullptr && " Handler is nullptr" );
323
- if (Handler->is_host ()) {
313
+ if (Handler.is_host ()) {
324
314
dataBuf = std::make_shared<vector_class<dataT>>(Range.size ());
325
315
Data = dataBuf->data ();
326
316
}
@@ -723,10 +713,12 @@ class accessor
723
713
Dimensions == 0 ),
724
714
buffer<DataT, 1 >>::type &bufferRef)
725
715
#ifdef __SYCL_DEVICE_ONLY__
726
- : impl((dataT *)detail::getSyclObjImpl(bufferRef)->BufPtr) {
716
+ : impl(reinterpret_cast <_ValueType *>(
717
+ detail::getSyclObjImpl (bufferRef)->BufPtr)) {
727
718
#else
728
719
: impl (std::make_shared<_ImplT>(
729
- (dataT *)detail::getSyclObjImpl (bufferRef)->BufPtr )) {
720
+ reinterpret_cast <_ValueType *>(
721
+ detail::getSyclObjImpl (bufferRef)->BufPtr ))) {
730
722
#endif
731
723
auto BufImpl = detail::getSyclObjImpl (bufferRef);
732
724
if (AccessTarget == access ::target::host_buffer) {
@@ -765,11 +757,11 @@ class accessor
765
757
// Pass nullptr as a pointer to mem and use buffers from the ctor
766
758
// arguments to avoid the need in adding utility functions for
767
759
// dummy/default initialization of range fields.
768
- : impl (nullptr , (handler *) nullptr ) {}
760
+ : impl (nullptr ) {}
769
761
#else // !__SYCL_DEVICE_ONLY__
770
762
: impl (std::make_shared<_ImplT>(
771
- (dataT *) detail::getSyclObjImpl (bufferRef)-> BufPtr ,
772
- &commandGroupHandlerRef )) {
763
+ reinterpret_cast <_ValueType *>(
764
+ detail::getSyclObjImpl (bufferRef)-> BufPtr ) )) {
773
765
auto BufImpl = detail::getSyclObjImpl (bufferRef);
774
766
if (BufImpl->OpenCLInterop && !BufImpl->isValidAccessToMem (accessMode)) {
775
767
throw cl::sycl::runtime_error (
@@ -804,11 +796,13 @@ class accessor
804
796
Dimensions > 0 ),
805
797
buffer<DataT, Dimensions>>::type &bufferRef)
806
798
#ifdef __SYCL_DEVICE_ONLY__
807
- : impl ((dataT *)detail::getSyclObjImpl (bufferRef)->BufPtr ,
799
+ : impl (reinterpret_cast <_ValueType *>(
800
+ detail::getSyclObjImpl (bufferRef)->BufPtr ),
808
801
bufferRef.MemRange , bufferRef.MemRange ) {
809
802
#else
810
803
: impl (std::make_shared<_ImplT>(
811
- (dataT *)detail::getSyclObjImpl (bufferRef)->BufPtr ,
804
+ reinterpret_cast <_ValueType *>(
805
+ detail::getSyclObjImpl (bufferRef)->BufPtr ),
812
806
bufferRef.MemRange , bufferRef.MemRange )) {
813
807
#endif
814
808
auto BufImpl = detail::getSyclObjImpl (bufferRef);
@@ -848,13 +842,12 @@ class accessor
848
842
// Pass nullptr as a pointer to mem and use buffers from the ctor
849
843
// arguments to avoid the need in adding utility functions for
850
844
// dummy/default initialization of range fields.
851
- : impl (nullptr , bufferRef.MemRange , bufferRef.MemRange ,
852
- &commandGroupHandlerRef) {}
845
+ : impl (nullptr , bufferRef.MemRange , bufferRef.MemRange ) {}
853
846
#else
854
847
: impl (std::make_shared<_ImplT>(
855
- (dataT *) detail::getSyclObjImpl (bufferRef)-> BufPtr ,
856
- bufferRef. MemRange , bufferRef. MemRange ,
857
- &commandGroupHandlerRef )) {
848
+ reinterpret_cast <_ValueType *>(
849
+ detail::getSyclObjImpl ( bufferRef)-> BufPtr ) ,
850
+ bufferRef. MemRange , bufferRef. MemRange )) {
858
851
auto BufImpl = detail::getSyclObjImpl (bufferRef);
859
852
if (BufImpl->OpenCLInterop && !BufImpl->isValidAccessToMem (accessMode)) {
860
853
throw cl::sycl::runtime_error (
@@ -899,8 +892,9 @@ class accessor
899
892
: impl (nullptr , Range, bufferRef.MemRange , Offset) {}
900
893
#else // !__SYCL_DEVICE_ONLY__
901
894
: impl (std::make_shared<_ImplT>(
902
- (dataT *)detail::getSyclObjImpl (bufferRef)->BufPtr , Range,
903
- bufferRef.MemRange , Offset)) {
895
+ reinterpret_cast <_ValueType *>(
896
+ detail::getSyclObjImpl (bufferRef)->BufPtr ),
897
+ Range, bufferRef.MemRange , Offset)) {
904
898
auto BufImpl = detail::getSyclObjImpl (bufferRef);
905
899
if (AccessTarget == access ::target::host_buffer) {
906
900
simple_scheduler::Scheduler::getInstance ()
@@ -941,12 +935,12 @@ class accessor
941
935
// arguments to avoid the need in adding utility functions for
942
936
// dummy/default initialization of range<Dimensions> and
943
937
// id<Dimension> fields.
944
- : impl (nullptr , Range, bufferRef.MemRange ,
945
- &commandGroupHandlerRef, Offset) {}
938
+ : impl (nullptr , Range, bufferRef.MemRange , Offset) {}
946
939
#else // !__SYCL_DEVICE_ONLY__
947
940
: impl (std::make_shared<_ImplT>(
948
- (dataT *)detail::getSyclObjImpl (bufferRef)->BufPtr , Range,
949
- bufferRef.MemRange , &commandGroupHandlerRef, Offset)) {
941
+ reinterpret_cast <_ValueType *>(
942
+ detail::getSyclObjImpl (bufferRef)->BufPtr ),
943
+ Range, bufferRef.MemRange , Offset)) {
950
944
auto BufImpl = detail::getSyclObjImpl (bufferRef);
951
945
if (BufImpl->OpenCLInterop && !BufImpl->isValidAccessToMem (accessMode)) {
952
946
throw cl::sycl::runtime_error (
@@ -958,24 +952,27 @@ class accessor
958
952
}
959
953
#endif // !__SYCL_DEVICE_ONLY__
960
954
961
- // TODO:
962
955
// local accessor ctor #1
963
- // accessor(handler &);
956
+ // accessor(handler &);
964
957
// Available only when:
965
958
// AccessTarget == access::target::local && Dimensions == 0
966
- //
967
- // template <typename DataT = dataT, int Dimensions = dimensions,
968
- // access::mode AccessMode = accessMode,
969
- // access::target AccessTarget = accessTarget,
970
- // access::placeholder IsPlaceholder = isPlaceholder>
971
- // accessor(typename std::enable_if<(AccessTarget == access::target::local &&
972
- // Dimensions == 0), handler>::type &commandGroupHandlerRef);
973
-
959
+ template <typename DataT = dataT, int Dimensions = dimensions,
960
+ access ::mode AccessMode = accessMode,
961
+ access ::target AccessTarget = accessTarget,
962
+ access ::placeholder IsPlaceholder = isPlaceholder>
963
+ accessor (typename std::enable_if<
964
+ (AccessTarget == access ::target::local &&
965
+ Dimensions == 0 ), handler>::type &commandGroupHandlerRef)
966
+ #ifdef __SYCL_DEVICE_ONLY__
967
+ : impl (commandGroupHandlerRef) {}
968
+ #else
969
+ : impl (std::make_shared<_ImplT>(commandGroupHandlerRef)) {}
970
+ #endif
974
971
975
972
// local accessor ctor #2
976
- // accessor(range allocationSize, handler &);
973
+ // accessor(range allocationSize, handler &);
977
974
// Available only when:
978
- // AccessTarget == access::target::local && Dimensions = > 0
975
+ // AccessTarget == access::target::local && Dimensions > 0
979
976
template <typename DataT = dataT, int Dimensions = dimensions,
980
977
access ::mode AccessMode = accessMode,
981
978
access ::target AccessTarget = accessTarget,
@@ -985,10 +982,10 @@ class accessor
985
982
range<Dimensions>>::type allocationSize,
986
983
handler &commandGroupHandlerRef)
987
984
#ifdef __SYCL_DEVICE_ONLY__
988
- : impl (allocationSize, & commandGroupHandlerRef) {}
985
+ : impl (allocationSize, commandGroupHandlerRef) {}
989
986
#else
990
987
: impl (std::make_shared<_ImplT>(allocationSize,
991
- & commandGroupHandlerRef)) {}
988
+ commandGroupHandlerRef)) {}
992
989
#endif
993
990
994
991
accessor (const accessor &rhs) = default ;
0 commit comments