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

Commit 06314ab

Browse files
authored
[SYCL] Remove old style interop (#448)
1 parent 9a1832b commit 06314ab

23 files changed

+211
-49
lines changed

SYCL/Basic/event_creation.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,4 @@ int main() {
2222
} catch (cl::sycl::device_error e) {
2323
std::cout << "Failed to create device for event" << std::endl;
2424
}
25-
try {
26-
std::cout << "Try create OpenCL event" << std::endl;
27-
cl::sycl::context c;
28-
if (!c.is_host()) {
29-
::cl_int error;
30-
cl_event u_e = clCreateUserEvent(c.get(), &error);
31-
cl::sycl::event cl_e(u_e, c);
32-
std::cout << "OpenCL event: " << std::hex << cl_e.get()
33-
<< ((cl_e.get() == u_e) ? " matches " : " does not match ")
34-
<< u_e << std::endl;
35-
36-
} else {
37-
std::cout << "Failed to create OpenCL context" << std::endl;
38-
}
39-
} catch (cl::sycl::device_error e) {
40-
std::cout << "Failed to create device for context" << std::endl;
41-
}
4225
}

SYCL/Basic/fpga_tests/fpga_queue.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// REQUIRES: opencl, opencl_icd
22

33
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out %opencl_lib
4-
// RUN: %HOST_RUN_PLACEHOLDER %t.out
54
// RUN: %ACC_RUN_PLACEHOLDER %t.out
6-
// RUN: %CPU_RUN_PLACEHOLDER %t.out
7-
// RUN: %GPU_RUN_PLACEHOLDER %t.out
85

96
//==------------- fpga_queue.cpp - SYCL FPGA queues test -------------------==//
107
//
@@ -14,6 +11,7 @@
1411
//
1512
//===----------------------------------------------------------------------===//
1613
#include <CL/sycl.hpp>
14+
#include <CL/sycl/backend/opencl.hpp>
1715
#include <iostream>
1816
#include <set>
1917

