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>
@@ -264,20 +266,6 @@ template <> struct IsCxPropertyList<ext::oneapi::accessor_property_list<>> {
264
266
constexpr static bool value = false ;
265
267
};
266
268
267
- // The function extends or truncates number of dimensions of objects of id
268
- // or ranges classes. When extending the new values are filled with
269
- // DefaultValue, truncation just removes extra values.
270
- template <int NewDim, int DefaultValue, template <int > class T , int OldDim>
271
- static T<NewDim> convertToArrayOfN (T<OldDim> OldObj) {
272
- T<NewDim> NewObj = InitializedVal<NewDim, T>::template get<0 >();
273
- const int CopyDims = NewDim > OldDim ? OldDim : NewDim;
274
- for (int I = 0 ; I < CopyDims; ++I)
275
- NewObj[I] = OldObj[I];
276
- for (int I = CopyDims; I < NewDim; ++I)
277
- NewObj[I] = DefaultValue;
278
- return NewObj;
279
- }
280
-
281
269
__SYCL_EXPORT device getDeviceFromHandler (handler &CommandGroupHandlerRef);
282
270
283
271
template <typename DataT, int Dimensions, access::mode AccessMode,
@@ -526,15 +514,14 @@ class image_accessor
526
514
// host.
527
515
}
528
516
#else
529
- : AccessorBaseHost ({detail::getSyclObjImpl (ImageRef)->getRowPitch (),
530
- detail::getSyclObjImpl (ImageRef)->getSlicePitch (), 0 },
517
+ : AccessorBaseHost ({ImageRef.getRowPitch (), ImageRef.getSlicePitch (), 0 },
531
518
detail::convertToArrayOfN<3 , 1 >(ImageRef.get_range ()),
532
519
detail::convertToArrayOfN<3 , 1 >(ImageRef.get_range ()),
533
520
AccessMode, detail::getSyclObjImpl (ImageRef).get (),
534
521
Dimensions, ImageElementSize),
535
522
MImageCount (ImageRef.size ()),
536
- MImgChannelOrder (detail::getSyclObjImpl ( ImageRef)-> getChannelOrder ()),
537
- MImgChannelType (detail::getSyclObjImpl ( ImageRef)-> getChannelType ()) {
523
+ MImgChannelOrder (ImageRef. getChannelOrder ()),
524
+ MImgChannelType (ImageRef. getChannelType ()) {
538
525
addHostAccessorAndWait (AccessorBaseHost::impl.get ());
539
526
}
540
527
#endif
@@ -557,15 +544,14 @@ class image_accessor
557
544
// host.
558
545
}
559
546
#else
560
- : AccessorBaseHost ({detail::getSyclObjImpl (ImageRef)->getRowPitch (),
561
- detail::getSyclObjImpl (ImageRef)->getSlicePitch (), 0 },
547
+ : AccessorBaseHost ({ImageRef.getRowPitch (), ImageRef.getSlicePitch (), 0 },
562
548
detail::convertToArrayOfN<3 , 1 >(ImageRef.get_range ()),
563
549
detail::convertToArrayOfN<3 , 1 >(ImageRef.get_range ()),
564
550
AccessMode, detail::getSyclObjImpl (ImageRef).get (),
565
551
Dimensions, ImageElementSize),
566
552
MImageCount (ImageRef.size ()),
567
- MImgChannelOrder (detail::getSyclObjImpl ( ImageRef)-> getChannelOrder ()),
568
- MImgChannelType (detail::getSyclObjImpl ( ImageRef)-> getChannelType ()) {
553
+ MImgChannelOrder (ImageRef. getChannelOrder ()),
554
+ MImgChannelType (ImageRef. getChannelType ()) {
569
555
checkDeviceFeatureSupported<info::device::image_support>(
570
556
getDeviceFromHandler (CommandGroupHandlerRef));
571
557
}
@@ -1203,7 +1189,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1203
1189
const property_list &PropertyList = {},
1204
1190
const detail::code_location CodeLoc = detail::code_location::current ())
1205
1191
: accessor (BufferRef, PropertyList, CodeLoc) {
1206
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1192
+ adjustAccPropsInBuf (BufferRef);
1207
1193
}
1208
1194
1209
1195
template <typename T = DataT, int Dims = Dimensions, typename AllocatorT,
@@ -1218,7 +1204,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1218
1204
{},
1219
1205
const detail::code_location CodeLoc = detail::code_location::current ())
1220
1206
: accessor (BufferRef, PropertyList, CodeLoc) {
1221
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1207
+ adjustAccPropsInBuf (BufferRef);
1222
1208
}
1223
1209
#endif
1224
1210
@@ -1297,7 +1283,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1297
1283
TagT, const property_list &PropertyList = {},
1298
1284
const detail::code_location CodeLoc = detail::code_location::current ())
1299
1285
: accessor (BufferRef, CommandGroupHandler, PropertyList, CodeLoc) {
1300
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1286
+ adjustAccPropsInBuf (BufferRef);
1301
1287
}
1302
1288
1303
1289
template <typename T = DataT, int Dims = Dimensions, typename AllocatorT,
@@ -1313,7 +1299,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1313
1299
{},
1314
1300
const detail::code_location CodeLoc = detail::code_location::current ())
1315
1301
: accessor (BufferRef, CommandGroupHandler, PropertyList, CodeLoc) {
1316
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1302
+ adjustAccPropsInBuf (BufferRef);
1317
1303
}
1318
1304
1319
1305
#endif
@@ -1357,7 +1343,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1357
1343
TagT, const property_list &PropertyList = {},
1358
1344
const detail::code_location CodeLoc = detail::code_location::current ())
1359
1345
: accessor (BufferRef, AccessRange, {}, PropertyList, CodeLoc) {
1360
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1346
+ adjustAccPropsInBuf (BufferRef);
1361
1347
}
1362
1348
1363
1349
template <typename T = DataT, int Dims = Dimensions, typename AllocatorT,
@@ -1373,7 +1359,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1373
1359
{},
1374
1360
const detail::code_location CodeLoc = detail::code_location::current ())
1375
1361
: accessor (BufferRef, AccessRange, {}, PropertyList, CodeLoc) {
1376
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1362
+ adjustAccPropsInBuf (BufferRef);
1377
1363
}
1378
1364
#endif
1379
1365
@@ -1419,7 +1405,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1419
1405
const detail::code_location CodeLoc = detail::code_location::current ())
1420
1406
: accessor (BufferRef, CommandGroupHandler, AccessRange, {}, PropertyList,
1421
1407
CodeLoc) {
1422
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1408
+ adjustAccPropsInBuf (BufferRef);
1423
1409
}
1424
1410
1425
1411
template <typename T = DataT, int Dims = Dimensions, typename AllocatorT,
@@ -1436,7 +1422,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1436
1422
const detail::code_location CodeLoc = detail::code_location::current ())
1437
1423
: accessor (BufferRef, CommandGroupHandler, AccessRange, {}, PropertyList,
1438
1424
CodeLoc) {
1439
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1425
+ adjustAccPropsInBuf (BufferRef);
1440
1426
}
1441
1427
#endif
1442
1428
@@ -1532,7 +1518,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1532
1518
id<Dimensions> AccessOffset, TagT, const property_list &PropertyList = {},
1533
1519
const detail::code_location CodeLoc = detail::code_location::current ())
1534
1520
: accessor (BufferRef, AccessRange, AccessOffset, PropertyList, CodeLoc) {
1535
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1521
+ adjustAccPropsInBuf (BufferRef);
1536
1522
}
1537
1523
1538
1524
template <typename T = DataT, int Dims = Dimensions, typename AllocatorT,
@@ -1548,7 +1534,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1548
1534
{},
1549
1535
const detail::code_location CodeLoc = detail::code_location::current ())
1550
1536
: accessor (BufferRef, AccessRange, AccessOffset, PropertyList, CodeLoc) {
1551
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1537
+ adjustAccPropsInBuf (BufferRef);
1552
1538
}
1553
1539
#endif
1554
1540
@@ -1645,7 +1631,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1645
1631
const detail::code_location CodeLoc = detail::code_location::current ())
1646
1632
: accessor (BufferRef, CommandGroupHandler, AccessRange, AccessOffset,
1647
1633
PropertyList, CodeLoc) {
1648
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1634
+ adjustAccPropsInBuf (BufferRef);
1649
1635
}
1650
1636
1651
1637
template <typename T = DataT, int Dims = Dimensions, typename AllocatorT,
@@ -1662,7 +1648,7 @@ class __SYCL_SPECIAL_CLASS accessor :
1662
1648
const detail::code_location CodeLoc = detail::code_location::current ())
1663
1649
: accessor (BufferRef, CommandGroupHandler, AccessRange, AccessOffset,
1664
1650
PropertyList, CodeLoc) {
1665
- adjustAccPropsInBuf (detail::getSyclObjImpl ( BufferRef). get () );
1651
+ adjustAccPropsInBuf (BufferRef);
1666
1652
}
1667
1653
#endif
1668
1654
@@ -1854,27 +1840,23 @@ class __SYCL_SPECIAL_CLASS accessor :
1854
1840
}
1855
1841
1856
1842
#if __cplusplus >= 201703L
1857
- template <typename ... PropTypes>
1858
- void adjustAccPropsInBuf (detail::SYCLMemObjI *SYCLMemObject ) {
1843
+ template <typename BufT, typename ... PropTypes>
1844
+ void adjustAccPropsInBuf (BufT &Buffer ) {
1859
1845
if constexpr (PropertyListT::template has_property<
1860
1846
sycl::ext::intel::property::buffer_location>()) {
1861
1847
auto location = (PropertyListT::template get_property<
1862
1848
sycl::ext::intel::property::buffer_location>())
1863
1849
.get_location ();
1864
1850
property_list PropList{
1865
1851
sycl::property::buffer::detail::buffer_location (location)};
1866
- detail::SYCLMemObjT *SYCLMemObjectT =
1867
- dynamic_cast <detail::SYCLMemObjT *>(SYCLMemObject);
1868
- SYCLMemObjectT->addOrReplaceAccessorProperties (PropList);
1852
+ Buffer.addOrReplaceAccessorProperties (PropList);
1869
1853
} else {
1870
- deleteAccPropsFromBuf (SYCLMemObject );
1854
+ deleteAccPropsFromBuf (Buffer );
1871
1855
}
1872
1856
}
1873
1857
1874
- void deleteAccPropsFromBuf (detail::SYCLMemObjI *SYCLMemObject) {
1875
- detail::SYCLMemObjT *SYCLMemObjectT =
1876
- dynamic_cast <detail::SYCLMemObjT *>(SYCLMemObject);
1877
- SYCLMemObjectT->deleteAccessorProperty (
1858
+ template <typename BufT> void deleteAccPropsFromBuf (BufT &Buffer) {
1859
+ Buffer.deleteAccProps (
1878
1860
sycl::detail::PropWithDataKind::AccPropBufferLocation);
1879
1861
}
1880
1862
#endif
@@ -2261,8 +2243,7 @@ class __SYCL_SPECIAL_CLASS accessor<DataT, Dimensions, AccessMode,
2261
2243
handler &CommandGroupHandler)
2262
2244
: detail::image_accessor<DataT, Dimensions, AccessMode,
2263
2245
access::target::image, IsPlaceholder>(
2264
- Image, CommandGroupHandler,
2265
- (detail::getSyclObjImpl(Image))->getElementSize ()) {
2246
+ Image, CommandGroupHandler, Image.getElementSize()) {
2266
2247
#ifndef __SYCL_DEVICE_ONLY__
2267
2248
detail::associateWithHandler (CommandGroupHandler, this ,
2268
2249
access::target::image);
@@ -2274,8 +2255,7 @@ class __SYCL_SPECIAL_CLASS accessor<DataT, Dimensions, AccessMode,
2274
2255
handler &CommandGroupHandler, const property_list &propList)
2275
2256
: detail::image_accessor<DataT, Dimensions, AccessMode,
2276
2257
access::target::image, IsPlaceholder>(
2277
- Image, CommandGroupHandler,
2278
- (detail::getSyclObjImpl(Image))->getElementSize()) {
2258
+ Image, CommandGroupHandler, Image.getElementSize()) {
2279
2259
(void )propList;
2280
2260
#ifndef __SYCL_DEVICE_ONLY__
2281
2261
detail::associateWithHandler (CommandGroupHandler, this ,
@@ -2319,14 +2299,14 @@ class accessor<DataT, Dimensions, AccessMode, access::target::host_image,
2319
2299
accessor (sycl::image<Dimensions, AllocatorT> &Image)
2320
2300
: detail::image_accessor<DataT, Dimensions, AccessMode,
2321
2301
access::target::host_image, IsPlaceholder>(
2322
- Image, (detail::getSyclObjImpl( Image))-> getElementSize ()) {}
2302
+ Image, Image. getElementSize()) {}
2323
2303
2324
2304
template <typename AllocatorT>
2325
2305
accessor (sycl::image<Dimensions, AllocatorT> &Image,
2326
2306
const property_list &propList)
2327
2307
: detail::image_accessor<DataT, Dimensions, AccessMode,
2328
2308
access::target::host_image, IsPlaceholder>(
2329
- Image, (detail::getSyclObjImpl( Image))-> getElementSize()) {
2309
+ Image, Image. getElementSize()) {
2330
2310
(void )propList;
2331
2311
}
2332
2312
};
@@ -2368,8 +2348,7 @@ class __SYCL_SPECIAL_CLASS accessor<DataT, Dimensions, AccessMode,
2368
2348
handler &CommandGroupHandler)
2369
2349
: detail::image_accessor<DataT, Dimensions + 1 , AccessMode,
2370
2350
access::target::image, IsPlaceholder>(
2371
- Image, CommandGroupHandler,
2372
- (detail::getSyclObjImpl(Image))->getElementSize ()) {
2351
+ Image, CommandGroupHandler, Image.getElementSize()) {
2373
2352
#ifndef __SYCL_DEVICE_ONLY__
2374
2353
detail::associateWithHandler (CommandGroupHandler, this ,
2375
2354
access::target::image_array);
@@ -2381,8 +2360,7 @@ class __SYCL_SPECIAL_CLASS accessor<DataT, Dimensions, AccessMode,
2381
2360
handler &CommandGroupHandler, const property_list &propList)
2382
2361
: detail::image_accessor<DataT, Dimensions + 1 , AccessMode,
2383
2362
access::target::image, IsPlaceholder>(
2384
- Image, CommandGroupHandler,
2385
- (detail::getSyclObjImpl(Image))->getElementSize()) {
2363
+ Image, CommandGroupHandler, Image.getElementSize()) {
2386
2364
(void )propList;
2387
2365
#ifndef __SYCL_DEVICE_ONLY__
2388
2366
detail::associateWithHandler (CommandGroupHandler, this ,
0 commit comments