Skip to content

accessor should export its template arguments / template matching error on accessor<T,int,auto...>  #10057

@stdale-intel

Description

@stdale-intel

When storing SYCL accessors inside a struct, it is important to be able to access the accessor's template parameters. (Refs: #9434, KhronosGroup/SYCL-Docs#421).

The accessor documentation shows a definition:

template <typename DataT, int Dimensions = 1,
          access_mode AccessMode =
              (std::is_const_v<DataT> ? access_mode::read
                                      : access_mode::read_write),
          target AccessTarget = target::device,
          access::placeholder isPlaceholder = access::placeholder::false_t>
class accessor

However, this definition is defective, because the accessor does not re-export its access mode or target.

Further, attempting to work around this limitation exposes an implementation flaw in DPCPP. The following code works generally and also succeeds with hipSYCL. However, it fails to compile with dpcpp:

#include <sycl/sycl.hpp>

template<typename, typename>
struct apply_accessor {};

template<template<typename,auto...> typename Acc,
         typename T1, typename T, auto... A>
struct apply_accessor<Acc<T1, A...>, T> {
    using type = Acc<T, A...>;
};

struct A {
    using X = sycl::accessor<int, 1, sycl::access::mode::read_write, sycl::access::target::device>;//, sycl::access::placeholder::false_t>;

    using Y = typename apply_accessor<X, float>::type;
};

int main() {
    A a;
}

Copy of filing from: KhronosGroup/SYCL-Docs#433

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions