DPC++ Runtime
Runtime libraries for oneAPI Data Parallel C++
spec_constant_impl.cpp
Go to the documentation of this file.
1 //==-- spec_constant_impl.cpp - 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 
10 
12 #include <CL/sycl/detail/pi.h>
13 #include <CL/sycl/detail/util.hpp>
14 #include <CL/sycl/exception.hpp>
15 
16 #include <cstring>
17 #include <iostream>
18 
20 namespace sycl {
21 namespace detail {
22 
23 void spec_constant_impl::set(size_t Size, const void *Val) {
24  if (0 == Size)
25  throw sycl::runtime_error("invalid spec constant size", PI_INVALID_VALUE);
26  auto *BytePtr = reinterpret_cast<const char *>(Val);
27  this->Bytes.assign(BytePtr, BytePtr + Size);
28 }
29 
31  SerializedObj &Dst) {
32  for (const auto &E : Reg) {
33  Dst.insert(Dst.end(), E.first.begin(), E.first.end());
34  const spec_constant_impl &SC = E.second;
35  Dst.insert(Dst.end(), SC.getValuePtr(), SC.getValuePtr() + SC.getSize());
36  }
37 }
38 
39 std::ostream &operator<<(std::ostream &Out, const spec_constant_impl &V) {
40  Out << "spec_constant_impl"
41  << " { Size=" << V.getSize() << " IsSet=" << V.isSet() << " Val=[";
42  std::ios_base::fmtflags FlagsSav = Out.flags();
43  Out << std::hex;
44  for (unsigned I = 0; I < V.getSize(); ++I) {
45  Out << (I == 0 ? "" : " ") << static_cast<int>(*(V.getValuePtr() + I));
46  }
47  Out << "]" << FlagsSav;
48  return Out;
49 }
50 
51 } // namespace detail
52 } // namespace sycl
53 } // __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
pi.h
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::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
PI_INVALID_VALUE
@ PI_INVALID_VALUE
Definition: pi.h:88
exception.hpp
cl::sycl::detail::spec_constant_impl::getValuePtr
const char * getValuePtr() const
Definition: spec_constant_impl.hpp:33
cl::sycl::detail::operator<<
std::ostream & operator<<(std::ostream &Out, const spec_constant_impl &V)
Definition: spec_constant_impl.cpp:39
spec_constant_impl.hpp
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