Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-20 02:31:58

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     // thread safe initialisation of the host allocator
0017     CMS_THREAD_SAFE static CachingAllocator<alpaka_common::DevHost, TQueue> allocator(
0018         host(),
0019         config::binGrowth,
0020         config::minBin,
0021         config::maxBin,
0022         config::maxCachedBytes,
0023         config::maxCachedFraction,
0024         false,   // reuseSameQueueAllocations
0025         false);  // debug
0026 
0027     // the public interface is thread safe
0028     return allocator;
0029   }
0030 
0031 }  // namespace cms::alpakatools
0032 
0033 #endif  // HeterogeneousCore_AlpakaInterface_interface_getHostCachingAllocator_h