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

[SYCL] Add test for kernel program cache #594

Closed
wants to merge 4 commits into from
Closed
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
41 changes: 41 additions & 0 deletions SYCL/Basic/kernel_program_cache.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER CreateMultipleRootDevices=2 NEOReadDebugKeys=1 %t.out
// REQUIRES: (opencl || level_zero) && gpu

//==---------- kernel_program_cache.cpp --- KernelProgramCache test --------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

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

class empty_functor {
public:
void operator()(cl::sycl::nd_item<1> item) const {}
};

template <class kernel_name, typename Functor>
void test(cl::sycl::queue &queue, Functor functor) {
auto bundle = cl::sycl::get_kernel_bundle<sycl::bundle_state::input>(
queue.get_context());

queue.submit([&](cl::sycl::handler &cgh) {
cgh.parallel_for(cl::sycl::nd_range<1>(10, 10), functor);
});

auto bundleObject = cl::sycl::build(bundle, bundle.get_devices());
auto kernelID = cl::sycl::get_kernel_id<kernel_name>();
auto kernel = bundleObject.get_kernel(kernelID);
}

int main() {
std::vector<device> devices = device::get_devices(info::device_type::gpu);
sycl::context context(devices);
sycl::queue queue(context, devices[0]);
assert(devices.size() == 2);
test<empty_functor>(queue, empty_functor{});
}