Skip to content

[SYCL] Unnamed lambdas should be fine with -sycl-std=2020 #3740

@pkeir

Description

@pkeir

With a build of the current DPC++ tip, the code below from Section 3.2 of the SYCL 2020 spec. can be compiled using clang++ -fsycl -fsycl-unnamed-lambda sycl_spec_2020_example_3_2.cpp.

The same command will fail with the -fsycl-unnamed-lambda flag removed; even with -sycl-std=2020 added explicitly. Am I right that the code below should build without the -fsycl-unnamed-lambda flag?

#include <iostream>
#include <sycl/sycl.hpp>
using namespace sycl;

int main() {
  int data[1024]; // Allocate data to be worked on

  queue myQueue;

  {
    buffer<int, 1> resultBuf { data, range<1> { 1024 } };

    myQueue.submit([&](handler& cgh) {
      accessor writeResult { resultBuf, cgh, write_only, no_init };

      cgh.parallel_for(1024, [=](id<1> idx) {
        writeResult[idx] = idx;
      }); // End of the kernel function
    });   // End of our commands for this queue
  }       // End of scope, so we wait for work producing resultBuf to complete

  for (int i = 0; i < 1024; i++)
    std::cout << "data[" << i << "] = " << data[i] << std::endl;

  return 0;
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions