Skip to content

Commit 6052ba0

Browse files
Use full qualifier sycl::device to fix compilation error
Added ifdefs around changes needed to work with both newer OS compiler and current oneAPI DPC++
1 parent dbc4b6a commit 6052ba0

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed

libsyclinterface/tests/test_helper.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@ TEST_F(TestHelperFns, ChkDeviceTypeToStr)
4545
res = DPCTL_DeviceTypeToStr(sycl::info::device_type::gpu));
4646
ASSERT_TRUE(res == "gpu");
4747

48+
#if __SYCL_COMPILER_VERSION < __SYCL_COMPILER_2023_SWITCHOVER
4849
EXPECT_NO_FATAL_FAILURE(
4950
res = DPCTL_DeviceTypeToStr(sycl::info::device_type::host));
51+
// since host device is being deprecated in SYCL 2020, accept unknown
5052
ASSERT_TRUE(res == "host");
53+
#endif
5154

5255
EXPECT_NO_FATAL_FAILURE(
5356
res = DPCTL_DeviceTypeToStr(sycl::info::device_type::custom));
@@ -72,8 +75,10 @@ TEST_F(TestHelperFns, ChkStrToDeviceType)
7275
EXPECT_NO_FATAL_FAILURE(dev_type = DPCTL_StrToDeviceType("gpu"));
7376
ASSERT_TRUE(dev_type == sycl::info::device_type::gpu);
7477

78+
#if __SYCL_COMPILER_VERSION < __SYCL_COMPILER_2023_SWITCHOVER
7579
EXPECT_NO_FATAL_FAILURE(dev_type = DPCTL_StrToDeviceType("host"));
7680
ASSERT_TRUE(dev_type == sycl::info::device_type::host);
81+
#endif
7782

7883
EXPECT_NO_FATAL_FAILURE(dev_type = DPCTL_StrToDeviceType("accelerator"));
7984
ASSERT_TRUE(dev_type == sycl::info::device_type::accelerator);
@@ -92,9 +97,11 @@ TEST_F(TestHelperFns, ChkDPCTLBackendTypeToSyclBackend)
9297
DPCTLSyclBackendType::DPCTL_CUDA));
9398
ASSERT_TRUE(res == sycl::backend::ext_oneapi_cuda);
9499

100+
#if __SYCL_COMPILER_VERSION < __SYCL_COMPILER_2023_SWITCHOVER
95101
EXPECT_NO_FATAL_FAILURE(res = DPCTL_DPCTLBackendTypeToSyclBackend(
96102
DPCTLSyclBackendType::DPCTL_HOST));
97103
ASSERT_TRUE(res == sycl::backend::host);
104+
#endif
98105

99106
EXPECT_NO_FATAL_FAILURE(res = DPCTL_DPCTLBackendTypeToSyclBackend(
100107
DPCTLSyclBackendType::DPCTL_OPENCL));
@@ -121,9 +128,11 @@ TEST_F(TestHelperFns, ChkSyclBackendToDPCTLBackendType)
121128
DTy = DPCTL_SyclBackendToDPCTLBackendType(sycl::backend::opencl));
122129
ASSERT_TRUE(DTy == DPCTLSyclBackendType::DPCTL_OPENCL);
123130

131+
#if __SYCL_COMPILER_VERSION < __SYCL_COMPILER_2023_SWITCHOVER
124132
EXPECT_NO_FATAL_FAILURE(
125133
DTy = DPCTL_SyclBackendToDPCTLBackendType(sycl::backend::host));
126134
ASSERT_TRUE(DTy == DPCTLSyclBackendType::DPCTL_HOST);
135+
#endif
127136

128137
EXPECT_NO_FATAL_FAILURE(DTy = DPCTL_SyclBackendToDPCTLBackendType(
129138
sycl::backend::ext_oneapi_cuda));
@@ -154,9 +163,11 @@ TEST_F(TestHelperFns, ChkDPCTLDeviceTypeToSyclDeviceType)
154163
DPCTLSyclDeviceType::DPCTL_CUSTOM));
155164
ASSERT_TRUE(dev_type == sycl::info::device_type::custom);
156165

166+
#if __SYCL_COMPILER_VERSION < __SYCL_COMPILER_2023_SWITCHOVER
157167
EXPECT_NO_FATAL_FAILURE(dev_type = DPCTL_DPCTLDeviceTypeToSyclDeviceType(
158168
DPCTLSyclDeviceType::DPCTL_HOST_DEVICE));
159169
ASSERT_TRUE(dev_type == sycl::info::device_type::host);
170+
#endif
160171

