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

Commit a4f2cae

Browse files
[SYCL] Adjust SYCL 2020 guarded feature tests (#1137)
With SYCL 2020 features that were previously guarded by the SYCL2020_CONFORMANT_APIS, tests that distinguished between behaviours with and without the macro are changed to expect the previously guarded API in all cases. Related change: intel/llvm#6541
1 parent 66c65ac commit a4f2cae

File tree

4 files changed

+6
-52
lines changed

4 files changed

+6
-52
lines changed

SYCL/Basic/buffer/buffer_allocator.cpp

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// RUN: %clangxx -fsycl -DSYCL2020_CONFORMANT_APIS -fsycl-targets=%sycl_triple %s -o %t.out
2-
// RUN: env SYCL_DEVICE_FILTER=opencl %CPU_RUN_PLACEHOLDER %t.out
3-
// RUN: env SYCL_DEVICE_FILTER=opencl %GPU_RUN_PLACEHOLDER %t.out
4-
// RUN: env SYCL_DEVICE_FILTER=opencl %ACC_RUN_PLACEHOLDER %t.out
51
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
62
// RUN: env SYCL_DEVICE_FILTER=opencl %CPU_RUN_PLACEHOLDER %t.out
73
// RUN: env SYCL_DEVICE_FILTER=opencl %GPU_RUN_PLACEHOLDER %t.out
@@ -15,9 +11,9 @@
1511
//
1612
//===----------------------------------------------------------------------===//
1713

18-
// Tests that the default (and explicit with SYCL 2020) buffer_allocator used by
19-
// buffers are as defined by the spec and will allocate the right amount of
20-
// memory on the device.
14+
// Tests that the default and explicit buffer_allocator used by buffers are as
15+
// defined by the spec and will allocate the right amount of memory on the
16+
// device.
2117

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

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

5247
sycl::buffer<T, 1, sycl::buffer_allocator<char>> CharAllocBuf{NumElems};
5348
sycl::buffer<T, 1, sycl::buffer_allocator<long>> LongAllocBuf{NumElems};
54-
#else
55-
static_assert(std::is_same_v<decltype(DefaultBuf),
56-
sycl::buffer<T, 1, sycl::buffer_allocator>>);
57-
#endif
5849

5950
Q.submit([&](sycl::handler &CGH) {
6051
auto DefaultAcc = DefaultBuf.get_access(CGH);
61-
#ifdef SYCL2020_CONFORMANT_APIS
6252
auto CharAllocAcc = CharAllocBuf.get_access(CGH);
6353
auto LongAllocAcc = LongAllocBuf.get_access(CGH);
64-
#endif
6554
CGH.parallel_for<TestKernel<T>>(NumElems, [=](sycl::item<1> It) {
6655
DefaultAcc[It] = static_cast<T>(It[0]);
67-
#ifdef SYCL2020_CONFORMANT_APIS
6856
CharAllocAcc[It] = static_cast<T>(It[0]);
6957
LongAllocAcc[It] = static_cast<T>(It[0]);
70-
#endif
7158
});
7259
}).wait();
7360

74-
#ifdef SYCL2020_CONFORMANT_APIS
7561
return checkResult(DefaultBuf, NumElems, TName,
7662
"buffer_allocator<" + TName + ">") &&
7763
checkResult(CharAllocBuf, NumElems, TName, "buffer_allocator<char>") &&
7864
checkResult(LongAllocBuf, NumElems, TName, "buffer_allocator<long>");
79-
#else
80-
return checkResult(DefaultBuf, NumElems, TName, "buffer_allocator");
81-
#endif
8265
}
8366

8467
#define RUN_TEST(TYPE, Q) runTest<TYPE>(Q, #TYPE)

