Skip to content

Commit 57aabe7

Browse files
[SYCL] Fix accessor's CTAD for g++ host compiler (#6673)
1 parent 4d69c29 commit 57aabe7

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

sycl/include/sycl/accessor.hpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -817,12 +817,14 @@ class __SYCL_SPECIAL_CLASS accessor :
817817
constexpr static int AdjustedDim = Dimensions == 0 ? 1 : Dimensions;
818818

819819
using AccessorCommonT::AS;
820-
using AccessorCommonT::IsAccessAnyWrite;
821-
using AccessorCommonT::IsAccessReadOnly;
822-
using AccessorCommonT::IsConstantBuf;
823-
using AccessorCommonT::IsGlobalBuf;
824-
using AccessorCommonT::IsHostBuf;
825-
using AccessorCommonT::IsPlaceH;
820+
// Cannot do "using AccessorCommonT::Flag" as it doesn't work with g++ as host
821+
// compiler, for some reason.
822+
static constexpr bool IsAccessAnyWrite = AccessorCommonT::IsAccessAnyWrite;
823+
static constexpr bool IsAccessReadOnly = AccessorCommonT::IsAccessReadOnly;
824+
static constexpr bool IsConstantBuf = AccessorCommonT::IsConstantBuf;
825+
static constexpr bool IsGlobalBuf = AccessorCommonT::IsGlobalBuf;
826+
static constexpr bool IsHostBuf = AccessorCommonT::IsHostBuf;
827+
static constexpr bool IsPlaceH = AccessorCommonT::IsPlaceH;
826828
template <int Dims>
827829
using AccessorSubscript =
828830
typename AccessorCommonT::template AccessorSubscript<Dims>;
@@ -1986,27 +1988,27 @@ accessor(buffer<DataT, Dimensions, AllocatorT>, Type1, Type2, Type3, Type4,
19861988
ext::oneapi::accessor_property_list<PropsT...>>;
19871989

19881990
template <typename DataT, int Dimensions, typename AllocatorT>
1989-
accessor(buffer<DataT, Dimensions, AllocatorT>, handler)
1991+
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &)
19901992
-> accessor<DataT, Dimensions, access::mode::read_write, target::device,
19911993
access::placeholder::false_t>;
19921994

19931995
template <typename DataT, int Dimensions, typename AllocatorT,
19941996
typename... PropsT>
1995-
accessor(buffer<DataT, Dimensions, AllocatorT>, handler,
1997+
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &,
19961998
const ext::oneapi::accessor_property_list<PropsT...> &)
19971999
-> accessor<DataT, Dimensions, access::mode::read_write, target::device,
19982000
access::placeholder::false_t,
19992001
ext::oneapi::accessor_property_list<PropsT...>>;
20002002

20012003
template <typename DataT, int Dimensions, typename AllocatorT, typename Type1>
2002-
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1)
2004+
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &, Type1)
20032005
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type1, Type1>(),
20042006
detail::deduceAccessTarget<Type1, Type1>(target::device),
20052007
access::placeholder::false_t>;
20062008

20072009
template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
20082010
typename... PropsT>
2009-
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1,
2011+
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &, Type1,
20102012
const ext::oneapi::accessor_property_list<PropsT...> &)
20112013
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type1, Type1>(),
20122014
detail::deduceAccessTarget<Type1, Type1>(target::device),
@@ -2015,14 +2017,14 @@ accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1,
20152017

20162018
template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
20172019
typename Type2>
2018-
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2)
2020+
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &, Type1, Type2)
20192021
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type1, Type2>(),
20202022
detail::deduceAccessTarget<Type1, Type2>(target::device),
20212023
access::placeholder::false_t>;
20222024

20232025
template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
20242026
typename Type2, typename... PropsT>
2025-
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2,
2027+
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &, Type1, Type2,
20262028
const ext::oneapi::accessor_property_list<PropsT...> &)
20272029
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type1, Type2>(),
20282030
detail::deduceAccessTarget<Type1, Type2>(target::device),
@@ -2031,14 +2033,14 @@ accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2,
20312033

20322034
template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
20332035
typename Type2, typename Type3>
2034-
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2, Type3)
2036+
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &, Type1, Type2, Type3)
20352037
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type2, Type3>(),
20362038
detail::deduceAccessTarget<Type2, Type3>(target::device),
20372039
access::placeholder::false_t>;
20382040

20392041
template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
20402042
typename Type2, typename Type3, typename... PropsT>
2041-
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2, Type3,
2043+
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &, Type1, Type2, Type3,
20422044
const ext::oneapi::accessor_property_list<PropsT...> &)
20432045
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type2, Type3>(),
20442046
detail::deduceAccessTarget<Type2, Type3>(target::device),
@@ -2047,15 +2049,15 @@ accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2, Type3,
20472049

20482050
template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
20492051
typename Type2, typename Type3, typename Type4>
2050-
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2, Type3,
2052+
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &, Type1, Type2, Type3,
20512053
Type4)
20522054
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type3, Type4>(),
20532055
detail::deduceAccessTarget<Type3, Type4>(target::device),
20542056
access::placeholder::false_t>;
20552057

20562058
template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
20572059
typename Type2, typename Type3, typename Type4, typename... PropsT>
2058-
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2, Type3,
2060+
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &, Type1, Type2, Type3,
20592061
Type4, const ext::oneapi::accessor_property_list<PropsT...> &)
20602062
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type3, Type4>(),
20612063
detail::deduceAccessTarget<Type3, Type4>(target::device),

sycl/test/regression/fsycl-host-compiler.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ int main() {
3838
for (int i = 0; i < 3; i++)
3939
if (data[i] != 1) isSuccess = false;
4040

41+
{
42+
buffer<int, 1> b(1);
43+
queue q;
44+
q.submit([&](handler &cgh) {
45+
accessor a{b, cgh};
46+
cgh.single_task<class test2>([=] { a[0] = 42; });
47+
}).wait();
48+
host_accessor a{b};
49+
isSuccess &= (a[0] == 42);
50+
}
51+
4152
if (!isSuccess)
4253
return -1;
4354

0 commit comments

Comments
 (0)