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

[SYCL] Adjust SYCL 2020 guarded feature tests #1137

Merged
Merged
Show file tree
Hide file tree
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
23 changes: 3 additions & 20 deletions SYCL/Basic/buffer/buffer_allocator.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// RUN: %clangxx -fsycl -DSYCL2020_CONFORMANT_APIS -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: env SYCL_DEVICE_FILTER=opencl %CPU_RUN_PLACEHOLDER %t.out
// RUN: env SYCL_DEVICE_FILTER=opencl %GPU_RUN_PLACEHOLDER %t.out
// RUN: env SYCL_DEVICE_FILTER=opencl %ACC_RUN_PLACEHOLDER %t.out
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: env SYCL_DEVICE_FILTER=opencl %CPU_RUN_PLACEHOLDER %t.out
// RUN: env SYCL_DEVICE_FILTER=opencl %GPU_RUN_PLACEHOLDER %t.out
Expand All @@ -15,9 +11,9 @@
//
//===----------------------------------------------------------------------===//

// Tests that the default (and explicit with SYCL 2020) buffer_allocator used by
// buffers are as defined by the spec and will allocate the right amount of
// memory on the device.
// Tests that the default and explicit buffer_allocator used by buffers are as
// defined by the spec and will allocate the right amount of memory on the
// device.

