HeterogeneousCore
AlpakaTest
plugins
alpaka
TestAlgo.dev.cc
Go to the documentation of this file.
1
// Check that ALPAKA_HOST_ONLY is not defined during device compilation:
2
#ifdef ALPAKA_HOST_ONLY
3
#error ALPAKA_HOST_ONLY defined in device compilation
4
#endif
5
6
#include <alpaka/alpaka.hpp>
7
8
#include "
DataFormats/PortableTestObjects/interface/alpaka/TestDeviceCollection.h
"
9
#include "
HeterogeneousCore/AlpakaInterface/interface/config.h
"
10
#include "
HeterogeneousCore/AlpakaInterface/interface/traits.h
"
11
#include "
HeterogeneousCore/AlpakaInterface/interface/workdivision.h
"
12
13
#include "
TestAlgo.h
"
14
15
namespace
ALPAKA_ACCELERATOR_NAMESPACE
{
16
17
using namespace
cms::alpakatools
;
18
19
class
TestAlgoKernel
{
20
public
:
21
template
<
typename
TAcc,
typename
= std::enable_if_t<is_accelerator_v<TAcc>>>
22
ALPAKA_FN_ACC
void
operator()
(TAcc
const
& acc,
portabletest::TestDeviceCollection::View
view
, int32_t
size
)
const
{
23
// global index of the thread within the grid
24
const
int32_t thread = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc)[0u];
25
const
portabletest::Matrix
matrix
{{1, 2, 3, 4, 5, 6}, {2, 4, 6, 8, 10, 12}, {3, 6, 9, 12, 15, 18}};
26
27
// set this only once in the whole kernel grid
28
if
(thread == 0) {
29
view
.r() = 1.;
30
}
31
32
// make a strided loop over the kernel grid, covering up to "size" elements
33
for
(int32_t
i
:
elements_with_stride
(acc,
size
)) {
34
view
[
i
] = {0., 0., 0.,
i
,
matrix
*
i
};
35
}
36
}
37
};
38
39
void
TestAlgo::fill
(Queue&
queue
,
portabletest::TestDeviceCollection
&
collection
)
const
{
40
// use 64 items per group (this value is arbitrary, but it's a reasonable starting point)
41
uint32_t
items
= 64;
42
43
// use as many groups as needed to cover the whole problem
44
uint32_t groups =
divide_up_by
(
collection
->metadata().size(),
items
);
45
46
// map items to
47
// - threads with a single element per thread on a GPU backend
48
// - elements within a single thread on a CPU backend
49
auto
workDiv = make_workdiv<Acc1D>(groups,
items
);
50
51
alpaka::exec<Acc1D>(
queue
, workDiv,
TestAlgoKernel
{},
collection
.view(),
collection
->metadata().size());
52
}
53
54
}
// namespace ALPAKA_ACCELERATOR_NAMESPACE
findQualityFiles.size
size
Write out results.
Definition:
findQualityFiles.py:443
TestDeviceCollection.h
makeMuonMisalignmentScenario.matrix
list matrix
Definition:
makeMuonMisalignmentScenario.py:141
mps_fire.i
i
Definition:
mps_fire.py:429
cms::alpakatools::divide_up_by
constexpr Idx divide_up_by(Idx value, Idx divisor)
Definition:
workdivision.h:20
ALPAKA_ACCELERATOR_NAMESPACE::TestAlgo::fill
void fill(Queue &queue, portabletest::TestDeviceCollection &collection) const
Definition:
TestAlgo.dev.cc:39
portabletest::Matrix
Eigen::Matrix< double, 3, 6 > Matrix
Definition:
TestSoA.h:13
pv::view
view
Definition:
PreparePVTrends.h:58
workdivision.h
createBeamHaloJobs.queue
queue
Definition:
createBeamHaloJobs.py:343
cms::alpakatools
Definition:
PortableCollection.h:43
ALPAKA_ACCELERATOR_NAMESPACE
Definition:
PortableCollection.h:14
PortableDeviceCollection::View
typename Layout::View View
Definition:
PortableDeviceCollection.h:20
universalConfigTemplate.collection
collection
Definition:
universalConfigTemplate.py:81
ALPAKA_ACCELERATOR_NAMESPACE::TestAlgoKernel::operator()
ALPAKA_FN_ACC void operator()(TAcc const &acc, portabletest::TestDeviceCollection::View view, int32_t size) const
Definition:
TestAlgo.dev.cc:22
traits.h
mps_monitormerge.items
list items
Definition:
mps_monitormerge.py:29
cms::alpakatools::elements_with_stride
Definition:
workdivision.h:81
TestAlgo.h
PortableDeviceCollection
Definition:
PortableDeviceCollection.h:14
ALPAKA_ACCELERATOR_NAMESPACE::TestAlgoKernel
Definition:
TestAlgo.dev.cc:19
config.h
Generated for CMSSW Reference Manual by
1.8.14