19
19
#include < sycl/detail/handler_proxy.hpp>
20
20
#include < sycl/detail/image_accessor_util.hpp>
21
21
#include < sycl/detail/image_ocl_types.hpp>
22
+ #include < sycl/device.hpp>
22
23
#include < sycl/exception.hpp>
23
24
#include < sycl/ext/oneapi/accessor_property_list.hpp>
24
25
#include < sycl/id.hpp>
25
26
#include < sycl/image.hpp>
26
27
#include < sycl/pointers.hpp>
27
28
#include < sycl/properties/accessor_properties.hpp>
29
+ #include < sycl/properties/buffer_properties.hpp>
28
30
#include < sycl/property_list.hpp>
29
31
#include < sycl/property_list_conversion.hpp>
30
32
#include < sycl/sampler.hpp>
@@ -248,20 +250,6 @@ template <> struct IsCxPropertyList<ext::oneapi::accessor_property_list<>> {
248
250
constexpr static bool value = false ;
249
251
};
250
252
251
- // The function extends or truncates number of dimensions of objects of id
252
- // or ranges classes. When extending the new values are filled with
253
- // DefaultValue, truncation just removes extra values.
254
- template <int NewDim, int DefaultValue, template <int > class T , int OldDim>
255
- static T<NewDim> convertToArrayOfN (T<OldDim> OldObj) {
256
- T<NewDim> NewObj = InitializedVal<NewDim, T>::template get<0 >();
257
- const int CopyDims = NewDim > OldDim ? OldDim : NewDim;
258
- for (int I = 0 ; I < CopyDims; ++I)
259
- NewObj[I] = OldObj[I];
260
- for (int I = CopyDims; I < NewDim; ++I)
261
- NewObj[I] = DefaultValue;
262
- return NewObj;
263
- }
264
-
265
253
__SYCL_EXPORT device getDeviceFromHandler (handler &CommandGroupHandlerRef);
266
254
267
255
template <typename DataT, int Dimensions, access::mode AccessMode,
@@ -510,15 +498,14 @@ class image_accessor
510
498
// host.
511
499
}
512
500
#else
513
- : AccessorBaseHost ({detail::getSyclObjImpl (ImageRef)->getRowPitch (),
514
- detail::getSyclObjImpl (ImageRef)->getSlicePitch (), 0 },
501
+ : AccessorBaseHost ({ImageRef.getRowPitch (), ImageRef.getSlicePitch (), 0 },
515
502
detail::convertToArrayOfN<3 , 1 >(ImageRef.get_range ()),
516
503
detail::convertToArrayOfN<3 , 1 >(ImageRef.get_range ()),
517
504
AccessMode, detail::getSyclObjImpl (ImageRef).get (),
518
505
Dimensions, ImageElementSize),
519
506
MImageCount (ImageRef.size ()),
520
- MImgChannelOrder (detail::getSyclObjImpl ( ImageRef)-> getChannelOrder ()),
521
- MImgChannelType (detail::getSyclObjImpl ( ImageRef)-> getChannelType ()) {
507
+ MImgChannelOrder (ImageRef. getChannelOrder ()),
508
+ MImgChannelType (ImageRef. getChannelType ()) {
522
509
addHostAccessorAndWait (AccessorBaseHost::impl.get ());
523
510
}
524
511
#endif
@@ -541,15 +528,14 @@ class image_accessor
541
528
// host.
542
529
}
543
530
#else
544
- : AccessorBaseHost ({detail::getSyclObjImpl (ImageRef)->getRowPitch (),
545
- detail::getSyclObjImpl (ImageRef)->getSlicePitch (), 0 },
531
+ : AccessorBaseHost ({ImageRef.getRowPitch (), ImageRef.getSlicePitch (), 0 },
546
532
detail::convertToArrayOfN<3 , 1 >(ImageRef.get_range ()),
547
533
detail::convertToArrayOfN<3 , 1 >(ImageRef.get_range ()),
548
534
AccessMode, detail::getSyclObjImpl (ImageRef).get (),
549
535
Dimensions, ImageElementSize),
550
536
MImageCount (ImageRef.size ()),
551
- MImgChannelOrder (detail::getSyclObjImpl ( ImageRef)-> getChannelOrder ()),
552
- MImgChannelType (detail::getSyclObjImpl ( ImageRef)-> getChannelType ()) {
537
+ MImgChannelOrder (ImageRef. getChannelOrder ()),
538
+ MImgChannelType (ImageRef. getChannelType ()) {
553
539
checkDeviceFeatureSupported<info::device::image_support>(
554
540
getDeviceFromHandler (CommandGroupHandlerRef));
555
541
}
@@ -1197,7 +1183,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1197
1183
const property_list &PropertyList = {},
1198
1184
const detail::code_location CodeLoc = detail::code_location::current ())
1199
1185
: accessor (BufferRef, PropertyList, CodeLoc) {
1200
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1186
+ adjustAccPropsInBuf (BufferRef);
1201
1187
}
1202
1188
1203
1189
template <typename T = DataT, int Dims = Dimensions, typename AllocatorT,
@@ -1212,7 +1198,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1212
1198
{},
1213
1199
const detail::code_location CodeLoc = detail::code_location::current ())
1214
1200
: accessor (BufferRef, PropertyList, CodeLoc) {
1215
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1201
+ adjustAccPropsInBuf (BufferRef);
1216
1202
}
1217
1203
#endif
1218
1204
@@ -1291,7 +1277,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1291
1277
TagT, const property_list &PropertyList = {},
1292
1278
const detail::code_location CodeLoc = detail::code_location::current ())
1293
1279
: accessor (BufferRef, CommandGroupHandler, PropertyList, CodeLoc) {
1294
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1280
+ adjustAccPropsInBuf (BufferRef);
1295
1281
}
1296
1282
1297
1283
template <typename T = DataT, int Dims = Dimensions, typename AllocatorT,
@@ -1307,7 +1293,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1307
1293
{},
1308
1294
const detail::code_location CodeLoc = detail::code_location::current ())
1309
1295
: accessor (BufferRef, CommandGroupHandler, PropertyList, CodeLoc) {
1310
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1296
+ adjustAccPropsInBuf (BufferRef);
1311
1297
}
1312
1298
1313
1299
#endif
@@ -1351,7 +1337,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1351
1337
TagT, const property_list &PropertyList = {},
1352
1338
const detail::code_location CodeLoc = detail::code_location::current ())
1353
1339
: accessor (BufferRef, AccessRange, {}, PropertyList, CodeLoc) {
1354
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1340
+ adjustAccPropsInBuf (BufferRef);
1355
1341
}
1356
1342
1357
1343
template <typename T = DataT, int Dims = Dimensions, typename AllocatorT,
@@ -1367,7 +1353,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1367
1353
{},
1368
1354
const detail::code_location CodeLoc = detail::code_location::current ())
1369
1355
: accessor (BufferRef, AccessRange, {}, PropertyList, CodeLoc) {
1370
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1356
+ adjustAccPropsInBuf (BufferRef);
1371
1357
}
1372
1358
#endif
1373
1359
@@ -1413,7 +1399,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1413
1399
const detail::code_location CodeLoc = detail::code_location::current ())
1414
1400
: accessor (BufferRef, CommandGroupHandler, AccessRange, {}, PropertyList,
1415
1401
CodeLoc) {
1416
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1402
+ adjustAccPropsInBuf (BufferRef);
1417
1403
}
1418
1404
1419
1405
template <typename T = DataT, int Dims = Dimensions, typename AllocatorT,
@@ -1430,7 +1416,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1430
1416
const detail::code_location CodeLoc = detail::code_location::current ())
1431
1417
: accessor (BufferRef, CommandGroupHandler, AccessRange, {}, PropertyList,
1432
1418
CodeLoc) {
1433
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1419
+ adjustAccPropsInBuf (BufferRef);
1434
1420
}
1435
1421
#endif
1436
1422
@@ -1526,7 +1512,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1526
1512
id<Dimensions> AccessOffset, TagT, const property_list &PropertyList = {},
1527
1513
const detail::code_location CodeLoc = detail::code_location::current ())
1528
1514
: accessor (BufferRef, AccessRange, AccessOffset, PropertyList, CodeLoc) {
1529
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1515
+ adjustAccPropsInBuf (BufferRef);
1530
1516
}
1531
1517
1532
1518
template <typename T = DataT, int Dims = Dimensions, typename AllocatorT,
@@ -1542,7 +1528,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1542
1528
{},
1543
1529
const detail::code_location CodeLoc = detail::code_location::current ())
1544
1530
: accessor (BufferRef, AccessRange, AccessOffset, PropertyList, CodeLoc) {
1545
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1531
+ adjustAccPropsInBuf (BufferRef);
1546
1532
}
1547
1533
#endif
1548
1534
@@ -1639,7 +1625,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1639
1625
const detail::code_location CodeLoc = detail::code_location::current ())
1640
1626
: accessor (BufferRef, CommandGroupHandler, AccessRange, AccessOffset,
1641
1627
PropertyList, CodeLoc) {
1642
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1628
+ adjustAccPropsInBuf (BufferRef);
1643
1629
}
1644
1630
1645
1631
template <typename T = DataT, int Dims = Dimensions, typename AllocatorT,
@@ -1656,7 +1642,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1656
1642
const detail::code_location CodeLoc = detail::code_location::current ())
1657
1643
: accessor (BufferRef, CommandGroupHandler, AccessRange, AccessOffset,
1658
1644
PropertyList, CodeLoc) {
1659
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1645
+ adjustAccPropsInBuf (BufferRef);
1660
1646
}
1661
1647
#endif
1662
1648
@@ -1829,27 +1815,23 @@ class __SYCL_SPECIAL_CLASS accessor :
1829
1815
}
1830
1816
1831
1817
#if __cplusplus >= 201703L
1832
- template <typename ... PropTypes>
1833
- void adjustAccPropsInBuf (detail::SYCLMemObjI *SYCLMemObject ) {
1818
+ template <typename BufT, typename ... PropTypes>
1819
+ void adjustAccPropsInBuf (BufT &Buffer ) {
1834
1820
if constexpr (PropertyListT::template has_property<
1835
1821
sycl::ext::intel::property::buffer_location>()) {
1836
1822
auto location = (PropertyListT::template get_property<
1837
1823
sycl::ext::intel::property::buffer_location>())
1838
1824
.get_location ();
1839
1825
property_list PropList{
1840
1826
sycl::property::buffer::detail::buffer_location (location)};
1841
- detail::SYCLMemObjT *SYCLMemObjectT =
1842
- dynamic_cast <detail::SYCLMemObjT *>(SYCLMemObject);
1843
- SYCLMemObjectT->addOrReplaceAccessorProperties (PropList);
1827
+ Buffer.addOrReplaceAccessorProperties (PropList);
1844
1828
} else {
1845
- deleteAccPropsFromBuf (SYCLMemObject );
1829
+ deleteAccPropsFromBuf (Buffer );
1846
1830
}
1847
1831
}
1848
1832
1849
- void deleteAccPropsFromBuf (detail::SYCLMemObjI *SYCLMemObject) {
1850
- detail::SYCLMemObjT *SYCLMemObjectT =
1851
- dynamic_cast <detail::SYCLMemObjT *>(SYCLMemObject);
1852
- SYCLMemObjectT->deleteAccessorProperty (
1833
+ template <typename BufT> void deleteAccPropsFromBuf (BufT &Buffer) {
1834
+ Buffer.deleteAccProps (
1853
1835
sycl::detail::PropWithDataKind::AccPropBufferLocation);
1854
1836
}
1855
1837
#endif
@@ -2236,8 +2218,7 @@ class __SYCL_SPECIAL_CLASS accessor<DataT, Dimensions, AccessMode,
2236
2218
handler &CommandGroupHandler)
2237
2219
: detail::image_accessor<DataT, Dimensions, AccessMode,
2238
2220
access::target::image, IsPlaceholder>(
2239
- Image, CommandGroupHandler,
2240
- (detail::getSyclObjImpl(Image))->getElementSize ()) {
2221
+ Image, CommandGroupHandler, Image.getElementSize()) {
2241
2222
#ifndef __SYCL_DEVICE_ONLY__
2242
2223
detail::associateWithHandler (CommandGroupHandler, this ,
2243
2224
access::target::image);
@@ -2249,8 +2230,7 @@ class __SYCL_SPECIAL_CLASS accessor<DataT, Dimensions, AccessMode,
2249
2230
handler &CommandGroupHandler, const property_list &propList)
2250
2231
: detail::image_accessor<DataT, Dimensions, AccessMode,
2251
2232
access::target::image, IsPlaceholder>(
2252
- Image, CommandGroupHandler,
2253
- (detail::getSyclObjImpl(Image))->getElementSize()) {
2233
+ Image, CommandGroupHandler, Image.getElementSize()) {
2254
2234
(void )propList;
2255
2235
#ifndef __SYCL_DEVICE_ONLY__
2256
2236
detail::associateWithHandler (CommandGroupHandler, this ,
@@ -2294,14 +2274,14 @@ class accessor<DataT, Dimensions, AccessMode, access::target::host_image,
2294
2274
accessor (sycl::image<Dimensions, AllocatorT> &Image)
2295
2275
: detail::image_accessor<DataT, Dimensions, AccessMode,
2296
2276
access::target::host_image, IsPlaceholder>(
2297
- Image, (detail::getSyclObjImpl( Image))-> getElementSize ()) {}
2277
+ Image, Image. getElementSize()) {}
2298
2278
2299
2279
template <typename AllocatorT>
2300
2280
accessor (sycl::image<Dimensions, AllocatorT> &Image,
2301
2281
const property_list &propList)
2302
2282
: detail::image_accessor<DataT, Dimensions, AccessMode,
2303
2283
access::target::host_image, IsPlaceholder>(
2304
- Image, (detail::getSyclObjImpl( Image))-> getElementSize()) {
2284
+ Image, Image. getElementSize()) {
2305
2285
(void )propList;
2306
2286
}
2307
2287
};
@@ -2343,8 +2323,7 @@ class __SYCL_SPECIAL_CLASS accessor<DataT, Dimensions, AccessMode,
2343
2323
handler &CommandGroupHandler)
2344
2324
: detail::image_accessor<DataT, Dimensions + 1 , AccessMode,
2345
2325
access::target::image, IsPlaceholder>(
2346
- Image, CommandGroupHandler,
2347
- (detail::getSyclObjImpl(Image))->getElementSize ()) {
2326
+ Image, CommandGroupHandler, Image.getElementSize()) {
2348
2327
#ifndef __SYCL_DEVICE_ONLY__
2349
2328
detail::associateWithHandler (CommandGroupHandler, this ,
2350
2329
access::target::image_array);
@@ -2356,8 +2335,7 @@ class __SYCL_SPECIAL_CLASS accessor<DataT, Dimensions, AccessMode,
2356
2335
handler &CommandGroupHandler, const property_list &propList)
2357
2336
: detail::image_accessor<DataT, Dimensions + 1 , AccessMode,
2358
2337
access::target::image, IsPlaceholder>(
2359
- Image, CommandGroupHandler,
2360
- (detail::getSyclObjImpl(Image))->getElementSize()) {
2338
+ Image, CommandGroupHandler, Image.getElementSize()) {
2361
2339
(void )propList;
2362
2340
#ifndef __SYCL_DEVICE_ONLY__
2363
2341
detail::associateWithHandler (CommandGroupHandler, this ,
0 commit comments