|
28 | 28 |
|
29 | 29 | #ifdef __cplusplus |
30 | 30 |
|
| 31 | +#include "Support/DllExport.h" |
31 | 32 | #include "dpctl_sycl_types.h" |
32 | 33 | #include <CL/sycl.hpp> |
33 | | -#include <iostream> |
34 | 34 | #include <vector> |
35 | 35 |
|
36 | 36 | namespace dpctl::syclinterface |
37 | 37 | { |
38 | 38 |
|
39 | 39 | #if __SYCL_COMPILER_VERSION >= 20221020 |
40 | 40 |
|
41 | | -class dpctl_device_selector |
| 41 | +class DPCTL_API dpctl_device_selector |
42 | 42 | { |
43 | 43 | public: |
44 | 44 | virtual ~dpctl_device_selector() = default; |
45 | 45 | static constexpr int REJECT_DEVICE = -1; |
46 | | - virtual int operator()(const sycl::device &d) const |
47 | | - { |
48 | | - std::cout << "Outright rejecting " |
49 | | - << d.get_info<sycl::info::device::name>() << std::endl; |
50 | | - return REJECT_DEVICE; |
51 | | - }; |
| 46 | + virtual int operator()(const sycl::device &) const; |
52 | 47 | }; |
53 | 48 |
|
54 | | -class dpctl_accelerator_selector : public dpctl_device_selector |
| 49 | +class DPCTL_API dpctl_accelerator_selector : public dpctl_device_selector |
55 | 50 | { |
56 | 51 | public: |
57 | 52 | dpctl_accelerator_selector() = default; |
58 | | - int operator()(const sycl::device &d) const override |
59 | | - { |
60 | | - return sycl::accelerator_selector_v(d); |
61 | | - } |
| 53 | + int operator()(const sycl::device &d) const override; |
62 | 54 | }; |
63 | 55 |
|
64 | | -class dpctl_default_selector : public dpctl_device_selector |
| 56 | +class DPCTL_API dpctl_default_selector : public dpctl_device_selector |
65 | 57 | { |
66 | 58 | public: |
67 | 59 | dpctl_default_selector() = default; |
68 | | - int operator()(const sycl::device &d) const override |
69 | | - { |
70 | | - auto score = sycl::default_selector_v(d); |
71 | | - std::cout << "Got score = " << score << std::endl; |
72 | | - return score; |
73 | | - } |
| 60 | + int operator()(const sycl::device &d) const override; |
74 | 61 | }; |
75 | 62 |
|
76 | | -class dpctl_gpu_selector : public dpctl_device_selector |
| 63 | +class DPCTL_API dpctl_gpu_selector : public dpctl_device_selector |
77 | 64 | { |
78 | 65 | public: |
79 | 66 | dpctl_gpu_selector() = default; |
80 | | - int operator()(const sycl::device &d) const override |
81 | | - { |
82 | | - return sycl::gpu_selector_v(d); |
83 | | - } |
| 67 | + int operator()(const sycl::device &d) const override; |
84 | 68 | }; |
85 | 69 |
|
86 | | -class dpctl_cpu_selector : public dpctl_device_selector |
| 70 | +class DPCTL_API dpctl_cpu_selector : public dpctl_device_selector |
87 | 71 | { |
88 | 72 | public: |
89 | 73 | dpctl_cpu_selector() = default; |
90 | | - int operator()(const sycl::device &d) const override |
91 | | - { |
92 | | - return sycl::cpu_selector_v(d); |
93 | | - } |
| 74 | + int operator()(const sycl::device &d) const override; |
94 | 75 | }; |
95 | 76 |
|
96 | | -class dpctl_filter_selector : public dpctl_device_selector |
| 77 | +class DPCTL_API dpctl_filter_selector : public dpctl_device_selector |
97 | 78 | { |
98 | 79 | public: |
99 | 80 | dpctl_filter_selector(const std::string &fs) : _impl(fs) {} |
100 | | - |
101 | | - int operator()(const sycl::device &d) const override |
102 | | - { |
103 | | - return _impl(d); |
104 | | - } |
| 81 | + int operator()(const sycl::device &d) const override; |
105 | 82 |
|
106 | 83 | private: |
107 | 84 | sycl::ext::oneapi::filter_selector _impl; |
108 | 85 | }; |
109 | 86 |
|
110 | | -class dpctl_host_selector : public dpctl_device_selector |
| 87 | +class DPCTL_API dpctl_host_selector : public dpctl_device_selector |
111 | 88 | { |
112 | 89 | public: |
113 | 90 | dpctl_host_selector() = default; |
114 | | - int operator()(const sycl::device &) const override |
115 | | - { |
116 | | - return REJECT_DEVICE; |
117 | | - } |
| 91 | + int operator()(const sycl::device &) const override; |
118 | 92 | }; |
119 | 93 |
|
120 | 94 | #else |
121 | 95 |
|
122 | | -class dpctl_device_selector : public sycl::device_selector |
| 96 | +class DPCTL_API dpctl_device_selector : public sycl::device_selector |
123 | 97 | { |
124 | 98 | public: |
125 | 99 | virtual ~dpctl_device_selector() = default; |
126 | 100 |
|
127 | 101 | virtual int operator()(const sycl::device &device) const = 0; |
128 | 102 | }; |
129 | 103 |
|
130 | | -class dpctl_accelerator_selector : public dpctl_device_selector |
| 104 | +class DPCTL_API dpctl_accelerator_selector : public dpctl_device_selector |
131 | 105 | { |
132 | 106 | public: |
133 | 107 | dpctl_accelerator_selector() : _impl(){}; |
134 | | - int operator()(const sycl::device &d) const |
135 | | - { |
136 | | - return _impl(d); |
137 | | - } |
| 108 | + int operator()(const sycl::device &d) const override; |
138 | 109 |
|
139 | 110 | private: |
140 | 111 | sycl::accelerator_selector _impl; |
141 | 112 | }; |
142 | 113 |
|
143 | | -class dpctl_default_selector : public dpctl_device_selector |
| 114 | +class DPCTL_API dpctl_default_selector : public dpctl_device_selector |
144 | 115 | { |
145 | 116 | public: |
146 | 117 | dpctl_default_selector() : _impl(){}; |
147 | | - int operator()(const sycl::device &d) const |
148 | | - { |
149 | | - return _impl(d); |
150 | | - } |
| 118 | + int operator()(const sycl::device &d) const override; |
151 | 119 |
|
152 | 120 | private: |
153 | 121 | sycl::default_selector _impl; |
154 | 122 | }; |
155 | 123 |
|
156 | | -class dpctl_gpu_selector : public dpctl_device_selector |
| 124 | +class DPCTL_API dpctl_gpu_selector : public dpctl_device_selector |
157 | 125 | { |
158 | 126 | public: |
159 | 127 | dpctl_gpu_selector() : _impl(){}; |
160 | | - int operator()(const sycl::device &d) const |
161 | | - { |
162 | | - return _impl(d); |
163 | | - } |
| 128 | + int operator()(const sycl::device &d) const override; |
164 | 129 |
|
165 | 130 | private: |
166 | 131 | sycl::gpu_selector _impl; |
167 | 132 | }; |
168 | 133 |
|
169 | | -class dpctl_cpu_selector : public dpctl_device_selector |
| 134 | +class DPCTL_API dpctl_cpu_selector : public dpctl_device_selector |
170 | 135 | { |
171 | 136 | public: |
172 | 137 | dpctl_cpu_selector() : _impl(){}; |
173 | | - int operator()(const sycl::device &d) const |
174 | | - { |
175 | | - return _impl(d); |
176 | | - } |
| 138 | + int operator()(const sycl::device &d) const override; |
177 | 139 |
|
178 | 140 | private: |
179 | 141 | sycl::cpu_selector _impl; |
180 | 142 | }; |
181 | 143 |
|
182 | | -class dpctl_filter_selector : public dpctl_device_selector |
| 144 | +class DPCTL_API dpctl_filter_selector : public dpctl_device_selector |
183 | 145 | { |
184 | 146 | public: |
185 | 147 | dpctl_filter_selector(const std::string &fs) : _impl(fs) {} |
186 | 148 |
|
187 | | - int operator()(const sycl::device &d) const |
188 | | - { |
189 | | - return _impl(d); |
190 | | - } |
| 149 | + int operator()(const sycl::device &d) const override; |
191 | 150 |
|
192 | 151 | private: |
193 | 152 | sycl::ext::oneapi::filter_selector _impl; |
194 | 153 | }; |
195 | 154 |
|
196 | | -class dpctl_host_selector : public dpctl_device_selector |
| 155 | +class DPCTL_API dpctl_host_selector : public dpctl_device_selector |
197 | 156 | { |
198 | 157 | public: |
199 | 158 | dpctl_host_selector() : _impl(){}; |
200 | | - int operator()(const sycl::device &d) const |
201 | | - { |
202 | | - return _impl(d); |
203 | | - } |
| 159 | + int operator()(const sycl::device &d) const override; |
204 | 160 |
|
205 | 161 | private: |
206 | 162 | sycl::host_selector _impl; |
|
0 commit comments