Skip to content

Commit 81c6b57

Browse files
Added config params for ifdef consts, moved device sel. class decl. to new file
Added config parameters for __SYCL_COMPILER_VERSION cutoffs used throughout. Moved declarations of dpctl_device_selector and other derived classes to a dedicated .hpp file.
1 parent 1d1dcc6 commit 81c6b57

10 files changed

+201
-140
lines changed

libsyclinterface/helper/source/dpctl_utils_helper.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ std::string DPCTL_DeviceTypeToStr(info::device_type devTy)
4848
case info::device_type::custom:
4949
ss << "custom";
5050
break;
51+
#if __SYCL_COMPILER_VERSION < __SYCL_COMPILER_2023_SWITCHOVER
5152
case info::device_type::host:
5253
ss << "host";
5354
break;
55+
#endif
5456
default:
5557
ss << "unknown";
5658
}
@@ -90,8 +92,10 @@ backend DPCTL_DPCTLBackendTypeToSyclBackend(DPCTLSyclBackendType BeTy)
9092
switch (BeTy) {
9193
case DPCTLSyclBackendType::DPCTL_CUDA:
9294
return backend::ext_oneapi_cuda;
95+
#if __SYCL_COMPILER_VERSION < __SYCL_COMPILER_2023_SWITCHOVER
9396
case DPCTLSyclBackendType::DPCTL_HOST:
9497
return backend::host;
98+
#endif
9599
case DPCTLSyclBackendType::DPCTL_LEVEL_ZERO:
96100
return backend::ext_oneapi_level_zero;
97101
case DPCTLSyclBackendType::DPCTL_OPENCL:
@@ -108,8 +112,10 @@ DPCTLSyclBackendType DPCTL_SyclBackendToDPCTLBackendType(backend B)
108112
switch (B) {
109113
case backend::ext_oneapi_cuda:
110114
return DPCTLSyclBackendType::DPCTL_CUDA;
115+
#if __SYCL_COMPILER_VERSION < __SYCL_COMPILER_2023_SWITCHOVER
111116
case backend::host:
112117
return DPCTLSyclBackendType::DPCTL_HOST;
118+
#endif
113119
case backend::ext_oneapi_level_zero:
114120
return DPCTLSyclBackendType::DPCTL_LEVEL_ZERO;
115121
case backend::opencl:
@@ -487,9 +493,11 @@ std::string DPCTL_GetDeviceFilterString(const device &Device)
487493
case backend::opencl:
488494
ss << "opencl";
489495
break;
496+
#if __SYCL_COMPILER_VERSION < __SYCL_COMPILER_2023_SWITCHOVER
490497
case backend::host:
491498
ss << "host";
492499
break;
500+
#endif
493501
default:
494502
ss << "unknown";
495503
};

libsyclinterface/include/Config/dpctl_config.h.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929
#cmakedefine DPCTL_ENABLE_L0_PROGRAM_CREATION \
3030
@DPCTL_ENABLE_L0_PROGRAM_CREATION@
3131

32+
/* Version of SYCL DPC++ 2023 compiler at which transition to SYCL 2020 occurs */
33+
#define __SYCL_COMPILER_2023_SWITCHOVER 20221020L
34+
35+
/* Version of SYCL DPC++ compiler at which info::max_work_item_size was
36+
made templated */
37+
#define __SYCL_COMPILER_MAX_WORK_ITEM_SIZE_THRESHOLD 20220805L
38+
3239
/* The DPCPP version used to build dpctl */
3340
#define DPCTL_DPCPP_VERSION "@IntelSycl_VERSION@"
3441

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
//===-- dpctl_device_selectors.h - Device selector class declar. --*-C++-*- =//
2+
//
3+
//
4+
// Data Parallel Control (dpctl)
5+
//
6+
// Copyright 2020-2022 Intel Corporation
7+
//
8+
// Licensed under the Apache License, Version 2.0 (the "License");
9+
// you may not use this file except in compliance with the License.
10+
// You may obtain a copy of the License at
11+
//
12+
// http://www.apache.org/licenses/LICENSE-2.0
13+
//
14+
// Unless required by applicable law or agreed to in writing, software
15+
// distributed under the License is distributed on an "AS IS" BASIS,
16+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
// See the License for the specific language governing permissions and
18+
// limitations under the License.
19+
//
20+
//===----------------------------------------------------------------------===//
21+
///
22+
/// \file
23+
/// This file declares classes for device selection.
24+
///
25+
//===----------------------------------------------------------------------===//
26+
27+
#pragma once
28+
29+
#include "Config/dpctl_config.h"
30+
#include "Support/DllExport.h"
31+
#include <CL/sycl.hpp>
32+
33+
namespace dpctl
34+
{
35+
namespace syclinterface
36+
{
37+
38+
#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_2023_SWITCHOVER
39+
40+
class DPCTL_API dpctl_device_selector
41+
{
42+
public:
43+
virtual ~dpctl_device_selector() = default;
44+
static constexpr int REJECT_DEVICE = -1;
45+
virtual int operator()(const sycl::device &) const;
46+
};
47+
48+
class DPCTL_API dpctl_accelerator_selector : public dpctl_device_selector
49+
{
50+
public:
51+
dpctl_accelerator_selector() = default;
52+
int operator()(const sycl::device &d) const override;
53+
};
54+
55+
class DPCTL_API dpctl_default_selector : public dpctl_device_selector
56+
{
57+
public:
58+
dpctl_default_selector() = default;
59+
int operator()(const sycl::device &d) const override;
60+
};
61+
62+
class DPCTL_API dpctl_gpu_selector : public dpctl_device_selector
63+
{
64+
public:
65+
dpctl_gpu_selector() = default;
66+
int operator()(const sycl::device &d) const override;
67+
};
68+
69+
class DPCTL_API dpctl_cpu_selector : public dpctl_device_selector
70+
{
71+
public:
72+
dpctl_cpu_selector() = default;
73+
int operator()(const sycl::device &d) const override;
74+
};
75+
76+
class DPCTL_API dpctl_filter_selector : public dpctl_device_selector
77+
{
78+
public:
79+
dpctl_filter_selector(const std::string &fs) : _impl(fs) {}
80+
int operator()(const sycl::device &d) const override;
81+
82+
private:
83+
sycl::ext::oneapi::filter_selector _impl;
84+
};
85+
86+
class DPCTL_API dpctl_host_selector : public dpctl_device_selector
87+
{
88+
public:
89+
dpctl_host_selector() = default;
90+
int operator()(const sycl::device &) const override;
91+
};
92+
93+
#else
94+
95+
class DPCTL_API dpctl_device_selector : public sycl::device_selector
96+
{
97+
public:
98+
virtual ~dpctl_device_selector() = default;
99+
100+
virtual int operator()(const sycl::device &device) const = 0;
101+
};
102+
103+
class DPCTL_API dpctl_accelerator_selector : public dpctl_device_selector
104+
{
105+
public:
106+
dpctl_accelerator_selector() : _impl(){};
107+
int operator()(const sycl::device &d) const override;
108+
109+
private:
110+
sycl::accelerator_selector _impl;
111+
};
112+
113+
class DPCTL_API dpctl_default_selector : public dpctl_device_selector
114+
{
115+
public:
116+
dpctl_default_selector() : _impl(){};
117+
int operator()(const sycl::device &d) const override;
118+
119+
private:
120+
sycl::default_selector _impl;
121+
};
122+
123+
class DPCTL_API dpctl_gpu_selector : public dpctl_device_selector
124+
{
125+
public:
126+
dpctl_gpu_selector() : _impl(){};
127+
int operator()(const sycl::device &d) const override;
128+
129+
private:
130+
sycl::gpu_selector _impl;
131+
};
132+
133+
class DPCTL_API dpctl_cpu_selector : public dpctl_device_selector
134+
{
135+
public:
136+
dpctl_cpu_selector() : _impl(){};
137+
int operator()(const sycl::device &d) const override;
138+
139+
private:
140+
sycl::cpu_selector _impl;
141+
};
142+
143+
class DPCTL_API dpctl_filter_selector : public dpctl_device_selector
144+
{
145+
public:
146+
dpctl_filter_selector(const std::string &fs) : _impl(fs) {}
147+
148+
int operator()(const sycl::device &d) const override;
149+
150+
private:
151+
sycl::ext::oneapi::filter_selector _impl;
152+
};
153+
154+
class DPCTL_API dpctl_host_selector : public dpctl_device_selector
155+
{
156+
public:
157+
dpctl_host_selector() : _impl(){};
158+
int operator()(const sycl::device &d) const override;
159+
160+
private:
161+
sycl::host_selector _impl;
162+
};
163+
164+
#endif
165+
166+
} // namespace syclinterface
167+
} // namespace dpctl

libsyclinterface/include/dpctl_sycl_type_casters.hpp

Lines changed: 1 addition & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -28,142 +28,14 @@
2828

2929
#ifdef __cplusplus
3030

31-
#include "Support/DllExport.h"
31+
#include "dpctl_device_selection.hpp"
3232
#include "dpctl_sycl_types.h"
3333
#include <CL/sycl.hpp>
3434
#include <vector>
3535

3636
namespace dpctl::syclinterface
3737
{
3838

39-
#if __SYCL_COMPILER_VERSION >= 20221020
40-
41-
class DPCTL_API dpctl_device_selector
42-
{
43-
public:
44-
virtual ~dpctl_device_selector() = default;
45-
static constexpr int REJECT_DEVICE = -1;
46-
virtual int operator()(const sycl::device &) const;
47-
};
48-
49-
class DPCTL_API dpctl_accelerator_selector : public dpctl_device_selector
50-
{
51-
public:
52-
dpctl_accelerator_selector() = default;
53-
int operator()(const sycl::device &d) const override;
54-
};
55-
56-
class DPCTL_API dpctl_default_selector : public dpctl_device_selector
57-
{
58-
public:
59-
dpctl_default_selector() = default;
60-
int operator()(const sycl::device &d) const override;
61-
};
62-
63-
class DPCTL_API dpctl_gpu_selector : public dpctl_device_selector
64-
{
65-
public:
66-
dpctl_gpu_selector() = default;
67-
int operator()(const sycl::device &d) const override;
68-
};
69-
70-
class DPCTL_API dpctl_cpu_selector : public dpctl_device_selector
71-
{
72-
public:
73-
dpctl_cpu_selector() = default;
74-
int operator()(const sycl::device &d) const override;
75-
};
76-
77-
class DPCTL_API dpctl_filter_selector : public dpctl_device_selector
78-
{
79-
public:
80-
dpctl_filter_selector(const std::string &fs) : _impl(fs) {}
81-
int operator()(const sycl::device &d) const override;
82-
83-
private:
84-
sycl::ext::oneapi::filter_selector _impl;
85-
};
86-
87-
class DPCTL_API dpctl_host_selector : public dpctl_device_selector
88-
{
89-
public:
90-
dpctl_host_selector() = default;
91-
int operator()(const sycl::device &) const override;
92-
};
93-
94-
#else
95-
96-
class DPCTL_API dpctl_device_selector : public sycl::device_selector
97-
{
98-
public:
99-
virtual ~dpctl_device_selector() = default;
100-
101-
virtual int operator()(const sycl::device &device) const = 0;
102-
};
103-
104-
class DPCTL_API dpctl_accelerator_selector : public dpctl_device_selector
105-
{
106-
public:
107-
dpctl_accelerator_selector() : _impl(){};
108-
int operator()(const sycl::device &d) const override;
109-
110-
private:
111-
sycl::accelerator_selector _impl;
112-
};
113-
114-
class DPCTL_API dpctl_default_selector : public dpctl_device_selector
115-
{
116-
public:
117-
dpctl_default_selector() : _impl(){};
118-
int operator()(const sycl::device &d) const override;
119-
120-
private:
121-
sycl::default_selector _impl;
122-
};
123-
124-
class DPCTL_API dpctl_gpu_selector : public dpctl_device_selector
125-
{
126-
public:
127-
dpctl_gpu_selector() : _impl(){};
128-
int operator()(const sycl::device &d) const override;
129-
130-
private:
131-
sycl::gpu_selector _impl;
132-
};
133-
134-
class DPCTL_API dpctl_cpu_selector : public dpctl_device_selector
135-
{
136-
public:
137-
dpctl_cpu_selector() : _impl(){};
138-
int operator()(const sycl::device &d) const override;
139-
140-
private:
141-
sycl::cpu_selector _impl;
142-
};
143-
144-
class DPCTL_API dpctl_filter_selector : public dpctl_device_selector
145-
{
146-
public:
147-
dpctl_filter_selector(const std::string &fs) : _impl(fs) {}
148-
149-
int operator()(const sycl::device &d) const override;
150-
151-
private:
152-
sycl::ext::oneapi::filter_selector _impl;
153-
};
154-
155-
class DPCTL_API dpctl_host_selector : public dpctl_device_selector
156-
{
157-
public:
158-
dpctl_host_selector() : _impl(){};
159-
int operator()(const sycl::device &d) const override;
160-
161-
private:
162-
sycl::host_selector _impl;
163-
};
164-
165-
#endif
166-
16739
/*!
16840
@brief Creates two convenience templated functions to
16941
reinterpret_cast an opaque pointer to a pointer to a Sycl type

libsyclinterface/source/dpctl_device_selector.cpp renamed to libsyclinterface/source/dpctl_device_selection.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@
2121
///
2222
/// \file
2323
/// This file implements device-selection classes declared in
24-
/// dpctl_sycl_type_type_casters.hpp
24+
/// dpctl_device_selection.hpp
2525
///
2626
//===----------------------------------------------------------------------===//
2727

28-
#include "dpctl_sycl_type_casters.hpp"
28+
#include "dpctl_device_selection.hpp"
29+
#include "Config/dpctl_config.h"
2930
#include <CL/sycl.hpp>
3031

3132
namespace dpctl
3233
{
33-
3434
namespace syclinterface
3535
{
3636

37-
#if __SYCL_COMPILER_VERSION >= 20221020
37+
#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_2023_SWITCHOVER
3838

3939
int dpctl_device_selector::operator()(const sycl::device &) const
4040
{

0 commit comments

Comments
 (0)