-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Let the test fail gracefully if no devies are found
If more than one device is available, run the tests on all available devices. Replace elements_with_stide with uniform_elements.
- Loading branch information
Showing
3 changed files
with
81 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,48 @@ | ||
#include <alpaka/alpaka.hpp> | ||
|
||
#include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigisDevice.h" | ||
#include "DataFormats/SiPixelDigiSoA/interface/alpaka/SiPixelDigisSoACollection.h" | ||
#include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigisHost.h" | ||
#include "HeterogeneousCore/AlpakaInterface/interface/workdivision.h" | ||
#include "DataFormats/SiPixelDigiSoA/interface/alpaka/SiPixelDigisSoACollection.h" | ||
#include "HeterogeneousCore/AlpakaInterface/interface/config.h" | ||
#include "HeterogeneousCore/AlpakaInterface/interface/traits.h" | ||
#include "HeterogeneousCore/AlpakaInterface/interface/workdivision.h" | ||
|
||
using namespace alpaka; | ||
|
||
namespace ALPAKA_ACCELERATOR_NAMESPACE { | ||
#include "Digis_test.h" | ||
|
||
using namespace cms::alpakatools; | ||
namespace testDigisSoA { | ||
namespace ALPAKA_ACCELERATOR_NAMESPACE::testDigisSoA { | ||
|
||
class TestFillKernel { | ||
public: | ||
template <typename TAcc, typename = std::enable_if_t<isAccelerator<TAcc>>> | ||
ALPAKA_FN_ACC void operator()(TAcc const& acc, SiPixelDigisSoAView digi_view) const { | ||
for (int32_t j : elements_with_stride(acc, digi_view.metadata().size())) { | ||
digi_view[j].clus() = j; | ||
digi_view[j].rawIdArr() = j * 2; | ||
digi_view[j].xx() = j * 3; | ||
digi_view[j].moduleId() = j * 4; | ||
} | ||
class TestFillKernel { | ||
public: | ||
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>> | ||
ALPAKA_FN_ACC void operator()(TAcc const& acc, SiPixelDigisSoAView digi_view) const { | ||
for (int32_t j : cms::alpakatools::uniform_elements(acc, digi_view.metadata().size())) { | ||
digi_view[j].clus() = j; | ||
digi_view[j].rawIdArr() = j * 2; | ||
digi_view[j].xx() = j * 3; | ||
digi_view[j].moduleId() = j * 4; | ||
} | ||
}; | ||
} | ||
}; | ||
|
||
class TestVerifyKernel { | ||
public: | ||
template <typename TAcc, typename = std::enable_if_t<isAccelerator<TAcc>>> | ||
ALPAKA_FN_ACC void operator()(TAcc const& acc, SiPixelDigisSoAConstView digi_view) const { | ||
for (uint32_t j : elements_with_stride(acc, digi_view.metadata().size())) { | ||
assert(digi_view[j].clus() == int(j)); | ||
assert(digi_view[j].rawIdArr() == j * 2); | ||
assert(digi_view[j].xx() == j * 3); | ||
assert(digi_view[j].moduleId() == j * 4); | ||
} | ||
class TestVerifyKernel { | ||
public: | ||
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>> | ||
ALPAKA_FN_ACC void operator()(TAcc const& acc, SiPixelDigisSoAConstView digi_view) const { | ||
for (uint32_t j : cms::alpakatools::uniform_elements(acc, digi_view.metadata().size())) { | ||
assert(digi_view[j].clus() == int(j)); | ||
assert(digi_view[j].rawIdArr() == j * 2); | ||
assert(digi_view[j].xx() == j * 3); | ||
assert(digi_view[j].moduleId() == j * 4); | ||
} | ||
}; | ||
|
||
void runKernels(SiPixelDigisSoAView digi_view, Queue& queue) { | ||
uint32_t items = 64; | ||
uint32_t groups = divide_up_by(digi_view.metadata().size(), items); | ||
auto workDiv = make_workdiv<Acc1D>(groups, items); | ||
alpaka::exec<Acc1D>(queue, workDiv, TestFillKernel{}, digi_view); | ||
alpaka::exec<Acc1D>(queue, workDiv, TestVerifyKernel{}, digi_view); | ||
} | ||
}; | ||
|
||
void runKernels(SiPixelDigisSoAView digi_view, Queue& queue) { | ||
uint32_t items = 64; | ||
uint32_t groups = cms::alpakatools::divide_up_by(digi_view.metadata().size(), items); | ||
auto workDiv = cms::alpakatools::make_workdiv<Acc1D>(groups, items); | ||
alpaka::exec<Acc1D>(queue, workDiv, TestFillKernel{}, digi_view); | ||
alpaka::exec<Acc1D>(queue, workDiv, TestVerifyKernel{}, digi_view); | ||
} | ||
|
||
} // namespace testDigisSoA | ||
} // namespace ALPAKA_ACCELERATOR_NAMESPACE | ||
} // namespace ALPAKA_ACCELERATOR_NAMESPACE::testDigisSoA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef DataFormats_SiPixelDigiSoA_test_alpaka_Digis_test_h | ||
#define DataFormats_SiPixelDigiSoA_test_alpaka_Digis_test_h | ||
|
||
#include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigisSoA.h" | ||
#include "HeterogeneousCore/AlpakaInterface/interface/config.h" | ||
|
||
namespace ALPAKA_ACCELERATOR_NAMESPACE::testDigisSoA { | ||
|
||
void runKernels(SiPixelDigisSoAView digis_view, Queue& queue); | ||
|
||
} // namespace ALPAKA_ACCELERATOR_NAMESPACE::testDigisSoA | ||
|
||
#endif // DataFormats_SiPixelDigiSoA_test_alpaka_Digis_test_h |