DPC++ Runtime
Runtime libraries for oneAPI DPC++
spec_constant_impl.hpp
Go to the documentation of this file.
1 //==-- spec_constant_impl.hpp - SYCL RT model for specialization constants -==//
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/detail/defines.hpp>
13 #include <sycl/detail/util.hpp>
14 #include <sycl/stl.hpp>
15 
16 #include <map>
17 #include <vector>
18 
19 namespace sycl {
21 namespace detail {
22 
23 // Represents a specialization constant value in SYCL runtime.
25 public:
26  spec_constant_impl() = default;
27 
28  spec_constant_impl(size_t Size, const void *Val) { set(Size, Val); }
29 
30  void set(size_t Size, const void *Val);
31 
32  size_t getSize() const { return Bytes.size(); }
33  const char *getValuePtr() const { return Bytes.data(); }
34  bool isSet() const { return !Bytes.empty(); }
35 
36 private:
37  std::vector<char> Bytes;
38 };
39 
40 std::ostream &operator<<(std::ostream &Out, const spec_constant_impl &V);
41 
42 // Used to define specialization constant registry. Must be ordered map, since
43 // the order of entries matters in stableSerializeSpecConstRegistry.
44 using SpecConstRegistryT = std::map<std::string, spec_constant_impl>;
45 
47  SerializedObj &Dst);
48 
49 } // namespace detail
50 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
51 } // namespace sycl
spec_constant_impl(size_t Size, const void *Val)
#define __SYCL_INLINE_VER_NAMESPACE(X)
std::map< std::string, spec_constant_impl > SpecConstRegistryT
void stableSerializeSpecConstRegistry(const SpecConstRegistryT &Reg, SerializedObj &Dst)
std::vector< unsigned char > SerializedObj
Definition: util.hpp:68
std::ostream & operator<<(std::ostream &Out, backend be)
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14