DPC++ Runtime
Runtime libraries for oneAPI DPC++
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
9
#include <
detail/spec_constant_impl.hpp
>
10
11
#include <
sycl/detail/defines.hpp
>
12
#include <
sycl/detail/iostream_proxy.hpp
>
13
#include <
sycl/detail/pi.h
>
14
#include <
sycl/detail/util.hpp
>
15
#include <
sycl/exception.hpp
>
16
17
#include <cstring>
18
19
namespace
sycl
{
20
__SYCL_INLINE_VER_NAMESPACE
(_V1) {
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"
,
26
PI_ERROR_INVALID_VALUE);
27
auto
*BytePtr =
reinterpret_cast<
const
char
*
>
(Val);
28
this->Bytes.assign(BytePtr, BytePtr + Size);
29
}
30
31
void
stableSerializeSpecConstRegistry
(
const
SpecConstRegistryT
&Reg,
32
SerializedObj
&Dst) {
33
for
(
const
auto
&E : Reg) {
34
Dst.insert(Dst.end(), E.first.begin(), E.first.end());
35
const
spec_constant_impl
&SC = E.second;
36
Dst.insert(Dst.end(), SC.
getValuePtr
(), SC.
getValuePtr
() + SC.
getSize
());
37
}
38
}
39
40
std::ostream &
operator<<
(std::ostream &Out,
const
spec_constant_impl
&V) {
41
Out <<
"spec_constant_impl"
42
<<
" { Size="
<< V.
getSize
() <<
" IsSet="
<< V.
isSet
() <<
" Val=["
;
43
std::ios_base::fmtflags FlagsSav = Out.flags();
44
Out << std::hex;
45
for
(
unsigned
I = 0; I < V.
getSize
(); ++I) {
46
Out << (I == 0 ?
""
:
" "
) <<
static_cast<
int
>
(*(V.
getValuePtr
() + I));
47
}
48
Out <<
"]"
<< FlagsSav;
49
return
Out;
50
}
51
52
}
// namespace detail
53
}
// __SYCL_INLINE_VER_NAMESPACE(_V1)
54
}
// namespace sycl
pi.h
sycl::_V1::detail::spec_constant_impl::getSize
size_t getSize() const
Definition:
spec_constant_impl.hpp:32
sycl::_V1::detail::stableSerializeSpecConstRegistry
void stableSerializeSpecConstRegistry(const SpecConstRegistryT &Reg, SerializedObj &Dst)
Definition:
spec_constant_impl.cpp:31
__SYCL_INLINE_VER_NAMESPACE
#define __SYCL_INLINE_VER_NAMESPACE(X)
Definition:
defines_elementary.hpp:11
sycl::_V1::detail::SpecConstRegistryT
std::map< std::string, spec_constant_impl > SpecConstRegistryT
Definition:
spec_constant_impl.hpp:44
sycl
---— Error handling, matching OpenCL plugin semantics.
Definition:
access.hpp:14
sycl::_V1::detail::spec_constant_impl::getValuePtr
const char * getValuePtr() const
Definition:
spec_constant_impl.hpp:33
sycl::_V1::detail::spec_constant_impl
Definition:
spec_constant_impl.hpp:24
defines.hpp
sycl::_V1::detail::operator<<
std::ostream & operator<<(std::ostream &Out, const spec_constant_impl &V)
Definition:
spec_constant_impl.cpp:40
iostream_proxy.hpp
exception.hpp
util.hpp
sycl::_V1::detail::SerializedObj
std::vector< unsigned char > SerializedObj
Definition:
util.hpp:68
spec_constant_impl.hpp
sycl::_V1::detail::spec_constant_impl::isSet
bool isSet() const
Definition:
spec_constant_impl.hpp:34
source
detail
spec_constant_impl.cpp
Generated by
1.8.17