1 #ifndef HeterogeneousCore_AlpakaInterface_interface_getDeviceCachingAllocator_h 2 #define HeterogeneousCore_AlpakaInterface_interface_getDeviceCachingAllocator_h 7 #include <alpaka/alpaka.hpp> 19 template <
typename TDev,
21 typename = std::enable_if_t<alpaka::isDevice<TDev> and alpaka::isQueue<TQueue>>>
24 auto const&
devices = cms::alpakatools::devices<alpaka::Platform<TDev>>();
25 ssize_t
const size =
devices.size();
28 auto ptr = std::allocator<Allocator>().allocate(size);
34 #if __cplusplus >= 202002L 49 std::destroy_at(ptr +
index);
53 std::allocator<Allocator>().deallocate(ptr, size);
59 auto deleter = [size](Allocator* allocators) {
60 for (
size_t i = size;
i > 0; --
i) {
61 std::destroy_at(allocators +
i - 1);
63 std::allocator<Allocator>().deallocate(allocators, size);
66 return std::unique_ptr<Allocator[], decltype(deleter)>(ptr,
deleter);
71 template <
typename TDev,
73 typename = std::enable_if_t<alpaka::isDevice<TDev> and alpaka::isQueue<TQueue>>>
80 size_t const index = alpaka::getNativeHandle(device);
84 return allocators[
index];
89 #endif // HeterogeneousCore_AlpakaInterface_interface_getDeviceCachingAllocator_h
def config(tmpl, pkg_help)
std::unique_ptr< GeometricDet > construct(DDCompactView const &cpv, std::vector< int > const &detidShifts)