llvm icon indicating copy to clipboard operation
llvm copied to clipboard

attribute 'reqd_work_group_size' does not support argument pack expansion

Open jzc opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe

The sycl::reqd_work_group_size attribute (and sycl::work_group_size_hint) does not accept a parameter pack expansion.

#include <sycl/sycl.hpp>

using namespace sycl;

template <int... Dims>
void foo1(queue &q) {
  range r(Dims...);
  nd_range ndr(r, r);
  q.parallel_for(ndr, [=](auto id) [[sycl::reqd_work_group_size(Dims...)]] {});
}

template <int... Dims>
void foo2(queue &q) {
  range r(Dims...);
  nd_range ndr(r, r);
  q.parallel_for(ndr, [=](auto id) [[sycl::work_group_size_hint(Dims...)]] {});
}

int main() {
  queue q;
  foo1<2>(q);
  foo1<2, 2>(q);
  foo1<2, 2, 2>(q);
  foo2<2>(q);
  foo2<2, 2>(q);
  foo2<2, 2, 2>(q);
}

Compiling this results with this error:

error: attribute 'reqd_work_group_size' does not support argument pack expansion
    9 |   q.parallel_for(ndr, [=](auto id) [[sycl::reqd_work_group_size(Dims...)]] {});
      |                                                                        ^
error: attribute 'work_group_size_hint' does not support argument pack expansion
   16 |   q.parallel_for(ndr, [=](auto id) [[sycl::work_group_size_hint(Dims...)]] {});

note that sycl::device_has does support parameter pack expansions; the following similar code compiles:

template <aspect... Aspects>
void foo(queue &q) {
  q.parallel_for(1, [=](auto id) [[sycl::device_has(Aspects...)]] {});
}

Describe the solution you would like

No response

Describe alternatives you have considered

No response

Additional context

No response

jzc avatar May 07 '24 16:05 jzc