DPC++ Runtime
Runtime libraries for oneAPI DPC++
free_function_queries.hpp
Go to the documentation of this file.
1 //==---- free_function_queries.hpp -- SYCL_INTEL_free_function_queries ext -==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
11 #include <sycl/group.hpp>
12 #include <sycl/nd_item.hpp>
13 #include <sycl/sub_group.hpp>
14 
15 // For deprecated queries:
16 #include <sycl/id.hpp>
17 #include <sycl/item.hpp>
18 
19 namespace sycl {
20 inline namespace _V1 {
21 namespace ext::oneapi::this_work_item {
22 template <int Dimensions> nd_item<Dimensions> get_nd_item() {
23 #ifdef __SYCL_DEVICE_ONLY__
24  return sycl::detail::Builder::getElement(
26 #else
27  throw sycl::exception(
28  sycl::make_error_code(sycl::errc::feature_not_supported),
29  "Free function calls are not supported on host");
30 #endif
31 }
32 
33 template <int Dimensions> group<Dimensions> get_work_group() {
34  return get_nd_item<Dimensions>().get_group();
35 }
36 
38 #ifdef __SYCL_DEVICE_ONLY__
39  return sycl::sub_group();
40 #else
41  throw sycl::exception(
42  sycl::make_error_code(sycl::errc::feature_not_supported),
43  "Free function calls are not supported on host");
44 #endif
45 }
46 } // namespace ext::oneapi::this_work_item
47 
48 namespace ext::oneapi::experimental {
49 template <int Dims>
51  "use sycl::ext::oneapi::this_work_item::get_nd_item() instead")
52 nd_item<Dims> this_nd_item() {
53  return ext::oneapi::this_work_item::get_nd_item<Dims>();
54 }
55 
56 template <int Dims>
58  "use sycl::ext::oneapi::this_work_item::get_work_group() instead")
59 group<Dims> this_group() {
60  return ext::oneapi::this_work_item::get_work_group<Dims>();
61 }
62 
64  "use sycl::ext::oneapi::this_work_item::get_sub_group() instead")
65 inline sycl::sub_group this_sub_group() {
67 }
68 
69 template <int Dims>
70 __SYCL_DEPRECATED("use nd_range kernel and "
71  "sycl::ext::oneapi::this_work_item::get_nd_item() instead")
72 item<Dims> this_item() {
73 #ifdef __SYCL_DEVICE_ONLY__
74  return sycl::detail::Builder::getElement(sycl::detail::declptr<item<Dims>>());
75 #else
76  throw sycl::exception(
77  sycl::make_error_code(sycl::errc::feature_not_supported),
78  "Free function calls are not supported on host");
79 #endif
80 }
81 
82 template <int Dims>
83 __SYCL_DEPRECATED("use nd_range kernel and "
84  "sycl::ext::oneapi::this_work_item::get_nd_item() instead")
85 id<Dims> this_id() {
86  return this_item<Dims>().get_id();
87 }
88 } // namespace ext::oneapi::experimental
89 } // namespace _V1
90 } // namespace sycl
A unique identifier of an item in an index space.
Definition: id.hpp:36
Identifies an instance of the function object executing at each point in a range.
Definition: item.hpp:37
Identifies an instance of the function object executing at each point in an nd_range.
Definition: nd_item.hpp:48
__SYCL_DEPRECATED("read_image for standard unsampled images is deprecated. " "Instead use fetch_image.") DataT read_image(const unsampled_image_handle &imageHandle
[Deprecated] Read an unsampled image using its handle
std::error_code make_error_code(sycl::errc E) noexcept
Constructs an error code using e and sycl_category()
Definition: exception.cpp:93
Definition: access.hpp:18