File indexing completed on 2024-04-23 22:56:07
0001 #include <alpaka/alpaka.hpp>
0002
0003 #include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigisDevice.h"
0004 #include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigisHost.h"
0005 #include "DataFormats/SiPixelDigiSoA/interface/alpaka/SiPixelDigisSoACollection.h"
0006 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0007 #include "HeterogeneousCore/AlpakaInterface/interface/workdivision.h"
0008
0009 #include "Digis_test.h"
0010
0011 namespace ALPAKA_ACCELERATOR_NAMESPACE::testDigisSoA {
0012
0013 class TestFillKernel {
0014 public:
0015 template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
0016 ALPAKA_FN_ACC void operator()(TAcc const& acc, SiPixelDigisSoAView digi_view) const {
0017 for (int32_t j : cms::alpakatools::uniform_elements(acc, digi_view.metadata().size())) {
0018 digi_view[j].clus() = j;
0019 digi_view[j].rawIdArr() = j * 2;
0020 digi_view[j].xx() = j * 3;
0021 digi_view[j].moduleId() = j * 4;
0022 }
0023 }
0024 };
0025
0026 class TestVerifyKernel {
0027 public:
0028 template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
0029 ALPAKA_FN_ACC void operator()(TAcc const& acc, SiPixelDigisSoAConstView digi_view) const {
0030 for (uint32_t j : cms::alpakatools::uniform_elements(acc, digi_view.metadata().size())) {
0031 ALPAKA_ASSERT_ACC(digi_view[j].clus() == int(j));
0032 ALPAKA_ASSERT_ACC(digi_view[j].rawIdArr() == j * 2);
0033 ALPAKA_ASSERT_ACC(digi_view[j].xx() == j * 3);
0034 ALPAKA_ASSERT_ACC(digi_view[j].moduleId() == j * 4);
0035 }
0036 }
0037 };
0038
0039 void runKernels(SiPixelDigisSoAView digi_view, Queue& queue) {
0040 uint32_t items = 64;
0041 uint32_t groups = cms::alpakatools::divide_up_by(digi_view.metadata().size(), items);
0042 auto workDiv = cms::alpakatools::make_workdiv<Acc1D>(groups, items);
0043 alpaka::exec<Acc1D>(queue, workDiv, TestFillKernel{}, digi_view);
0044 alpaka::exec<Acc1D>(queue, workDiv, TestVerifyKernel{}, digi_view);
0045 }
0046
0047 }