DPC++ Runtime
Runtime libraries for oneAPI Data Parallel C++
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 
12 #include <CL/sycl/detail/util.hpp>
13 #include <CL/sycl/stl.hpp>
14 
15 #include <iostream>
16 #include <map>
17 #include <vector>
18 
20 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 } // namespace sycl
51 } // __SYCL_INLINE_NAMESPACE(cl)
cl::sycl::detail::spec_constant_impl
Definition: spec_constant_impl.hpp:24
cl::sycl::detail::SerializedObj
std::vector< unsigned char > SerializedObj
Definition: util.hpp:56
stl.hpp
cl::sycl::operator<<
std::ostream & operator<<(std::ostream &Out, backend be)
Definition: backend_types.hpp:46
detail
Definition: pi_opencl.cpp:86
util.hpp
cl::sycl::detail::spec_constant_impl::isSet
bool isSet() const
Definition: spec_constant_impl.hpp:34
cl::sycl::detail::spec_constant_impl::spec_constant_impl
spec_constant_impl(size_t Size, const void *Val)
Definition: spec_constant_impl.hpp:28
cl::sycl::detail::stableSerializeSpecConstRegistry
void stableSerializeSpecConstRegistry(const SpecConstRegistryT &Reg, SerializedObj &Dst)
Definition: spec_constant_impl.cpp:30
defines.hpp
cl::sycl::detail::spec_constant_impl::getSize
size_t getSize() const
Definition: spec_constant_impl.hpp:32
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::detail::spec_constant_impl::getValuePtr
const char * getValuePtr() const
Definition: spec_constant_impl.hpp:33
cl::sycl::detail::SpecConstRegistryT
std::map< std::string, spec_constant_impl > SpecConstRegistryT
Definition: spec_constant_impl.hpp:44
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12