Skip to content

Commit 44993e9

Browse files
authored
Update enable_if on accessor constructor to allow in specialization with target::host_task (#8540)
* Update enable_if on accessor constructor to allow in specialization with target::host_task. * Add test.
1 parent 1867609 commit 44993e9

File tree

2 files changed

+42
-24
lines changed

2 files changed

+42
-24
lines changed

sycl/include/sycl/accessor.hpp

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ class accessor_common {
276276
constexpr static access::address_space AS = TargetToAS<AccessTarget>::AS;
277277

278278
constexpr static bool IsHostBuf = AccessTarget == access::target::host_buffer;
279+
constexpr static bool IsHostTask = AccessTarget == access::target::host_task;
279280
// SYCL2020 4.7.6.9.4.3
280281
// IsPlaceHolder template parameter has no bearing on whether the accessor
281282
// instance is a placeholder. This is determined solely by the constructor.
@@ -1021,6 +1022,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
10211022
static constexpr bool IsHostBuf = AccessorCommonT::IsHostBuf;
10221023
static constexpr bool IsPlaceH = AccessorCommonT::IsPlaceH;
10231024
static constexpr bool IsConst = AccessorCommonT::IsConst;
1025+
static constexpr bool IsHostTask = AccessorCommonT::IsHostTask;
10241026
template <int Dims>
10251027
using AccessorSubscript =
10261028
typename AccessorCommonT::template AccessorSubscript<Dims>;
@@ -1292,7 +1294,8 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
12921294
typename detail::enable_if_t<
12931295
detail::IsRunTimePropertyListT<PropertyListT>::value &&
12941296
std::is_same<T, DataT>::value && Dims == 0 &&
1295-
(IsHostBuf || (IsGlobalBuf || IsConstantBuf))> * = nullptr>
1297+
(IsHostBuf || IsHostTask || (IsGlobalBuf || IsConstantBuf))> * =
1298+
nullptr>
12961299
accessor(
12971300
buffer<T, 1, AllocatorT> &BufferRef,
12981301
const property_list &PropertyList = {},
@@ -1324,7 +1327,8 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
13241327
typename detail::enable_if_t<
13251328
detail::IsCxPropertyList<PropertyListT>::value &&
13261329
std::is_same<T, DataT>::value && Dims == 0 &&
1327-
(IsHostBuf || (IsGlobalBuf || IsConstantBuf))> * = nullptr>
1330+
(IsHostBuf || IsHostTask || (IsGlobalBuf || IsConstantBuf))> * =
1331+
nullptr>
13281332
accessor(
13291333
buffer<T, 1, AllocatorT> &BufferRef,
13301334
const ext::oneapi::accessor_property_list<PropTypes...> &PropertyList =
@@ -1356,7 +1360,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
13561360
typename = typename detail::enable_if_t<
13571361
detail::IsRunTimePropertyListT<PropertyListT>::value &&
13581362
std::is_same<T, DataT>::value && (Dims == 0) &&
1359-
(IsGlobalBuf || IsConstantBuf || IsHostBuf)>>
1363+
(IsGlobalBuf || IsHostBuf || IsConstantBuf || IsHostTask)>>
13601364
accessor(
13611365
buffer<T, 1, AllocatorT> &BufferRef, handler &CommandGroupHandler,
13621366
const property_list &PropertyList = {},
@@ -1388,7 +1392,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
13881392
typename = typename detail::enable_if_t<
13891393
detail::IsCxPropertyList<PropertyListT>::value &&
13901394
std::is_same<T, DataT>::value && (Dims == 0) &&
1391-
(IsGlobalBuf || IsConstantBuf || IsHostBuf)>>
1395+
(IsGlobalBuf || IsConstantBuf || IsHostBuf || IsHostTask)>>
13921396
accessor(
13931397
buffer<T, 1, AllocatorT> &BufferRef, handler &CommandGroupHandler,
13941398
const ext::oneapi::accessor_property_list<PropTypes...> &PropertyList =
@@ -1420,7 +1424,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
14201424
typename = detail::enable_if_t<
14211425
detail::IsRunTimePropertyListT<PropertyListT>::value &&
14221426
IsSameAsBuffer<T, Dims>::value &&
1423-
(IsHostBuf || (IsGlobalBuf || IsConstantBuf))>>
1427+
(IsHostBuf || IsHostTask || (IsGlobalBuf || IsConstantBuf))>>
14241428
accessor(
14251429
buffer<T, Dims, AllocatorT> &BufferRef,
14261430
const property_list &PropertyList = {},
@@ -1454,7 +1458,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
14541458
typename = detail::enable_if_t<
14551459
detail::IsCxPropertyList<PropertyListT>::value &&
14561460
IsSameAsBuffer<T, Dims>::value &&
1457-
(IsHostBuf || (IsGlobalBuf || IsConstantBuf))>>
1461+
(IsHostBuf || IsHostTask || (IsGlobalBuf || IsConstantBuf))>>
14581462
accessor(
14591463
buffer<T, Dims, AllocatorT> &BufferRef,
14601464
const ext::oneapi::accessor_property_list<PropTypes...> &PropertyList =
@@ -1489,7 +1493,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
14891493
typename = detail::enable_if_t<
14901494
detail::IsRunTimePropertyListT<PropertyListT>::value &&
14911495
IsSameAsBuffer<T, Dims>::value && IsValidTag<TagT>::value &&
1492-
(IsGlobalBuf || IsConstantBuf || IsHostBuf)>>
1496+
(IsGlobalBuf || IsConstantBuf || IsHostBuf || IsHostTask)>>
14931497
accessor(
14941498
buffer<T, Dims, AllocatorT> &BufferRef, TagT,
14951499
const property_list &PropertyList = {},
@@ -1503,7 +1507,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
15031507
typename = detail::enable_if_t<
15041508
detail::IsCxPropertyList<PropertyListT>::value &&
15051509
IsSameAsBuffer<T, Dims>::value && IsValidTag<TagT>::value &&
1506-
(IsGlobalBuf || IsConstantBuf || IsHostBuf)>>
1510+
(IsGlobalBuf || IsConstantBuf || IsHostBuf || IsHostTask)>>
15071511
accessor(
15081512
buffer<T, Dims, AllocatorT> &BufferRef, TagT,
15091513
const ext::oneapi::accessor_property_list<PropTypes...> &PropertyList =
@@ -1517,7 +1521,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
15171521
typename = detail::enable_if_t<
15181522
detail::IsRunTimePropertyListT<PropertyListT>::value &&
15191523
IsSameAsBuffer<T, Dims>::value &&
1520-
(IsGlobalBuf || IsConstantBuf || IsHostBuf)>>
1524+
(IsGlobalBuf || IsConstantBuf || IsHostBuf || IsHostTask)>>
15211525
accessor(
15221526
buffer<T, Dims, AllocatorT> &BufferRef, handler &CommandGroupHandler,
15231527
const property_list &PropertyList = {},
@@ -1550,7 +1554,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
15501554
typename = detail::enable_if_t<
15511555
detail::IsCxPropertyList<PropertyListT>::value &&
15521556
IsSameAsBuffer<T, Dims>::value &&
1553-
(IsGlobalBuf || IsConstantBuf || IsHostBuf)>>
1557+
(IsGlobalBuf || IsConstantBuf || IsHostBuf || IsHostTask)>>
15541558
accessor(
15551559
buffer<T, Dims, AllocatorT> &BufferRef, handler &CommandGroupHandler,
15561560
const ext::oneapi::accessor_property_list<PropTypes...> &PropertyList =
@@ -1584,7 +1588,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
15841588
typename = detail::enable_if_t<
15851589
detail::IsRunTimePropertyListT<PropertyListT>::value &&
15861590
IsSameAsBuffer<T, Dims>::value && IsValidTag<TagT>::value &&
1587-
(IsGlobalBuf || IsConstantBuf || IsHostBuf)>>
1591+
(IsGlobalBuf || IsConstantBuf || IsHostBuf || IsHostTask)>>
15881592
accessor(
15891593
buffer<T, Dims, AllocatorT> &BufferRef, handler &CommandGroupHandler,
15901594
TagT, const property_list &PropertyList = {},
@@ -1598,7 +1602,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
15981602
typename = detail::enable_if_t<
15991603
detail::IsCxPropertyList<PropertyListT>::value &&
16001604
IsSameAsBuffer<T, Dims>::value && IsValidTag<TagT>::value &&
1601-
(IsGlobalBuf || IsConstantBuf || IsHostBuf)>>
1605+
(IsGlobalBuf || IsConstantBuf || IsHostBuf || IsHostTask)>>
16021606
accessor(
16031607
buffer<T, Dims, AllocatorT> &BufferRef, handler &CommandGroupHandler,
16041608
TagT,
@@ -1613,7 +1617,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
16131617
typename = detail::enable_if_t<
16141618
detail::IsRunTimePropertyListT<PropertyListT>::value &&
16151619
IsSameAsBuffer<T, Dims>::value &&
1616-
(IsHostBuf || (IsGlobalBuf || IsConstantBuf))>>
1620+
(IsHostBuf || IsHostTask || (IsGlobalBuf || IsConstantBuf))>>
16171621
accessor(
16181622
buffer<T, Dims, AllocatorT> &BufferRef, range<Dimensions> AccessRange,
16191623
const property_list &PropertyList = {},
@@ -1625,7 +1629,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
16251629
typename = detail::enable_if_t<
16261630
detail::IsCxPropertyList<PropertyListT>::value &&
16271631
IsSameAsBuffer<T, Dims>::value &&
1628-
(IsHostBuf || (IsGlobalBuf || IsConstantBuf))>>
1632+
(IsHostBuf || IsHostTask || (IsGlobalBuf || IsConstantBuf))>>
16291633
accessor(
16301634
buffer<T, Dims, AllocatorT> &BufferRef, range<Dimensions> AccessRange,
16311635
const ext::oneapi::accessor_property_list<PropTypes...> &PropertyList =
@@ -1667,7 +1671,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
16671671
typename = detail::enable_if_t<
16681672
detail::IsRunTimePropertyListT<PropertyListT>::value &&
16691673
IsSameAsBuffer<T, Dims>::value &&
1670-
(IsGlobalBuf || IsConstantBuf || IsHostBuf)>>
1674+
(IsGlobalBuf || IsConstantBuf || IsHostBuf || IsHostTask)>>
16711675
accessor(
16721676
buffer<T, Dims, AllocatorT> &BufferRef, handler &CommandGroupHandler,
16731677
range<Dimensions> AccessRange, const property_list &PropertyList = {},
@@ -1680,7 +1684,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
16801684
typename = detail::enable_if_t<
16811685
detail::IsCxPropertyList<PropertyListT>::value &&
16821686
IsSameAsBuffer<T, Dims>::value &&
1683-
(IsGlobalBuf || IsConstantBuf || IsHostBuf)>>
1687+
(IsGlobalBuf || IsConstantBuf || IsHostBuf || IsHostTask)>>
16841688
accessor(
16851689
buffer<T, Dims, AllocatorT> &BufferRef, handler &CommandGroupHandler,
16861690
range<Dimensions> AccessRange,
@@ -1695,7 +1699,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
16951699
typename = detail::enable_if_t<
16961700
detail::IsRunTimePropertyListT<PropertyListT>::value &&
16971701
IsSameAsBuffer<T, Dims>::value && IsValidTag<TagT>::value &&
1698-
(IsGlobalBuf || IsConstantBuf || IsHostBuf)>>
1702+
(IsGlobalBuf || IsConstantBuf || IsHostBuf || IsHostTask)>>
16991703
accessor(
17001704
buffer<T, Dims, AllocatorT> &BufferRef, handler &CommandGroupHandler,
17011705
range<Dimensions> AccessRange, TagT,
@@ -1711,7 +1715,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
17111715
typename = detail::enable_if_t<
17121716
detail::IsCxPropertyList<PropertyListT>::value &&
17131717
IsSameAsBuffer<T, Dims>::value && IsValidTag<TagT>::value &&
1714-
(IsGlobalBuf || IsConstantBuf || IsHostBuf)>>
1718+
(IsGlobalBuf || IsConstantBuf || IsHostBuf || IsHostTask)>>
17151719
accessor(
17161720
buffer<T, Dims, AllocatorT> &BufferRef, handler &CommandGroupHandler,
17171721
range<Dimensions> AccessRange, TagT,
@@ -1727,7 +1731,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
17271731
typename = detail::enable_if_t<
17281732
detail::IsRunTimePropertyListT<PropertyListT>::value &&
17291733
IsSameAsBuffer<T, Dims>::value &&
1730-
(IsHostBuf || (IsGlobalBuf || IsConstantBuf))>>
1734+
(IsHostBuf || IsHostTask || (IsGlobalBuf || IsConstantBuf))>>
17311735
accessor(
17321736
buffer<T, Dims, AllocatorT> &BufferRef, range<Dimensions> AccessRange,
17331737
id<Dimensions> AccessOffset, const property_list &PropertyList = {},
@@ -1767,7 +1771,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
17671771
typename = detail::enable_if_t<
17681772
detail::IsCxPropertyList<PropertyListT>::value &&
17691773
IsSameAsBuffer<T, Dims>::value &&
1770-
(IsHostBuf || (IsGlobalBuf || IsConstantBuf))>>
1774+
(IsHostBuf || IsHostTask || (IsGlobalBuf || IsConstantBuf))>>
17711775
accessor(
17721776
buffer<T, Dims, AllocatorT> &BufferRef, range<Dimensions> AccessRange,
17731777
id<Dimensions> AccessOffset,
@@ -1838,7 +1842,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
18381842
typename = detail::enable_if_t<
18391843
detail::IsRunTimePropertyListT<PropertyListT>::value &&
18401844
IsSameAsBuffer<T, Dims>::value &&
1841-
(IsGlobalBuf || IsConstantBuf || IsHostBuf)>>
1845+
(IsGlobalBuf || IsConstantBuf || IsHostBuf || IsHostTask)>>
18421846
accessor(
18431847
buffer<T, Dims, AllocatorT> &BufferRef, handler &CommandGroupHandler,
18441848
range<Dimensions> AccessRange, id<Dimensions> AccessOffset,
@@ -1879,7 +1883,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
18791883
typename = detail::enable_if_t<
18801884
detail::IsCxPropertyList<PropertyListT>::value &&
18811885
IsSameAsBuffer<T, Dims>::value &&
1882-
(IsGlobalBuf || IsConstantBuf || IsHostBuf)>>
1886+
(IsGlobalBuf || IsConstantBuf || IsHostBuf || IsHostTask)>>
18831887
accessor(
18841888
buffer<T, Dims, AllocatorT> &BufferRef, handler &CommandGroupHandler,
18851889
range<Dimensions> AccessRange, id<Dimensions> AccessOffset,
@@ -1921,7 +1925,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
19211925
typename = detail::enable_if_t<
19221926
detail::IsRunTimePropertyListT<PropertyListT>::value &&
19231927
IsSameAsBuffer<T, Dims>::value && IsValidTag<TagT>::value &&
1924-
(IsGlobalBuf || IsConstantBuf || IsHostBuf)>>
1928+
(IsGlobalBuf || IsConstantBuf || IsHostBuf || IsHostTask)>>
19251929
accessor(
19261930
buffer<T, Dims, AllocatorT> &BufferRef, handler &CommandGroupHandler,
19271931
range<Dimensions> AccessRange, id<Dimensions> AccessOffset, TagT,
@@ -1937,7 +1941,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
19371941
typename = detail::enable_if_t<
19381942
detail::IsCxPropertyList<PropertyListT>::value &&
19391943
IsSameAsBuffer<T, Dims>::value && IsValidTag<TagT>::value &&
1940-
(IsGlobalBuf || IsConstantBuf || IsHostBuf)>>
1944+
(IsGlobalBuf || IsConstantBuf || IsHostBuf || IsHostTask)>>
19411945
accessor(
19421946
buffer<T, Dims, AllocatorT> &BufferRef, handler &CommandGroupHandler,
19431947
range<Dimensions> AccessRange, id<Dimensions> AccessOffset, TagT,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %clangxx -fsycl -fsyntax-only %s
2+
3+
#include <sycl/sycl.hpp>
4+
5+
int main() {
6+
using AccT = sycl::accessor<int, 0, sycl::access::mode::read_write,
7+
sycl::access::target::host_task>;
8+
int data(5);
9+
sycl::range<1> r(1);
10+
sycl::buffer<int, 1> data_buf(&data, r);
11+
sycl::queue q;
12+
q.submit([&](sycl::handler &cgh) { AccT acc(data_buf, cgh); });
13+
return 0;
14+
}

0 commit comments

Comments
 (0)