Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-07-02 00:53:48

0001 #ifndef HeterogeneousCore_AlpakaInterface_interface_getHostCachingAllocator_h
0002 #define HeterogeneousCore_AlpakaInterface_interface_getHostCachingAllocator_h
0003 
0004 #include <alpaka/alpaka.hpp>
0005 
0006 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0007 #include "HeterogeneousCore/AlpakaInterface/interface/AllocatorConfig.h"
0008 #include "HeterogeneousCore/AlpakaInterface/interface/CachingAllocator.h"
0009 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0010 #include "HeterogeneousCore/AlpakaInterface/interface/host.h"
0011 
0012 namespace cms::alpakatools {
0013 
0014   template <typename TQueue, typename = std::enable_if_t<alpaka::isQueue<TQueue>>>
0015   inline CachingAllocator<alpaka_common::DevHost, TQueue>& getHostCachingAllocator(
0016       AllocatorConfig const& config = AllocatorConfig{}, bool debug = false) {
0017     // thread safe initialisation of the host allocator
0018     CMS_THREAD_SAFE static CachingAllocator<alpaka_common::DevHost, TQueue> allocator(
0019         host(),
0020         config,
0021         false,  // reuseSameQueueAllocations
0022         debug);
0023 
0024     // the public interface is thread safe
0025     return allocator;
0026   }
0027 
0028 }  // namespace cms::alpakatools
0029 
0030 #endif  // HeterogeneousCore_AlpakaInterface_interface_getHostCachingAllocator_h