161172
EXPECT_NO_FATAL_FAILURE(dev_type = DPCTL_DPCTLDeviceTypeToSyclDeviceType(
162173
DPCTLSyclDeviceType::DPCTL_AUTOMATIC));
@@ -179,9 +190,11 @@ TEST_F(TestHelperFns, SyclDeviceTypeToDPCTLDeviceType)
179190
sycl::info::device_type::gpu));
180191
ASSERT_TRUE(DTy == DPCTLSyclDeviceType::DPCTL_GPU);
181192

193+
#if __SYCL_COMPILER_VERSION < __SYCL_COMPILER_2023_SWITCHOVER
182194
EXPECT_NO_FATAL_FAILURE(DTy = DPCTL_SyclDeviceTypeToDPCTLDeviceType(
183195
sycl::info::device_type::host));
184196
ASSERT_TRUE(DTy == DPCTLSyclDeviceType::DPCTL_HOST_DEVICE);
197+
#endif
185198

186199
EXPECT_NO_FATAL_FAILURE(DTy = DPCTL_SyclDeviceTypeToDPCTLDeviceType(
187200
sycl::info::device_type::accelerator));

libsyclinterface/tests/test_sycl_device_aspects.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ struct TestDPCTLSyclDeviceInterfaceAspects
163163
EXPECT_NO_FATAL_FAILURE(DRef = DPCTLDevice_CreateFromSelector(DSRef));
164164
if (!DRef)
165165
GTEST_SKIP_("Device not found");
166-
auto D = unwrap<device>(DRef);
166+
auto D = unwrap<sycl::device>(DRef);
167167
auto syclAspect = GetParam().second.second;
168168
try {
169169
hasAspect = D->has(syclAspect);

libsyclinterface/tests/test_sycl_device_manager.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
///
2525
//===----------------------------------------------------------------------===//
2626

27+
#include "dpctl_device_selection.hpp"
2728
#include "dpctl_sycl_device_interface.h"
2829
#include "dpctl_sycl_device_manager.h"
2930
#include "dpctl_sycl_device_selector_interface.h"
@@ -32,6 +33,8 @@
3233
#include <gtest/gtest.h>
3334
#include <string>
3435

36+
using dpctl::syclinterface::dpctl_default_selector;
37+
3538
struct TestDPCTLDeviceManager : public ::testing::TestWithParam<const char *>
3639
{
3740
DPCTLSyclDeviceSelectorRef DSRef = nullptr;

libsyclinterface/tests/test_sycl_event_interface.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
///
2525
//===----------------------------------------------------------------------===//
2626

27+
#include "Config/dpctl_config.h"
2728
#include "dpctl_sycl_event_interface.h"
2829
#include "dpctl_sycl_types.h"
2930
#include <CL/sycl.hpp>
@@ -156,7 +157,12 @@ TEST_F(TestDPCTLSyclEventInterface, ChkGetCommandExecutionStatus)
156157
TEST_F(TestDPCTLSyclEventInterface, CheckGetProfiling)
157158
{
158159
property_list propList{property::queue::enable_profiling()};
160+
161+
#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_2023_SWITCHOVER
162+
queue Q(cpu_selector_v, propList);
163+
#else
159164
queue Q(cpu_selector(), propList);
165+
#endif
160166
auto eA = Q.submit(
161167
[&](handler &h) { h.parallel_for(1000, [=](id<1>) { /*...*/ }); });
162168
DPCTLSyclEventRef ERef = reinterpret_cast<DPCTLSyclEventRef>(&eA);

libsyclinterface/tests/test_sycl_queue_interface.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
///
2525
//===----------------------------------------------------------------------===//
2626

27+
#include "Config/dpctl_config.h"
2728
#include "dpctl_sycl_context_interface.h"
2829
#include "dpctl_sycl_device_interface.h"
2930
#include "dpctl_sycl_device_manager.h"
@@ -355,9 +356,11 @@ TEST_P(TestDPCTLQueueMemberFunctions, CheckGetBackend)
355356
case DPCTL_CUDA:
356357
EXPECT_TRUE(Backend == backend::ext_oneapi_cuda);
357358
break;
359+
#if __SYCL_COMPILER_VERSION < __SYCL_COMPILER_2023_SWITCHOVER
358360
case DPCTL_HOST:
359361
EXPECT_TRUE(Backend == backend::host);
360362
break;
363+
#endif
361364
case DPCTL_LEVEL_ZERO:
362365
EXPECT_TRUE(Backend == backend::ext_oneapi_level_zero);
363366
break;

0 commit comments

Comments
 (0)