DPC++ Runtime
Runtime libraries for oneAPI DPC++
sampler_impl.hpp
Go to the documentation of this file.
1 //==----------------- sampler_impl.hpp - SYCL standard header file ---------==//
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 
12 #include <sycl/context.hpp>
13 #include <sycl/detail/export.hpp>
14 #include <sycl/detail/pi.hpp>
15 #include <sycl/property_list.hpp>
16 
17 #include <mutex>
18 #include <unordered_map>
19 
20 namespace sycl {
21 inline namespace _V1 {
22 
23 enum class addressing_mode : unsigned int;
24 enum class filtering_mode : unsigned int;
25 enum class coordinate_normalization_mode : unsigned int;
26 
27 namespace detail {
28 class __SYCL_EXPORT sampler_impl {
29 public:
31  addressing_mode addressingMode, filtering_mode filteringMode,
32  const property_list &propList);
33 
34  sampler_impl(cl_sampler clSampler, const context &syclContext);
35 
36  addressing_mode get_addressing_mode() const;
37 
38  filtering_mode get_filtering_mode() const;
39 
40  coordinate_normalization_mode get_coordinate_normalization_mode() const;
41 
42  sycl::detail::pi::PiSampler getOrCreateSampler(const context &Context);
43 
47  template <typename propertyT> bool has_property() const noexcept {
48  return MPropList.has_property<propertyT>();
49  }
50 
57  template <typename propertyT> propertyT get_property() const {
58  return MPropList.get_property<propertyT>();
59  }
60 
61  ~sampler_impl();
62 
63 private:
65  std::mutex MMutex;
66 
67  std::unordered_map<context, sycl::detail::pi::PiSampler> MContextToSampler;
68 
69  coordinate_normalization_mode MCoordNormMode;
70  addressing_mode MAddrMode;
71  filtering_mode MFiltMode;
72  property_list MPropList;
73 };
74 
75 } // namespace detail
76 } // namespace _V1
77 } // namespace sycl
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:51
propertyT get_property() const
Gets the specified property of this sampler_impl.
bool has_property() const noexcept
Checks if this sampler_impl has a property of type propertyT.
Objects of the property_list class are containers for the SYCL properties.
filtering_mode
Definition: sampler.hpp:31
coordinate_normalization_mode
Definition: sampler.hpp:36
addressing_mode
Definition: sampler.hpp:23
Definition: access.hpp:18
C++ wrapper of extern "C" PI interfaces.
_Abi const simd< _Tp, _Abi > & noexcept
Definition: simd.hpp:1324