1616#include < sycl/detail/common.hpp>
1717#include < sycl/detail/defines_elementary.hpp>
1818#include < sycl/detail/export.hpp>
19+ #include < sycl/detail/id_queries_fit_in_int.hpp>
1920#include < sycl/detail/impl_utils.hpp>
2021#include < sycl/detail/kernel_desc.hpp>
2122#include < sycl/detail/reduction_forward.hpp>
@@ -227,22 +228,6 @@ __SYCL_EXPORT void *getValueFromDynamicParameter(
227228 ext::oneapi::experimental::detail::dynamic_parameter_base
228229 &DynamicParamBase);
229230
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-
246231// Helper for merging properties with ones defined in an optional kernel functor
247232// getter.
248233template <typename KernelType, typename PropertiesT, typename Cond = void >
@@ -265,70 +250,6 @@ struct GetMergedKernelProperties<
265250 PropertiesT, get_method_properties>;
266251};
267252
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-
332253template <int Dims> class RoundedRangeIDGenerator {
333254 id<Dims> Id;
334255 id<Dims> InitId;
@@ -1353,8 +1274,10 @@ class __SYCL_EXPORT handler {
13531274 // / \param Kernel is a SYCL kernel function.
13541275 // / \param Properties is the properties.
13551276 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__
13581281 throwIfActionIsCreated ();
13591282 MKernel = detail::getSyclObjImpl (std::move (Kernel));
13601283 detail::checkValueRange<Dims>(NumWorkItems);
@@ -1364,6 +1287,7 @@ class __SYCL_EXPORT handler {
13641287 setNDRangeUsed (false );
13651288 extractArgsAndReqs ();
13661289 MKernelName = getKernelName ();
1290+ #endif
13671291 }
13681292
13691293 // / Defines and invokes a SYCL kernel function for the specified range and
@@ -1376,8 +1300,10 @@ class __SYCL_EXPORT handler {
13761300 // / \param Properties is the properties.
13771301 // / \param Kernel is a SYCL kernel function.
13781302 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__
13811307 throwIfActionIsCreated ();
13821308 MKernel = detail::getSyclObjImpl (std::move (Kernel));
13831309 detail::checkValueRange<Dims>(NDRange);
@@ -1387,6 +1313,7 @@ class __SYCL_EXPORT handler {
13871313 setNDRangeUsed (true );
13881314 extractArgsAndReqs ();
13891315 MKernelName = getKernelName ();
1316+ #endif
13901317 }
13911318
13921319 // / Hierarchical kernel invocation method of a kernel defined as a lambda
@@ -2136,8 +2063,10 @@ class __SYCL_EXPORT handler {
21362063 // / \param Kernel is a SYCL kernel function.
21372064 template <int Dims>
21382065 __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__
21412070 throwIfActionIsCreated ();
21422071 MKernel = detail::getSyclObjImpl (std::move (Kernel));
21432072 detail::checkValueRange<Dims>(NumWorkItems, WorkItemOffset);
@@ -2146,6 +2075,7 @@ class __SYCL_EXPORT handler {
21462075 setNDRangeUsed (false );
21472076 extractArgsAndReqs ();
21482077 MKernelName = getKernelName ();
2078+ #endif
21492079 }
21502080
21512081 // / Defines and invokes a SYCL kernel function for the specified range and
0 commit comments