alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
ViewStdArray.hpp
Go to the documentation of this file.
1
/* Copyright 2022 Axel Huebl, Benjamin Worpitz, Jan Stephan, Bernhard Manfred Gruber
2
* SPDX-License-Identifier: MPL-2.0
3
*/
4
5
/* TODO: Once C++20 is available remove this file and replace with a generic ContiguousContainer solution based on
6
* concepts. It should be sufficient to check for the existence of Container.size() and Container.data() */
7
8
#pragma once
9
10
#include "
alpaka/core/Common.hpp
"
11
#include "
alpaka/dev/DevCpu.hpp
"
12
#include "
alpaka/mem/view/Traits.hpp
"
13
#include "
alpaka/platform/PlatformCpu.hpp
"
14
15
#include <array>
16
17
namespace
alpaka::trait
18
{
19
//! The std::array device type trait specialization.
20
template
<
typename
TElem, std::
size_t
Tsize>
21
struct
DevType
<
std
::array<TElem, Tsize>>
22
{
23
using
type
=
DevCpu
;
24
};
25
26
//! The std::array device get trait specialization.
27
template
<
typename
TElem, std::
size_t
Tsize>
28
struct
GetDev
<
std
::array<TElem, Tsize>>
29
{
30
ALPAKA_FN_HOST
static
auto
getDev
(std::array<TElem, Tsize>
const
&
/* view */
) ->
DevCpu
31
{
32
// Instantiating the CPU platform here is a hack we can do internally, because we know that the CPU
33
// platform does not contain any data. But it generally does not apply.
34
return
getDevByIdx
(
PlatformCpu
{}, 0u);
35
}
36
};
37
38
//! The std::array dimension getter trait specialization.
39
template
<
typename
TElem, std::
size_t
Tsize>
40
struct
DimType
<
std
::array<TElem, Tsize>>
41
{
42
using
type
=
DimInt<1u>
;
43
};
44
45
//! The std::array memory element type get trait specialization.
46
template
<
typename
TElem, std::
size_t
Tsize>
47
struct
ElemType
<
std
::array<TElem, Tsize>>
48
{
49
using
type
= TElem;
50
};
51
52
template
<
typename
TElem, std::
size_t
Tsize>
53
struct
GetExtents
<
std
::array<TElem, Tsize>>
54
{
55
ALPAKA_FN_HOST
constexpr
auto
operator()
(std::array<TElem, Tsize>
const
& a)
56
->
Vec<DimInt<1>
,
Idx<std::array<TElem, Tsize>
>>
57
{
58
return
{std::size(a)};
59
}
60
};
61
62
//! The std::array native pointer get trait specialization.
63
template
<
typename
TElem, std::
size_t
Tsize>
64
struct
GetPtrNative
<
std
::array<TElem, Tsize>>
65
{
66
ALPAKA_FN_HOST
static
auto
getPtrNative
(std::array<TElem, Tsize>
const
& view) -> TElem
const
*
67
{
68
return
std::data(view);
69
}
70
71
ALPAKA_FN_HOST
static
auto
getPtrNative
(std::array<TElem, Tsize>& view) -> TElem*
72
{
73
return
std::data(view);
74
}
75
};
76
77
//! The std::array offset get trait specialization.
78
template
<
typename
TElem, std::
size_t
Tsize>
79
struct
GetOffsets
<
std
::array<TElem, Tsize>>
80
{
81
ALPAKA_FN_HOST
auto
operator()
(std::array<TElem, Tsize>
const
&)
82
->
Vec<DimInt<1>
,
Idx<std::array<TElem, Tsize>
>>
83
{
84
return
{0};
85
}
86
};
87
88
//! The std::vector idx type trait specialization.
89
template
<
typename
TElem, std::
size_t
Tsize>
90
struct
IdxType
<
std
::array<TElem, Tsize>>
91
{
92
using
type
= std::size_t;
93
};
94
}
// namespace alpaka::trait
DevCpu.hpp
PlatformCpu.hpp
alpaka::DevCpu
The CPU device handle.
Definition
DevCpu.hpp:56
alpaka::Vec
A n-dimensional vector.
Definition
Vec.hpp:38
Common.hpp
ALPAKA_FN_HOST
#define ALPAKA_FN_HOST
Definition
Common.hpp:40
Traits.hpp
alpaka::trait
The accelerator traits.
Definition
AccCpuOmp2Blocks.hpp:112
alpaka::Idx
typename trait::IdxType< T >::type Idx
Definition
Traits.hpp:29
alpaka::getDevByIdx
ALPAKA_FN_HOST auto getDevByIdx(TPlatform const &platform, std::size_t const &devIdx) -> Dev< TPlatform >
Definition
Traits.hpp:62
alpaka::DimInt
std::integral_constant< std::size_t, N > DimInt
Definition
DimIntegralConst.hpp:15
std
STL namespace.
alpaka::PlatformCpu
The CPU device platform.
Definition
PlatformCpu.hpp:18
alpaka::trait::DevType
The device type trait.
Definition
Traits.hpp:23
alpaka::trait::DimType< std::array< TElem, Tsize > >::type
DimInt< 1u > type
Definition
ViewStdArray.hpp:42
alpaka::trait::DimType
The dimension getter type trait.
Definition
Traits.hpp:14
alpaka::trait::ElemType< std::array< TElem, Tsize > >::type
TElem type
Definition
ViewStdArray.hpp:49
alpaka::trait::ElemType
The element type trait.
Definition
Traits.hpp:16
alpaka::trait::GetDev< std::array< TElem, Tsize > >::getDev
static ALPAKA_FN_HOST auto getDev(std::array< TElem, Tsize > const &) -> DevCpu
Definition
ViewStdArray.hpp:30
alpaka::trait::GetDev
The device get trait.
Definition
Traits.hpp:27
alpaka::trait::GetExtents< std::array< TElem, Tsize > >::operator()
ALPAKA_FN_HOST constexpr auto operator()(std::array< TElem, Tsize > const &a) -> Vec< DimInt< 1 >, Idx< std::array< TElem, Tsize > > >
Definition
ViewStdArray.hpp:55
alpaka::trait::GetExtents
The GetExtents trait for getting the extents of an object as an alpaka::Vec.
Definition
Traits.hpp:37
alpaka::trait::GetOffsets< std::array< TElem, Tsize > >::operator()
ALPAKA_FN_HOST auto operator()(std::array< TElem, Tsize > const &) -> Vec< DimInt< 1 >, Idx< std::array< TElem, Tsize > > >
Definition
ViewStdArray.hpp:81
alpaka::trait::GetOffsets
The GetOffsets trait for getting the offsets of an object as an alpaka::Vec.
Definition
Traits.hpp:33
alpaka::trait::GetPtrNative< std::array< TElem, Tsize > >::getPtrNative
static ALPAKA_FN_HOST auto getPtrNative(std::array< TElem, Tsize > &view) -> TElem *
Definition
ViewStdArray.hpp:71
alpaka::trait::GetPtrNative< std::array< TElem, Tsize > >::getPtrNative
static ALPAKA_FN_HOST auto getPtrNative(std::array< TElem, Tsize > const &view) -> TElem const *
Definition
ViewStdArray.hpp:66
alpaka::trait::GetPtrNative
The native pointer get trait.
Definition
Traits.hpp:54
alpaka::trait::IdxType< std::array< TElem, Tsize > >::type
std::size_t type
Definition
ViewStdArray.hpp:92
alpaka::trait::IdxType
The idx type trait.
Definition
Traits.hpp:25
include
alpaka
mem
view
ViewStdArray.hpp
Generated on Tue Feb 4 2025 09:02:23 for alpaka by
1.9.8