Skip to content

[SYCL] Fix accessor's CTAD for g++ host compiler #6673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions sycl/include/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,12 +817,14 @@ class __SYCL_SPECIAL_CLASS accessor :
constexpr static int AdjustedDim = Dimensions == 0 ? 1 : Dimensions;

using AccessorCommonT::AS;
using AccessorCommonT::IsAccessAnyWrite;
using AccessorCommonT::IsAccessReadOnly;
using AccessorCommonT::IsConstantBuf;
using AccessorCommonT::IsGlobalBuf;
using AccessorCommonT::IsHostBuf;
using AccessorCommonT::IsPlaceH;
// Cannot do "using AccessorCommonT::Flag" as it doesn't work with g++ as host
// compiler, for some reason.
static constexpr bool IsAccessAnyWrite = AccessorCommonT::IsAccessAnyWrite;
static constexpr bool IsAccessReadOnly = AccessorCommonT::IsAccessReadOnly;
static constexpr bool IsConstantBuf = AccessorCommonT::IsConstantBuf;
static constexpr bool IsGlobalBuf = AccessorCommonT::IsGlobalBuf;
static constexpr bool IsHostBuf = AccessorCommonT::IsHostBuf;
static constexpr bool IsPlaceH = AccessorCommonT::IsPlaceH;
template <int Dims>
using AccessorSubscript =
typename AccessorCommonT::template AccessorSubscript<Dims>;
Expand Down Expand Up @@ -1986,27 +1988,27 @@ accessor(buffer<DataT, Dimensions, AllocatorT>, Type1, Type2, Type3, Type4,
ext::oneapi::accessor_property_list<PropsT...>>;

template <typename DataT, int Dimensions, typename AllocatorT>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler)
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &)
-> accessor<DataT, Dimensions, access::mode::read_write, target::device,
access::placeholder::false_t>;

template <typename DataT, int Dimensions, typename AllocatorT,
typename... PropsT>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler,
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &,
const ext::oneapi::accessor_property_list<PropsT...> &)
-> accessor<DataT, Dimensions, access::mode::read_write, target::device,
access::placeholder::false_t,
ext::oneapi::accessor_property_list<PropsT...>>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1)
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &, Type1)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type1, Type1>(),
detail::deduceAccessTarget<Type1, Type1>(target::device),
access::placeholder::false_t>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename... PropsT>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1,
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &, Type1,
const ext::oneapi::accessor_property_list<PropsT...> &)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type1, Type1>(),
detail::deduceAccessTarget<Type1, Type1>(target::device),
Expand All @@ -2015,14 +2017,14 @@ accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1,

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename Type2>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2)
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &, Type1, Type2)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type1, Type2>(),
detail::deduceAccessTarget<Type1, Type2>(target::device),
access::placeholder::false_t>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename Type2, typename... PropsT>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2,
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &, Type1, Type2,
const ext::oneapi::accessor_property_list<PropsT...> &)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type1, Type2>(),
detail::deduceAccessTarget<Type1, Type2>(target::device),
Expand All @@ -2031,14 +2033,14 @@ accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2,

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename Type2, typename Type3>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2, Type3)
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &, Type1, Type2, Type3)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type2, Type3>(),
detail::deduceAccessTarget<Type2, Type3>(target::device),
access::placeholder::false_t>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename Type2, typename Type3, typename... PropsT>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2, Type3,
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &, Type1, Type2, Type3,
const ext::oneapi::accessor_property_list<PropsT...> &)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type2, Type3>(),
detail::deduceAccessTarget<Type2, Type3>(target::device),
Expand All @@ -2047,15 +2049,15 @@ accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2, Type3,

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename Type2, typename Type3, typename Type4>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2, Type3,
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &, Type1, Type2, Type3,
Type4)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type3, Type4>(),
detail::deduceAccessTarget<Type3, Type4>(target::device),
access::placeholder::false_t>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename Type2, typename Type3, typename Type4, typename... PropsT>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2, Type3,
accessor(buffer<DataT, Dimensions, AllocatorT>, handler &, Type1, Type2, Type3,
Type4, const ext::oneapi::accessor_property_list<PropsT...> &)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type3, Type4>(),
detail::deduceAccessTarget<Type3, Type4>(target::device),
Expand Down
11 changes: 11 additions & 0 deletions sycl/test/regression/fsycl-host-compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ int main() {
for (int i = 0; i < 3; i++)
if (data[i] != 1) isSuccess = false;

{
buffer<int, 1> b(1);
queue q;
q.submit([&](handler &cgh) {
accessor a{b, cgh};
cgh.single_task<class test2>([=] { a[0] = 42; });
}).wait();
host_accessor a{b};
isSuccess &= (a[0] == 42);
}

if (!isSuccess)
return -1;

Expand Down