@@ -25,7 +23,7 @@ const int maxNumQueues = 256;
2523
void GetCLQueue(event sycl_event, std::set<cl_command_queue> &cl_queues) {
2624
try {
2725
cl_command_queue cl_queue;
28-
cl_event cl_event = sycl_event.get();
26+
cl_event cl_event = get_native<backend::opencl>(sycl_event);
2927
cl_int error = clGetEventInfo(cl_event, CL_EVENT_COMMAND_QUEUE,
3028
sizeof(cl_queue), &cl_queue, nullptr);
3129
assert(CL_SUCCESS == error && "Failed to obtain queue from OpenCL event");
@@ -108,7 +106,9 @@ int main() {
108106
int result = cl_queues.size();
109107
device dev = Queue.get_device();
110108
int expected_result =
111-
dev.is_host() ? 0 : getExpectedQueueNumber(dev.get(), 3);
109+
dev.is_host()
110+
? 0
111+
: getExpectedQueueNumber(get_native<backend::opencl>(dev), 3);
112112

113113
if (expected_result != result) {
114114
std::cout << "Result Num of queues = " << result << std::endl
@@ -149,7 +149,9 @@ int main() {
149149
int result = cl_queues.size();
150150
device dev = Queue.get_device();
151151
int expected_result =
152-
dev.is_host() ? 0 : getExpectedQueueNumber(dev.get(), maxNumQueues);
152+
dev.is_host() ? 0
153+
: getExpectedQueueNumber(get_native<backend::opencl>(dev),
154+
maxNumQueues);
153155

154156
if (expected_result != result) {
155157
std::cout << "Result Num of queues = " << result << std::endl

SYCL/Basic/queue/queue.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//
99
//===----------------------------------------------------------------------===//
1010
#include <CL/sycl.hpp>
11+
#include <CL/sycl/backend/opencl.hpp>
1112
#include <iostream>
1213

1314
using namespace cl::sycl;
@@ -23,7 +24,7 @@ void print_queue_info(const queue &q) {
2324
q.get_context().get_platform().get_backend() !=
2425
cl::sycl::backend::opencl)
2526
? nullptr
26-
: q.get())
27+
: sycl::get_native<sycl::backend::opencl>(q))
2728
<< std::endl;
2829
std::cout << "queue wraps " << get_type(q.get_device()) << " device"
2930
<< std::endl;
@@ -50,7 +51,7 @@ int main() {
5051
assert(deviceA.is_host() == MovedQueue.is_host());
5152
if (!deviceA.is_host() &&
5253
deviceA.get_platform().get_backend() == cl::sycl::backend::opencl) {
53-
assert(MovedQueue.get() != nullptr);
54+
assert(sycl::get_native<sycl::backend::opencl>(MovedQueue) != nullptr);
5455
}
5556
}
5657
{
@@ -63,7 +64,8 @@ int main() {
6364
assert(deviceA.is_host() == WillMovedQueue.is_host());
6465
if (!deviceA.is_host() &&
6566
deviceA.get_platform().get_backend() == cl::sycl::backend::opencl) {
66-
assert(WillMovedQueue.get() != nullptr);
67+
assert(sycl::get_native<sycl::backend::opencl>(WillMovedQueue) !=
68+
nullptr);
6769
}
6870
}
6971
{

SYCL/Basic/subdevice.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
#include <CL/sycl.hpp>
16+
#include <CL/sycl/backend/opencl.hpp>
1617
#include <algorithm>
1718
#include <cassert>
1819
#include <iostream>
@@ -50,8 +51,9 @@ int main() {
5051
SubDevicesEq[0].get_info<info::device::partition_type_property>() ==
5152
info::partition_property::partition_equally);
5253

53-
assert(SubDevicesEq[0].get_info<info::device::parent_device>().get() ==
54-
dev.get());
54+
assert(sycl::get_native<sycl::backend::opencl>(
55+
SubDevicesEq[0].get_info<info::device::parent_device>()) ==
56+
sycl::get_native<sycl::backend::opencl>(dev));
5557
} catch (feature_not_supported) {
5658
// okay skip it
5759
}

SYCL/Basic/subsubdevice.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
#include <CL/sycl.hpp>
16+
#include <CL/sycl/backend/opencl.hpp>
1617
#include <algorithm>
1718
#include <cassert>
1819
#include <iostream>
@@ -51,8 +52,9 @@ int main() {
5152
SubDevicesEq[0].get_info<info::device::partition_type_property>() ==
5253
info::partition_property::partition_equally);
5354

54-
assert(SubDevicesEq[0].get_info<info::device::parent_device>().get() ==
55-
dev.get());
55+
assert(sycl::get_native<sycl::backend::opencl>(
56+
SubDevicesEq[0].get_info<info::device::parent_device>()) ==
57+
sycl::get_native<sycl::backend::opencl>(dev));
5658
} catch (feature_not_supported) {
5759
// okay skip it
5860
}

SYCL/Basic/buffer/buffer_interop.cpp renamed to SYCL/DeprecatedFeatures/buffer_interop.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: opencl, opencl_icd
22

3-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out %opencl_lib
3+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -D__SYCL_INTERNAL_API -o %t.out %opencl_lib
44
// RUN: %CPU_RUN_PLACEHOLDER %t.out
55
// RUN: %GPU_RUN_PLACEHOLDER %t.out
66
// RUN: %ACC_RUN_PLACEHOLDER %t.out

SYCL/Basic/device_platform_interop.cpp renamed to SYCL/DeprecatedFeatures/device_platform_interop.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: opencl
22

3-
// RUN: %clangxx -fsycl %s -o %t.run
3+
// RUN: %clangxx -fsycl -D__SYCL_INTERNAL_API %s -o %t.run
44
// RUN: %GPU_RUN_PLACEHOLDER %t.run
55
// RUN: %CPU_RUN_PLACEHOLDER %t.run
66
// RUN: %ACC_RUN_PLACEHOLDER %t.run
@@ -43,4 +43,4 @@ int main() {
4343
assert(P1 == P3 && "Platform impls are different");
4444

4545
return 0;
46-
}
46+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// REQUIRES: opencl, opencl_icd
2+
3+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -D__SYCL_INTERNAL_API %s -o %t.out %opencl_lib
4+
// RUN: %HOST_RUN_PLACEHOLDER %t.out
5+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
6+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
7+
8+
//==--------------- event.cpp - SYCL event test ----------------------------==//
9+
//
10+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
11+
// See https://llvm.org/LICENSE.txt for license information.
12+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
13+
//
14+
//===----------------------------------------------------------------------===//
15+
#include <CL/sycl.hpp>
16+
#include <iostream>
17+
18+
int main() {
19+
try {
20+
std::cout << "Try create OpenCL event" << std::endl;
21+
cl::sycl::context c;
22+
if (!c.is_host()) {
23+
::cl_int error;
24+
cl_event u_e = clCreateUserEvent(c.get(), &error);
25+
cl::sycl::event cl_e(u_e, c);
26+
std::cout << "OpenCL event: " << std::hex << cl_e.get()
27+
<< ((cl_e.get() == u_e) ? " matches " : " does not match ")
28+
<< u_e << std::endl;
29+
30+
} else {
31+
std::cout << "Failed to create OpenCL context" << std::endl;
32+
}
33+
} catch (cl::sycl::device_error e) {
34+
std::cout << "Failed to create device for context" << std::endl;
35+
}
36+
}

SYCL/KernelAndProgram/kernel-and-program-interop.cpp renamed to SYCL/DeprecatedFeatures/kernel-and-program-interop.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: opencl, opencl_icd
22

3-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out %opencl_lib
3+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -D__SYCL_INTERNAL_API -o %t.out %opencl_lib
44
// RUN: %HOST_RUN_PLACEHOLDER %t.out
55
// RUN: %CPU_RUN_PLACEHOLDER %t.out
66
// RUN: %GPU_RUN_PLACEHOLDER %t.out

SYCL/Basic/kernel_interop.cpp renamed to SYCL/DeprecatedFeatures/kernel_interop.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: opencl, opencl_icd
22

3-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out %opencl_lib
3+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -D__SYCL_INTERNAL_API %s -o %t.out %opencl_lib
44
// RUN: %CPU_RUN_PLACEHOLDER %t.out
55
// RUN: %GPU_RUN_PLACEHOLDER %t.out
66
// RUN: %ACC_RUN_PLACEHOLDER %t.out

0 commit comments

Comments
 (0)