16
16
#include < sycl/detail/common.hpp>
17
17
#include < sycl/detail/defines_elementary.hpp>
18
18
#include < sycl/detail/export.hpp>
19
+ #include < sycl/detail/id_queries_fit_in_int.hpp>
19
20
#include < sycl/detail/impl_utils.hpp>
20
21
#include < sycl/detail/kernel_desc.hpp>
21
22
#include < sycl/detail/reduction_forward.hpp>
@@ -227,22 +228,6 @@ __SYCL_EXPORT void *getValueFromDynamicParameter(
227
228
ext::oneapi::experimental::detail::dynamic_parameter_base
228
229
&DynamicParamBase);
229
230
230
- #if __SYCL_ID_QUERIES_FIT_IN_INT__
231
- template <typename T> struct NotIntMsg ;
232
-
233
- template <int Dims> struct NotIntMsg <range<Dims>> {
234
- constexpr static const char *Msg =
235
- " Provided range is out of integer limits. Pass "
236
- " `-fno-sycl-id-queries-fit-in-int' to disable range check." ;
237
- };
238
-
239
- template <int Dims> struct NotIntMsg <id<Dims>> {
240
- constexpr static const char *Msg =
241
- " Provided offset is out of integer limits. Pass "
242
- " `-fno-sycl-id-queries-fit-in-int' to disable offset check." ;
243
- };
244
- #endif
245
-
246
231
// Helper for merging properties with ones defined in an optional kernel functor
247
232
// getter.
248
233
template <typename KernelType, typename PropertiesT, typename Cond = void >
@@ -265,70 +250,6 @@ struct GetMergedKernelProperties<
265
250
PropertiesT, get_method_properties>;
266
251
};
267
252
268
- #if __SYCL_ID_QUERIES_FIT_IN_INT__
269
- template <typename T, typename ValT>
270
- typename std::enable_if_t <std::is_same<ValT, size_t >::value ||
271
- std::is_same<ValT, unsigned long long >::value>
272
- checkValueRangeImpl (ValT V) {
273
- static constexpr size_t Limit =
274
- static_cast <size_t >((std::numeric_limits<int >::max)());
275
- if (V > Limit)
276
- throw sycl::exception (make_error_code (errc::nd_range), NotIntMsg<T>::Msg);
277
- }
278
- #endif
279
-
280
- template <int Dims, typename T>
281
- typename std::enable_if_t <std::is_same_v<T, range<Dims>> ||
282
- std::is_same_v<T, id<Dims>>>
283
- checkValueRange (const T &V) {
284
- #if __SYCL_ID_QUERIES_FIT_IN_INT__
285
- for (size_t Dim = 0 ; Dim < Dims; ++Dim)
286
- checkValueRangeImpl<T>(V[Dim]);
287
-
288
- {
289
- unsigned long long Product = 1 ;
290
- for (size_t Dim = 0 ; Dim < Dims; ++Dim) {
291
- Product *= V[Dim];
292
- // check value now to prevent product overflow in the end
293
- checkValueRangeImpl<T>(Product);
294
- }
295
- }
296
- #else
297
- (void )V;
298
- #endif
299
- }
300
-
301
- template <int Dims>
302
- void checkValueRange (const range<Dims> &R, const id<Dims> &O) {
303
- #if __SYCL_ID_QUERIES_FIT_IN_INT__
304
- checkValueRange<Dims>(R);
305
- checkValueRange<Dims>(O);
306
-
307
- for (size_t Dim = 0 ; Dim < Dims; ++Dim) {
308
- unsigned long long Sum = R[Dim] + O[Dim];
309
-
310
- checkValueRangeImpl<range<Dims>>(Sum);
311
- }
312
- #else
313
- (void )R;
314
- (void )O;
315
- #endif
316
- }
317
-
318
- template <int Dims, typename T>
319
- typename std::enable_if_t <std::is_same_v<T, nd_range<Dims>>>
320
- checkValueRange (const T &V) {
321
- #if __SYCL_ID_QUERIES_FIT_IN_INT__
322
- checkValueRange<Dims>(V.get_global_range ());
323
- checkValueRange<Dims>(V.get_local_range ());
324
- checkValueRange<Dims>(V.get_offset ());
325
-
326
- checkValueRange<Dims>(V.get_global_range (), V.get_offset ());
327
- #else
328
- (void )V;
329
- #endif
330
- }
331
-
332
253
template <int Dims> class RoundedRangeIDGenerator {
333
254
id<Dims> Id;
334
255
id<Dims> InitId;
@@ -1353,8 +1274,10 @@ class __SYCL_EXPORT handler {
1353
1274
// / \param Kernel is a SYCL kernel function.
1354
1275
// / \param Properties is the properties.
1355
1276
template <int Dims, typename PropertiesT>
1356
- void parallel_for_impl (range<Dims> NumWorkItems, PropertiesT Props,
1357
- kernel Kernel) {
1277
+ void parallel_for_impl ([[maybe_unused]] range<Dims> NumWorkItems,
1278
+ [[maybe_unused]] PropertiesT Props,
1279
+ [[maybe_unused]] kernel Kernel) {
1280
+ #ifndef __SYCL_DEVICE_ONLY__
1358
1281
throwIfActionIsCreated ();
1359
1282
MKernel = detail::getSyclObjImpl (std::move (Kernel));
1360
1283
detail::checkValueRange<Dims>(NumWorkItems);
@@ -1364,6 +1287,7 @@ class __SYCL_EXPORT handler {
1364
1287
setNDRangeUsed (false );
1365
1288
extractArgsAndReqs ();
1366
1289
MKernelName = getKernelName ();
1290
+ #endif
1367
1291
}
1368
1292
1369
1293
// / Defines and invokes a SYCL kernel function for the specified range and
@@ -1376,8 +1300,10 @@ class __SYCL_EXPORT handler {
1376
1300
// / \param Properties is the properties.
1377
1301
// / \param Kernel is a SYCL kernel function.
1378
1302
template <int Dims, typename PropertiesT>
1379
- void parallel_for_impl (nd_range<Dims> NDRange, PropertiesT Props,
1380
- kernel Kernel) {
1303
+ void parallel_for_impl ([[maybe_unused]] nd_range<Dims> NDRange,
1304
+ [[maybe_unused]] PropertiesT Props,
1305
+ [[maybe_unused]] kernel Kernel) {
1306
+ #ifndef __SYCL_DEVICE_ONLY__
1381
1307
throwIfActionIsCreated ();
1382
1308
MKernel = detail::getSyclObjImpl (std::move (Kernel));
1383
1309
detail::checkValueRange<Dims>(NDRange);
@@ -1387,6 +1313,7 @@ class __SYCL_EXPORT handler {
1387
1313
setNDRangeUsed (true );
1388
1314
extractArgsAndReqs ();
1389
1315
MKernelName = getKernelName ();
1316
+ #endif
1390
1317
}
1391
1318
1392
1319
// / Hierarchical kernel invocation method of a kernel defined as a lambda
@@ -2136,8 +2063,10 @@ class __SYCL_EXPORT handler {
2136
2063
// / \param Kernel is a SYCL kernel function.
2137
2064
template <int Dims>
2138
2065
__SYCL2020_DEPRECATED (" offsets are deprecated in SYCL 2020" )
2139
- void parallel_for(range<Dims> NumWorkItems, id<Dims> WorkItemOffset,
2140
- kernel Kernel) {
2066
+ void parallel_for([[maybe_unused]] range<Dims> NumWorkItems,
2067
+ [[maybe_unused]] id<Dims> WorkItemOffset,
2068
+ [[maybe_unused]] kernel Kernel) {
2069
+ #ifndef __SYCL_DEVICE_ONLY__
2141
2070
throwIfActionIsCreated ();
2142
2071
MKernel = detail::getSyclObjImpl (std::move (Kernel));
2143
2072
detail::checkValueRange<Dims>(NumWorkItems, WorkItemOffset);
@@ -2146,6 +2075,7 @@ class __SYCL_EXPORT handler {
2146
2075
setNDRangeUsed (false );
2147
2076
extractArgsAndReqs ();
2148
2077
MKernelName = getKernelName ();
2078
+ #endif
2149
2079
}
2150
2080
2151
2081
// / Defines and invokes a SYCL kernel function for the specified range and
0 commit comments