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 52 std::destroy_at(ptr +
index);
56 std::allocator<Allocator>().deallocate(ptr, size);
62 auto deleter = [size](Allocator* ptr) {
63 for (
size_t i = size;
i > 0; --
i) {
64 std::destroy_at(ptr +
i - 1);
66 std::allocator<Allocator>().deallocate(ptr, size);
69 return std::unique_ptr<Allocator[], decltype(deleter)>(ptr,
deleter);
74 template <
typename TDev,
76 typename = std::enable_if_t<alpaka::isDevice<TDev> and alpaka::isQueue<TQueue>>>
79 CMS_THREAD_SAFE static auto allocators = detail::allocate_device_allocators<TDev, TQueue>();
81 size_t const index = alpaka::getNativeHandle(device);
85 return allocators[
index];
90 #endif // HeterogeneousCore_AlpakaInterface_interface_getDeviceCachingAllocator_h
std::unique_ptr< GeometricDet > construct(DDCompactView const &cpv, std::vector< int > const &detidShifts)