Skip to content
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

Certain kname types fail to compile for parallel_for<kname> #17092

Open
cmpfeil opened this issue Feb 20, 2025 · 1 comment
Open

Certain kname types fail to compile for parallel_for<kname> #17092

cmpfeil opened this issue Feb 20, 2025 · 1 comment
Labels
bug Something isn't working confirmed

Comments

@cmpfeil
Copy link

cmpfeil commented Feb 20, 2025

Describe the bug

Certain choices for the optional template parameter typename KernelName for parallel_for cause compilation error.

To reproduce

Minimal modification of the basic example from SYCL Basic Code: parallel_for is sufficient: Replace parallel_for by parallel_for<kname> with specific type for kname. Full code:

// example.cxx
#include <CL/sycl.hpp>
#include <cstdint>

template <std::uint8_t N>
struct Something {};

using kname = Something<34>; // problem
//using kname = Something<11>; // no problem for other values

using namespace sycl;

int main() {
  queue Q;
  int const size = 10;
  buffer<int> A{ size };

  Q.submit([&](handler& h) {
      accessor A_acc(A, h);
      h.parallel_for<kname>(range<1>(size), [=](id<1> indx) {
          A_acc[indx] = 77;
          });
      });

  host_accessor result(A);

  for (int i = 0; i < size; i++)
    std::cout << result[i] << " "; std::cout << "\n";
  return 0;
}

Compilation via icpx -fsycl example.cxx reproduces the error

In file included from <built-in>:1:
/tmp/icpx-9fdd42b796/example-header-ab166a.h:65:63: warning: missing terminating ' character [-Winvalid-pp-token]
   65 |     return "::sycl::detail::__pf_kernel_wrapper<::Something<'"'>>";
      |                                                               ^
/tmp/icpx-9fdd42b796/example-header-ab166a.h:65:63: error: expected ';' after return statement
   65 |     return "::sycl::detail::__pf_kernel_wrapper<::Something<'"'>>";
      |                                                               ^
      |                                                               ;
/tmp/icpx-9fdd42b796/example-header-ab166a.h:112:27: warning: missing terminating ' character [-Winvalid-pp-token]
  112 |     return "::Something<'"'>";
      |                           ^
/tmp/icpx-9fdd42b796/example-header-ab166a.h:112:27: error: expected ';' after return statement
  112 |     return "::Something<'"'>";
      |                           ^
      |                           ;

See also https://www.godbolt.org/z/scWTq48a6

Environment

  • OS: Linux (at least)
  • DPC++ versions 2022.2.0 and newer reproduce this error
  • DPC++ versions 2022.1.0 and older don't reproduce this error

Additional context

Suspected cause: According to cppref

... std::uint8_t may be unsigned char, ...

Then, I guess the value of 34 corresponding to the character " causes the compiler generated header /tmp/icpx-9fdd42b796/example-header-ab166a.h to contain these syntax errors: e.g., return "::Something<'"'>"; which should rather be return "::Something<'\"'>";.

@cmpfeil cmpfeil added the bug Something isn't working label Feb 20, 2025
@bader
Copy link
Contributor

bader commented Feb 20, 2025

@tahonermann, FYI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed
Projects
None yet
Development

No branches or pull requests

3 participants