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 
15 #include <map>
16 #include <vector>
17 
18 namespace sycl {
19 inline namespace _V1 {
20 namespace detail {
21 
22 // Represents a specialization constant value in SYCL runtime.
24 public:
25  spec_constant_impl() = default;
26 
27  spec_constant_impl(size_t Size, const void *Val) { set(Size, Val); }
28 
29  void set(size_t Size, const void *Val);
30 
31  size_t getSize() const { return Bytes.size(); }
32  const char *getValuePtr() const { return Bytes.data(); }
33  bool isSet() const { return !Bytes.empty(); }
34 
35 private:
36  std::vector<char> Bytes;
37 };
38 
39 std::ostream &operator<<(std::ostream &Out, const spec_constant_impl &V);
40 
41 // Used to define specialization constant registry. Must be ordered map, since
42 // the order of entries matters in stableSerializeSpecConstRegistry.
43 using SpecConstRegistryT = std::map<std::string, spec_constant_impl>;
44 
46  SerializedObj &Dst);
47 
48 } // namespace detail
49 } // namespace _V1
50 } // namespace sycl
void set(size_t Size, const void *Val)
spec_constant_impl(size_t Size, const void *Val)
std::map< std::string, spec_constant_impl > SpecConstRegistryT
void stableSerializeSpecConstRegistry(const SpecConstRegistryT &Reg, SerializedObj &Dst)
std::ostream & operator<<(std::ostream &os, std::optional< T > const &opt)
std::vector< unsigned char > SerializedObj
Definition: util.hpp:69
Definition: access.hpp:18