#include <iostream>
#include <sycl/sycl.hpp>
Expand Down Expand Up @@ -45,40 +41,27 @@ bool checkResult(sycl::buffer<T, 1, AllocT> &Buf, size_t N, std::string &TName,
template <typename T> bool runTest(sycl::queue &Q, std::string TName) {
sycl::buffer<T, 1> DefaultBuf{NumElems};

#ifdef SYCL2020_CONFORMANT_APIS
static_assert(std::is_same_v<decltype(DefaultBuf),
sycl::buffer<T, 1, sycl::buffer_allocator<T>>>);

sycl::buffer<T, 1, sycl::buffer_allocator<char>> CharAllocBuf{NumElems};
sycl::buffer<T, 1, sycl::buffer_allocator<long>> LongAllocBuf{NumElems};
#else
static_assert(std::is_same_v<decltype(DefaultBuf),
sycl::buffer<T, 1, sycl::buffer_allocator>>);
#endif

Q.submit([&](sycl::handler &CGH) {
auto DefaultAcc = DefaultBuf.get_access(CGH);
#ifdef SYCL2020_CONFORMANT_APIS
auto CharAllocAcc = CharAllocBuf.get_access(CGH);
auto LongAllocAcc = LongAllocBuf.get_access(CGH);
#endif
CGH.parallel_for<TestKernel<T>>(NumElems, [=](sycl::item<1> It) {
DefaultAcc[It] = static_cast<T>(It[0]);
#ifdef SYCL2020_CONFORMANT_APIS
CharAllocAcc[It] = static_cast<T>(It[0]);
LongAllocAcc[It] = static_cast<T>(It[0]);
#endif
});
}).wait();

#ifdef SYCL2020_CONFORMANT_APIS
return checkResult(DefaultBuf, NumElems, TName,
"buffer_allocator<" + TName + ">") &&
checkResult(CharAllocBuf, NumElems, TName, "buffer_allocator<char>") &&
checkResult(LongAllocBuf, NumElems, TName, "buffer_allocator<long>");
#else
return checkResult(DefaultBuf, NumElems, TName, "buffer_allocator");
#endif
}

#define RUN_TEST(TYPE, Q) runTest<TYPE>(Q, #TYPE)
Expand Down
5 changes: 3 additions & 2 deletions SYCL/Basic/fpga_tests/fpga_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ const int maxNumQueues = 256;
void GetCLQueue(event sycl_event, std::set<cl_command_queue> &cl_queues) {
try {
cl_command_queue cl_queue;
cl_event cl_event = get_native<backend::opencl>(sycl_event);
cl_int error = clGetEventInfo(cl_event, CL_EVENT_COMMAND_QUEUE,
std::vector<cl_event> cl_events = get_native<backend::opencl>(sycl_event);
assert(cl_events.size() > 0 && "No native OpenCL events in SYCL event.");
cl_int error = clGetEventInfo(cl_events[0], CL_EVENT_COMMAND_QUEUE,
sizeof(cl_queue), &cl_queue, nullptr);
assert(CL_SUCCESS == error && "Failed to obtain queue from OpenCL event");

Expand Down
17 changes: 0 additions & 17 deletions SYCL/HostInteropTask/interop-task.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// RUN: %clangxx -fsycl -DSYCL2020_CONFORMANT_APIS -fsycl-targets=%sycl_triple %s -o %t.out %threads_lib %opencl_lib
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// RUN: %ACC_RUN_PLACEHOLDER %t.out
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out %threads_lib %opencl_lib
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
Expand Down Expand Up @@ -47,16 +43,9 @@ void copy(buffer<DataT, 1> &Src, buffer<DataT, 1> &Dst, queue &Q) {
auto DstMem = IH.get_native_mem<backend::opencl>(DstA);
cl_event Event;

#ifdef SYCL2020_CONFORMANT_APIS
int RC = clEnqueueCopyBuffer(NativeQ, SrcMem[0], DstMem[0], 0, 0,
sizeof(DataT) * SrcA.get_count(), 0, nullptr,
&Event);
#else
int RC = clEnqueueCopyBuffer(NativeQ, SrcMem, DstMem, 0, 0,
sizeof(DataT) * SrcA.get_count(), 0, nullptr,
&Event);
#endif

if (RC != CL_SUCCESS)
throw runtime_error("Can't enqueue buffer copy", RC);

Expand Down Expand Up @@ -180,15 +169,9 @@ void test3(queue &Q) {

Q.submit([&](handler &CGH) {
auto Func = [=](interop_handle IH) {
#ifdef SYCL2020_CONFORMANT_APIS
std::vector<cl_event> Ev = get_native<backend::opencl>(Event);

int RC = clWaitForEvents(1, Ev.data());
#else
cl_event Ev = get_native<backend::opencl>(Event);

int RC = clWaitForEvents(1, &Ev);
#endif
if (RC != CL_SUCCESS)
throw runtime_error("Can't wait for events", RC);
};
Expand Down
13 changes: 0 additions & 13 deletions SYCL/Plugin/interop-opencl.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
// REQUIRES: opencl

// RUN: %clangxx -fsycl -DSYCL2020_CONFORMANT_APIS -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: env SYCL_DEVICE_FILTER=opencl %CPU_RUN_PLACEHOLDER %t.out
// RUN: env SYCL_DEVICE_FILTER=opencl %GPU_RUN_PLACEHOLDER %t.out
// RUN: env SYCL_DEVICE_FILTER=opencl %ACC_RUN_PLACEHOLDER %t.out
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: env SYCL_DEVICE_FILTER=opencl %CPU_RUN_PLACEHOLDER %t.out
// RUN: env SYCL_DEVICE_FILTER=opencl %GPU_RUN_PLACEHOLDER %t.out
Expand Down Expand Up @@ -37,9 +33,7 @@ int main() {
cgh.host_task([=](const sycl::interop_handle &ih) {
(void)Acc;
auto BufNative = ih.get_native_mem<sycl::backend::opencl>(Acc);
#ifdef SYCL2020_CONFORMANT_APIS
assert(BufNative.size() == 1);
#endif
});
});
}
Expand All @@ -50,22 +44,15 @@ int main() {
auto ocl_context = get_native<backend::opencl>(Context);
auto ocl_queue = get_native<backend::opencl>(Queue);
auto ocl_buffers = get_native<backend::opencl>(Buffer);
#ifdef SYCL2020_CONFORMANT_APIS
assert(ocl_buffers.size() == 1);
#endif

// Re-create SYCL objects from native OpenCL handles
auto PlatformInterop = opencl::make<platform>(ocl_platform);
auto DeviceInterop = opencl::make<device>(ocl_device);
auto ContextInterop = opencl::make<context>(ocl_context);
auto QueueInterop = opencl::make<queue>(ContextInterop, ocl_queue);
#ifdef SYCL2020_CONFORMANT_APIS
auto BufferInterop =
sycl::make_buffer<backend::opencl, int>(ocl_buffers[0], ContextInterop);
#else
auto BufferInterop =
sycl::make_buffer<backend::opencl, int>(ocl_buffers, ContextInterop);
#endif

// Check native handles
assert(ocl_platform == get_native<backend::opencl>(PlatformInterop));
Expand Down