alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
ConstBufCpuTraits.hpp
Go to the documentation of this file.
1
/* Copyright 2022 Alexander Matthes, Axel Huebl, Benjamin Worpitz, Andrea Bocci, Jan Stephan, Bernhard Manfred Gruber,
2
* Anton Reinhard
3
* SPDX-License-Identifier: MPL-2.0
4
*/
5
#pragma once
6
7
#include "
alpaka/dev/DevCpu.hpp
"
8
#include "
alpaka/mem/buf/Traits.hpp
"
9
#include "
alpaka/mem/buf/cpu/BufCpu.hpp
"
10
#include "
alpaka/mem/buf/cpu/ConstBufCpu.hpp
"
11
12
namespace
alpaka::trait
13
{
14
//! The CPU device memory const-buffer type trait specialization.
15
template
<
typename
TElem,
typename
TDim,
typename
TIdx>
16
struct
ConstBufType
<
DevCpu
, TElem, TDim, TIdx>
17
{
18
using
type
=
ConstBufCpu<TElem, TDim, TIdx>
;
19
};
20
21
//! The ConstBufCpu device type trait specialization.
22
template
<
typename
TElem,
typename
TDim,
typename
TIdx>
23
struct
DevType
<
ConstBufCpu
<TElem, TDim, TIdx>>
24
{
25
using
type
=
DevCpu
;
26
};
27
28
//! The ConstBufCpu device get trait specialization.
29
template
<
typename
TElem,
typename
TDim,
typename
TIdx>
30
struct
GetDev
<
ConstBufCpu
<TElem, TDim, TIdx>>
31
{
32
ALPAKA_FN_HOST
static
auto
getDev
(
ConstBufCpu<TElem, TDim, TIdx>
const
& buf) ->
DevCpu
33
{
34
return
buf.m_spBufImpl->m_dev;
35
}
36
};
37
38
//! The ConstBufCpu dimension getter trait.
39
template
<
typename
TElem,
typename
TDim,
typename
TIdx>
40
struct
DimType
<
ConstBufCpu
<TElem, TDim, TIdx>>
41
{
42
using
type
= TDim;
43
};
44
45
//! The ConstBufCpu memory element type get trait specialization.
46
template
<
typename
TElem,
typename
TDim,
typename
TIdx>
47
struct
ElemType
<
ConstBufCpu
<TElem, TDim, TIdx>>
48
{
49
// const qualify the element type of the inner view
50
using
type
= TElem
const
;
51
};
52
53
//! The ConstBufCpu width get trait specialization.
54
template
<
typename
TElem,
typename
TDim,
typename
TIdx>
55
struct
GetExtents
<
ConstBufCpu
<TElem, TDim, TIdx>>
56
{
57
ALPAKA_FN_HOST
auto
operator()
(
ConstBufCpu<TElem, TDim, TIdx>
const
& buf)
58
{
59
return
buf.m_spBufImpl->m_extentElements;
60
}
61
};
62
63
//! The ConstBufCpu native pointer get trait specialization.
64
template
<
typename
TElem,
typename
TDim,
typename
TIdx>
65
struct
GetPtrNative
<
ConstBufCpu
<TElem, TDim, TIdx>>
66
{
67
ALPAKA_FN_HOST
static
auto
getPtrNative
(
ConstBufCpu<TElem, TDim, TIdx>
const
& buf) -> TElem
const
*
68
{
69
return
buf.m_spBufImpl->m_pMem;
70
}
71
};
72
73
//! The ConstBufCpu pointer on device get trait specialization.
74
template
<
typename
TElem,
typename
TDim,
typename
TIdx>
75
struct
GetPtrDev
<
ConstBufCpu
<TElem, TDim, TIdx>,
DevCpu
>
76
{
77
ALPAKA_FN_HOST
static
auto
getPtrDev
(
ConstBufCpu<TElem, TDim, TIdx>
const
& buf,
DevCpu
const
& dev)
78
-> TElem
const
*
79
{
80
if
(dev ==
getDev
(buf))
81
{
82
return
buf.m_spBufImpl->m_pMem;
83
}
84
else
85
{
86
throw
std::runtime_error(
"The buffer is not accessible from the given device!"
);
87
}
88
}
89
};
90
91
//! The ConstBufCpu offset get trait specialization.
92
template
<
typename
TElem,
typename
TDim,
typename
TIdx>
93
struct
GetOffsets
<
ConstBufCpu
<TElem, TDim, TIdx>>
94
{
95
ALPAKA_FN_HOST
auto
operator()
(
ConstBufCpu<TElem, TDim, TIdx>
const
&)
const
->
Vec<TDim, TIdx>
96
{
97
return
Vec<TDim, TIdx>::zeros
();
98
}
99
};
100
101
//! The ConstBufCpu idx type trait specialization.
102
template
<
typename
TElem,
typename
TDim,
typename
TIdx>
103
struct
IdxType
<
ConstBufCpu
<TElem, TDim, TIdx>>
104
{
105
using
type
= TIdx;
106
};
107
108
//! The MakeConstBuf trait for constant CPU buffers.
109
template
<
typename
TElem,
typename
TDim,
typename
TIdx>
110
struct
MakeConstBuf
<
ConstBufCpu
<TElem, TDim, TIdx>>
111
{
112
ALPAKA_FN_HOST
static
auto
makeConstBuf
(
ConstBufCpu<TElem, TDim, TIdx>
const
& buf)
113
->
ConstBufCpu<TElem, TDim, TIdx>
114
{
115
return
buf;
116
}
117
118
ALPAKA_FN_HOST
static
auto
makeConstBuf
(
ConstBufCpu<TElem, TDim, TIdx>
&& buf) ->
ConstBufCpu<TElem, TDim, TIdx>
119
{
120
return
buf;
121
}
122
};
123
}
// namespace alpaka::trait
BufCpu.hpp
ConstBufCpu.hpp
DevCpu.hpp
alpaka::ConstBufCpu
The CPU memory buffer.
Definition
ConstBufCpu.hpp:36
alpaka::DevCpu
The CPU device handle.
Definition
DevCpu.hpp:56
alpaka::Vec
A n-dimensional vector.
Definition
Vec.hpp:38
alpaka::Vec::zeros
ALPAKA_NO_HOST_ACC_WARNING static ALPAKA_FN_HOST_ACC constexpr auto zeros() -> Vec< TDim, TVal >
Zero value constructor.
Definition
Vec.hpp:99
ALPAKA_FN_HOST
#define ALPAKA_FN_HOST
Definition
Common.hpp:40
Traits.hpp
alpaka::trait
The accelerator traits.
Definition
AccCpuOmp2Blocks.hpp:112
alpaka::getDev
ALPAKA_FN_HOST auto getDev(T const &t)
Definition
Traits.hpp:68
alpaka::trait::ConstBufType
The memory const-buffer type trait.
Definition
Traits.hpp:27
alpaka::trait::DevType
The device type trait.
Definition
Traits.hpp:23
alpaka::trait::DimType< ConstBufCpu< TElem, TDim, TIdx > >::type
TDim type
Definition
ConstBufCpuTraits.hpp:42
alpaka::trait::DimType
The dimension getter type trait.
Definition
Traits.hpp:14
alpaka::trait::ElemType< ConstBufCpu< TElem, TDim, TIdx > >::type
TElem const type
Definition
ConstBufCpuTraits.hpp:50
alpaka::trait::ElemType
The element type trait.
Definition
Traits.hpp:16
alpaka::trait::GetDev< ConstBufCpu< TElem, TDim, TIdx > >::getDev
static ALPAKA_FN_HOST auto getDev(ConstBufCpu< TElem, TDim, TIdx > const &buf) -> DevCpu
Definition
ConstBufCpuTraits.hpp:32
alpaka::trait::GetDev
The device get trait.
Definition
Traits.hpp:27
alpaka::trait::GetExtents< ConstBufCpu< TElem, TDim, TIdx > >::operator()
ALPAKA_FN_HOST auto operator()(ConstBufCpu< TElem, TDim, TIdx > const &buf)
Definition
ConstBufCpuTraits.hpp:57
alpaka::trait::GetExtents
The GetExtents trait for getting the extents of an object as an alpaka::Vec.
Definition
Traits.hpp:37
alpaka::trait::GetOffsets< ConstBufCpu< TElem, TDim, TIdx > >::operator()
ALPAKA_FN_HOST auto operator()(ConstBufCpu< TElem, TDim, TIdx > const &) const -> Vec< TDim, TIdx >
Definition
ConstBufCpuTraits.hpp:95
alpaka::trait::GetOffsets
The GetOffsets trait for getting the offsets of an object as an alpaka::Vec.
Definition
Traits.hpp:33
alpaka::trait::GetPtrDev< ConstBufCpu< TElem, TDim, TIdx >, DevCpu >::getPtrDev
static ALPAKA_FN_HOST auto getPtrDev(ConstBufCpu< TElem, TDim, TIdx > const &buf, DevCpu const &dev) -> TElem const *
Definition
ConstBufCpuTraits.hpp:77
alpaka::trait::GetPtrDev
The pointer on device get trait.
Definition
Traits.hpp:58
alpaka::trait::GetPtrNative< ConstBufCpu< TElem, TDim, TIdx > >::getPtrNative
static ALPAKA_FN_HOST auto getPtrNative(ConstBufCpu< TElem, TDim, TIdx > const &buf) -> TElem const *
Definition
ConstBufCpuTraits.hpp:67
alpaka::trait::GetPtrNative
The native pointer get trait.
Definition
Traits.hpp:54
alpaka::trait::IdxType< ConstBufCpu< TElem, TDim, TIdx > >::type
TIdx type
Definition
ConstBufCpuTraits.hpp:105
alpaka::trait::IdxType
The idx type trait.
Definition
Traits.hpp:25
alpaka::trait::MakeConstBuf< ConstBufCpu< TElem, TDim, TIdx > >::makeConstBuf
static ALPAKA_FN_HOST auto makeConstBuf(ConstBufCpu< TElem, TDim, TIdx > const &buf) -> ConstBufCpu< TElem, TDim, TIdx >
Definition
ConstBufCpuTraits.hpp:112
alpaka::trait::MakeConstBuf< ConstBufCpu< TElem, TDim, TIdx > >::makeConstBuf
static ALPAKA_FN_HOST auto makeConstBuf(ConstBufCpu< TElem, TDim, TIdx > &&buf) -> ConstBufCpu< TElem, TDim, TIdx >
Definition
ConstBufCpuTraits.hpp:118
alpaka::trait::MakeConstBuf
The trait to transform a mutable buffer into a constant one.
Definition
Traits.hpp:55
include
alpaka
mem
buf
cpu
traits
ConstBufCpuTraits.hpp
Generated on Wed Jun 4 2025 11:30:59 for alpaka by
1.9.8