SYCL/Basic/fpga_tests/fpga_queue.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ const int maxNumQueues = 256;
2323
void GetCLQueue(event sycl_event, std::set<cl_command_queue> &cl_queues) {
2424
try {
2525
cl_command_queue cl_queue;
26-
cl_event cl_event = get_native<backend::opencl>(sycl_event);
27-
cl_int error = clGetEventInfo(cl_event, CL_EVENT_COMMAND_QUEUE,
26+
std::vector<cl_event> cl_events = get_native<backend::opencl>(sycl_event);
27+
assert(cl_events.size() > 0 && "No native OpenCL events in SYCL event.");
28+
cl_int error = clGetEventInfo(cl_events[0], CL_EVENT_COMMAND_QUEUE,
2829
sizeof(cl_queue), &cl_queue, nullptr);
2930
assert(CL_SUCCESS == error && "Failed to obtain queue from OpenCL event");
3031

SYCL/HostInteropTask/interop-task.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// RUN: %clangxx -fsycl -DSYCL2020_CONFORMANT_APIS -fsycl-targets=%sycl_triple %s -o %t.out %threads_lib %opencl_lib
2-
// RUN: %CPU_RUN_PLACEHOLDER %t.out
3-
// RUN: %GPU_RUN_PLACEHOLDER %t.out
4-
// RUN: %ACC_RUN_PLACEHOLDER %t.out
51
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out %threads_lib %opencl_lib
62
// RUN: %CPU_RUN_PLACEHOLDER %t.out
73
// RUN: %GPU_RUN_PLACEHOLDER %t.out
@@ -47,16 +43,9 @@ void copy(buffer<DataT, 1> &Src, buffer<DataT, 1> &Dst, queue &Q) {
4743
auto DstMem = IH.get_native_mem<backend::opencl>(DstA);
4844
cl_event Event;
4945

50-
#ifdef SYCL2020_CONFORMANT_APIS
5146
int RC = clEnqueueCopyBuffer(NativeQ, SrcMem[0], DstMem[0], 0, 0,
5247
sizeof(DataT) * SrcA.get_count(), 0, nullptr,
5348
&Event);
54-
#else
55-
int RC = clEnqueueCopyBuffer(NativeQ, SrcMem, DstMem, 0, 0,
56-
sizeof(DataT) * SrcA.get_count(), 0, nullptr,
57-
&Event);
58-
#endif
59-
6049
if (RC != CL_SUCCESS)
6150
throw runtime_error("Can't enqueue buffer copy", RC);
6251

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

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

186174
int RC = clWaitForEvents(1, Ev.data());
187-
#else
188-
cl_event Ev = get_native<backend::opencl>(Event);
189-
190-
int RC = clWaitForEvents(1, &Ev);
191-
#endif
192175
if (RC != CL_SUCCESS)
193176
throw runtime_error("Can't wait for events", RC);
194177
};

SYCL/Plugin/interop-opencl.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
// REQUIRES: opencl
22

3-
// RUN: %clangxx -fsycl -DSYCL2020_CONFORMANT_APIS -fsycl-targets=%sycl_triple %s -o %t.out
4-
// RUN: env SYCL_DEVICE_FILTER=opencl %CPU_RUN_PLACEHOLDER %t.out
5-
// RUN: env SYCL_DEVICE_FILTER=opencl %GPU_RUN_PLACEHOLDER %t.out
6-
// RUN: env SYCL_DEVICE_FILTER=opencl %ACC_RUN_PLACEHOLDER %t.out
73
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
84
// RUN: env SYCL_DEVICE_FILTER=opencl %CPU_RUN_PLACEHOLDER %t.out
95
// RUN: env SYCL_DEVICE_FILTER=opencl %GPU_RUN_PLACEHOLDER %t.out
@@ -37,9 +33,7 @@ int main() {
3733
cgh.host_task([=](const sycl::interop_handle &ih) {
3834
(void)Acc;
3935
auto BufNative = ih.get_native_mem<sycl::backend::opencl>(Acc);
40-
#ifdef SYCL2020_CONFORMANT_APIS
4136
assert(BufNative.size() == 1);
42-
#endif
4337
});
4438
});
4539
}
@@ -50,22 +44,15 @@ int main() {
5044
auto ocl_context = get_native<backend::opencl>(Context);
5145
auto ocl_queue = get_native<backend::opencl>(Queue);
5246
auto ocl_buffers = get_native<backend::opencl>(Buffer);
53-
#ifdef SYCL2020_CONFORMANT_APIS
5447
assert(ocl_buffers.size() == 1);
55-
#endif
5648

5749
// Re-create SYCL objects from native OpenCL handles
5850
auto PlatformInterop = opencl::make<platform>(ocl_platform);
5951
auto DeviceInterop = opencl::make<device>(ocl_device);
6052
auto ContextInterop = opencl::make<context>(ocl_context);
6153
auto QueueInterop = opencl::make<queue>(ContextInterop, ocl_queue);
62-
#ifdef SYCL2020_CONFORMANT_APIS
6354
auto BufferInterop =
6455
sycl::make_buffer<backend::opencl, int>(ocl_buffers[0], ContextInterop);
65-
#else
66-
auto BufferInterop =
67-
sycl::make_buffer<backend::opencl, int>(ocl_buffers, ContextInterop);
68-
#endif
6956

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

0 commit comments

Comments
 (0)