Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

[SYCL] Add check for carrying real kernel IDs #616

Merged
merged 4 commits into from
Dec 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions SYCL/Basic/interop/check_carrying_real_kernel_IDs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// REQUIRES: opencl
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out %opencl_lib
// RUN: %ACC_RUN_PLACEHOLDER %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out

#include <CL/opencl.h>
#include <CL/sycl.hpp>
#include <CL/sycl/backend/opencl.hpp>

using namespace cl::sycl;

int main() {
queue Queue{};

const char KernelCode[] = "__kernel void foo() { }\n";
const size_t KernelCodeSize = sizeof(KernelCode);
const char *CLCode[1] = {KernelCode};

auto Context = Queue.get_info<info::queue::context>();
auto Device = Queue.get_info<info::queue::device>();
cl_context CLContext = get_native<backend::opencl>(Context);
cl_device_id CLDevice = get_native<backend::opencl>(Device);

cl_int Err;

cl_program CLProgram =
clCreateProgramWithSource(CLContext, 1, CLCode, &KernelCodeSize, &Err);
assert(Err == CL_SUCCESS);
Err = clBuildProgram(CLProgram, 1, &CLDevice, "", nullptr, nullptr);
assert(Err == CL_SUCCESS);

cl_kernel CLKernel = clCreateKernel(CLProgram, "foo", &Err);
assert(Err == CL_SUCCESS);
kernel SYCLKernel = sycl::make_kernel<backend::opencl>(CLKernel, Context);

Queue.submit(
[&](handler &commandgroup) { commandgroup.single_task(SYCLKernel); });
return 0;
}