Skip to content

[SYCL] Incorrect Kernel Lambda Capture #41

Closed
@agozillon

Description

#include <CL/sycl.hpp>
using namespace cl::sycl;

int main() {
  queue q;
  q.submit([&](handler &cgh) {
    int w = 512;
    cgh.single_task<class are_you_broken>([=]() {
      printf("%d \n", w);
    });
  });
  q.wait();
  return 0;
}

So it's a pretty simple example, just trying to capture a value and print it, however when using ComputeCPP (1.0) I'll get the correct value 512 inside the single_task, in the Intel implementation I get an arbitrary large integer value (e.g. 946443008). The contrived example should be directly and quickly usable to see if it is indeed a bug in the implementation or if I'm mistaken and its an issue on my end!

I used the following command: clang++ -std=c++11 -fsycl possibly_broken_capture.cpp -o possibly_broken_capture -lsycl -lOpenCL

When I compile just the device side code the header indicates that SemaSYCL does find the parameter and treats it as { kernel_param_kind_t::kind_std_layout, 4, 0 }.

Note: In my test version of the example I have a device selector that forces it to choose Intel OCL, so both SYCL runtimes should find the same OCL implementation.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions