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/property_list.hpp>
15 
16 #include <unordered_map>
17 
18 namespace sycl {
20 
21 enum class addressing_mode : unsigned int;
22 enum class filtering_mode : unsigned int;
23 enum class coordinate_normalization_mode : unsigned int;
24 
25 namespace detail {
26 class __SYCL_EXPORT sampler_impl {
27 public:
29  addressing_mode addressingMode, filtering_mode filteringMode,
30  const property_list &propList);
31 
32  sampler_impl(cl_sampler clSampler, const context &syclContext);
33 
34  addressing_mode get_addressing_mode() const;
35 
36  filtering_mode get_filtering_mode() const;
37 
38  coordinate_normalization_mode get_coordinate_normalization_mode() const;
39 
40  RT::PiSampler getOrCreateSampler(const context &Context);
41 
45  template <typename propertyT> bool has_property() const noexcept {
46  return MPropList.has_property<propertyT>();
47  }
48 
55  template <typename propertyT> propertyT get_property() const {
56  return MPropList.get_property<propertyT>();
57  }
58 
59  ~sampler_impl();
60 
61 private:
63  std::mutex MMutex;
64 
65  std::unordered_map<context, RT::PiSampler> MContextToSampler;
66 
67  coordinate_normalization_mode MCoordNormMode;
68  addressing_mode MAddrMode;
69  filtering_mode MFiltMode;
70  property_list MPropList;
71 };
72 
73 } // namespace detail
74 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
75 } // namespace sycl
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:41
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.
#define __SYCL_INLINE_VER_NAMESPACE(X)
::pi_sampler PiSampler
Definition: pi.hpp:122
filtering_mode
Definition: sampler.hpp:28
coordinate_normalization_mode
Definition: sampler.hpp:33
addressing_mode
Definition: sampler.hpp:20
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14