1 #ifndef HeterogeneousCore_AlpakaInterface_interface_getDeviceCachingAllocator_h 2 #define HeterogeneousCore_AlpakaInterface_interface_getDeviceCachingAllocator_h 7 #include <alpaka/alpaka.hpp> 18 template <
typename TDev,
20 typename = std::enable_if_t<alpaka::isDevice<TDev> and alpaka::isQueue<TQueue>>>
23 auto const&
devices = cms::alpakatools::devices<alpaka::Platform<TDev>>();
24 ssize_t
const size =
devices.size();
27 auto ptr = std::allocator<Allocator>().allocate(size);
33 #if __cplusplus >= 202002L 48 std::destroy_at(ptr +
index);
52 std::allocator<Allocator>().deallocate(ptr, size);
58 auto deleter = [size](Allocator* allocators) {
59 for (
size_t i = size;
i > 0; --
i) {
60 std::destroy_at(allocators +
i - 1);
62 std::allocator<Allocator>().deallocate(allocators, size);
65 return std::unique_ptr<Allocator[], decltype(deleter)>(ptr,
deleter);
70 template <
typename TDev,
72 typename = std::enable_if_t<alpaka::isDevice<TDev> and alpaka::isQueue<TQueue>>>
79 size_t const index = alpaka::getNativeHandle(device);
83 return allocators[
index];
88 #endif // HeterogeneousCore_AlpakaInterface_interface_getDeviceCachingAllocator_h
def config(tmpl, pkg_help)
std::unique_ptr< GeometricDet > construct(DDCompactView const &cpv, std::vector< int > const &detidShifts)