CMS 3D CMS Logo

Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
cms::alpakatools Namespace Reference

Namespaces

 config
 
 detail
 
 impl
 
 traits
 

Classes

class  CachingAllocator
 
struct  CopyToDevice
 
struct  CopyToDevice< cms::alpakatest::AlpakaESTestDataB< alpaka_common::DevHost > >
 
struct  CopyToDevice< PortableHostCollection< TLayout > >
 
struct  CopyToHost
 
struct  CopyToHost< PortableDeviceCollection< TLayout, TDevice > >
 
class  elements_with_stride
 
class  elements_with_stride_nd
 
class  EventCache
 
class  QueueCache
 
struct  requires_single_thread_per_block
 
class  ScopedContextAcquire
 
class  ScopedContextAnalyze
 
class  ScopedContextProduce
 
class  ScopedContextTask
 

Typedefs

template<typename TDev , typename T , typename = std::enable_if_t<alpaka::isDevice<TDev>>>
using const_device_buffer = alpaka::ViewConst< device_buffer< TDev, T > >
 
template<typename T >
using const_host_buffer = alpaka::ViewConst< host_buffer< T > >
 
template<typename TDev , typename T , typename = std::enable_if_t<alpaka::isDevice<TDev>>>
using device_buffer = typename detail::buffer_type< TDev, T >::type
 
template<typename TDev , typename T , typename = std::enable_if_t<alpaka::isDevice<TDev>>>
using device_view = typename detail::view_type< TDev, T >::type
 
template<typename T >
using host_buffer = typename detail::buffer_type< DevHost, T >::type
 
template<typename T >
using host_view = typename detail::view_type< DevHost, T >::type
 

Enumerations

enum  AllocatorPolicy { AllocatorPolicy::Synchronous = 0, AllocatorPolicy::Asynchronous = 1, AllocatorPolicy::Caching = 2 }
 

Functions

template<typename TElem , typename TIdx , typename TExtent , typename TQueue , typename TDev , typename = std::enable_if_t<alpaka::isDevice<TDev> and alpaka::isQueue<TQueue>>>
ALPAKA_FN_HOST auto allocCachedBuf (TDev const &dev, TQueue queue, TExtent const &extent=TExtent())
 
template<typename TPlatform , typename = std::enable_if_t<alpaka::isPlatform<TPlatform>>>
alpaka::Dev< TPlatform > const & chooseDevice (edm::StreamID id)
 
template<typename TPlatform , typename = std::enable_if_t<alpaka::isPlatform<TPlatform>>>
std::vector< alpaka::Dev< TPlatform > > const & devices ()
 
constexpr Idx divide_up_by (Idx value, Idx divisor)
 
template<typename TDev , typename TQueue , typename = std::enable_if_t<alpaka::isDevice<TDev> and alpaka::isQueue<TQueue>>>
CachingAllocator< TDev, TQueue > & getDeviceCachingAllocator (TDev const &device)
 
template<typename Event >
EventCache< Event > & getEventCache ()
 
template<typename TQueue , typename = std::enable_if_t<alpaka::isQueue<TQueue>>>
CachingAllocator< alpaka_common::DevHost, TQueue > & getHostCachingAllocator ()
 
template<typename Queue >
QueueCache< Queue > & getQueueCache ()
 
alpaka::DevCpu const & host ()
 
template<typename T , typename TDev >
std::enable_if_t< alpaka::isDevice< TDev > and not std::is_array_v< T >, device_buffer< TDev, T > > make_device_buffer (TDev const &device)
 
template<typename T , typename TDev >
std::enable_if_t< alpaka::isDevice< TDev > and cms::is_unbounded_array_v< T > and not std::is_array_v< std::remove_extent_t< T > >, device_buffer< TDev, T > > make_device_buffer (TDev const &device, Extent extent)
 
template<typename T , typename TDev >
std::enable_if_t< alpaka::isDevice< TDev > and cms::is_bounded_array_v< T > and not std::is_array_v< std::remove_extent_t< T > >, device_buffer< TDev, T > > make_device_buffer (TDev const &device)
 
template<typename T , typename TQueue >
std::enable_if_t< alpaka::isQueue< TQueue > and not std::is_array_v< T >, device_buffer< alpaka::Dev< TQueue >, T > > make_device_buffer (TQueue const &queue)
 
template<typename T , typename TQueue >
std::enable_if_t< alpaka::isQueue< TQueue > and cms::is_unbounded_array_v< T > and not std::is_array_v< std::remove_extent_t< T > >, device_buffer< alpaka::Dev< TQueue >, T > > make_device_buffer (TQueue const &queue, Extent extent)
 
template<typename T , typename TQueue >
std::enable_if_t< alpaka::isQueue< TQueue > and cms::is_bounded_array_v< T > and not std::is_array_v< std::remove_extent_t< T > >, device_buffer< alpaka::Dev< TQueue >, T > > make_device_buffer (TQueue const &queue)
 
template<typename T , typename TDev >
std::enable_if_t< not std::is_array_v< T >, device_view< TDev, T > > make_device_view (TDev const &device, T &data)
 
template<typename T , typename TDev >
device_view< TDev, T[]> make_device_view (TDev const &device, T *data, Extent extent)
 
template<typename T , typename TDev >
std::enable_if_t< cms::is_unbounded_array_v< T > and not std::is_array_v< std::remove_extent_t< T > >, device_view< TDev, T > > make_device_view (TDev const &device, T &data, Extent extent)
 
template<typename T , typename TDev >
std::enable_if_t< cms::is_bounded_array_v< T > and not std::is_array_v< std::remove_extent_t< T > >, device_view< TDev, T > > make_device_view (TDev const &device, T &data)
 
template<typename T >
std::enable_if_t< not std::is_array_v< T >, host_buffer< T > > make_host_buffer ()
 
template<typename T >
std::enable_if_t< cms::is_unbounded_array_v< T > and not std::is_array_v< std::remove_extent_t< T > >, host_buffer< T > > make_host_buffer (Extent extent)
 
template<typename T >
std::enable_if_t< cms::is_bounded_array_v< T > and not std::is_array_v< std::remove_extent_t< T > >, host_buffer< T > > make_host_buffer ()
 
template<typename T , typename TPlatform >
std::enable_if_t< not std::is_array_v< T >, host_buffer< T > > make_host_buffer ()
 
template<typename T , typename TPlatform >
std::enable_if_t< cms::is_unbounded_array_v< T > and not std::is_array_v< std::remove_extent_t< T > >, host_buffer< T > > make_host_buffer (Extent extent)
 
template<typename T , typename TPlatform >
std::enable_if_t< cms::is_bounded_array_v< T > and not std::is_array_v< std::remove_extent_t< T > >, host_buffer< T > > make_host_buffer ()
 
template<typename T , typename TQueue >
std::enable_if_t< alpaka::isQueue< TQueue > and not std::is_array_v< T >, host_buffer< T > > make_host_buffer (TQueue const &queue)
 
template<typename T , typename TQueue >
std::enable_if_t< alpaka::isQueue< TQueue > and cms::is_unbounded_array_v< T > and not std::is_array_v< std::remove_extent_t< T > >, host_buffer< T > > make_host_buffer (TQueue const &queue, Extent extent)
 
template<typename T , typename TQueue >
std::enable_if_t< alpaka::isQueue< TQueue > and cms::is_bounded_array_v< T > and not std::is_array_v< std::remove_extent_t< T > >, host_buffer< T > > make_host_buffer (TQueue const &queue)
 
template<typename T >
std::enable_if_t< not std::is_array_v< T >, host_view< T > > make_host_view (T &data)
 
template<typename T >
host_view< T[]> make_host_view (T *data, Extent extent)
 
template<typename T >
std::enable_if_t< cms::is_unbounded_array_v< T > and not std::is_array_v< std::remove_extent_t< T > >, host_view< T > > make_host_view (T &data, Extent extent)
 
template<typename T >
std::enable_if_t< cms::is_bounded_array_v< T > and not std::is_array_v< std::remove_extent_t< T > >, host_view< T > > make_host_view (T &data)
 
template<typename TAcc , typename = std::enable_if_t<alpaka::isAccelerator<TAcc> and alpaka::Dim<TAcc>::value == 1>>
WorkDiv< Dim1Dmake_workdiv (Idx blocks, Idx elements)
 
template<typename TAcc , typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
WorkDiv< alpaka::Dim< TAcc > > make_workdiv (const Vec< alpaka::Dim< TAcc >> &blocks, const Vec< alpaka::Dim< TAcc >> &elements)
 
void module_backend_config (edm::ConfigurationDescriptions &iDesc)
 
constexpr Idx round_up_by (Idx value, Idx divisor)
 

Variables

template<typename TDev , typename = std::enable_if_t<alpaka::isDevice<TDev>>>
constexpr AllocatorPolicy allocator_policy = AllocatorPolicy::Synchronous
 
template<typename TAcc , typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
constexpr bool requires_single_thread_per_block_v = requires_single_thread_per_block<TAcc>::value
 

Typedef Documentation

◆ const_device_buffer

template<typename TDev , typename T , typename = std::enable_if_t<alpaka::isDevice<TDev>>>
using cms::alpakatools::const_device_buffer = typedef alpaka::ViewConst<device_buffer<TDev, T> >

Definition at line 172 of file memory.h.

◆ const_host_buffer

template<typename T >
using cms::alpakatools::const_host_buffer = typedef alpaka::ViewConst<host_buffer<T> >

Definition at line 59 of file memory.h.

◆ device_buffer

template<typename TDev , typename T , typename = std::enable_if_t<alpaka::isDevice<TDev>>>
using cms::alpakatools::device_buffer = typedef typename detail::buffer_type<TDev, T>::type

Definition at line 169 of file memory.h.

◆ device_view

template<typename TDev , typename T , typename = std::enable_if_t<alpaka::isDevice<TDev>>>
using cms::alpakatools::device_view = typedef typename detail::view_type<TDev, T>::type

Definition at line 249 of file memory.h.

◆ host_buffer

template<typename T >
using cms::alpakatools::host_buffer = typedef typename detail::buffer_type<DevHost, T>::type

Definition at line 56 of file memory.h.

◆ host_view

template<typename T >
using cms::alpakatools::host_view = typedef typename detail::view_type<DevHost, T>::type

Definition at line 142 of file memory.h.

Enumeration Type Documentation

◆ AllocatorPolicy

Function Documentation

◆ allocCachedBuf()

template<typename TElem , typename TIdx , typename TExtent , typename TQueue , typename TDev , typename = std::enable_if_t<alpaka::isDevice<TDev> and alpaka::isQueue<TQueue>>>
ALPAKA_FN_HOST auto cms::alpakatools::allocCachedBuf ( TDev const &  dev,
TQueue  queue,
TExtent const &  extent = TExtent() 
)

Definition at line 197 of file CachedBufAlloc.h.

References createBeamHaloJobs::queue.

197  {
198  return traits::CachedBufAlloc<TElem, alpaka::Dim<TExtent>, TIdx, TDev, TQueue>::allocCachedBuf(dev, queue, extent);
199  }
ALPAKA_FN_HOST auto allocCachedBuf(TDev const &dev, TQueue queue, TExtent const &extent=TExtent())

◆ chooseDevice()

template<typename TPlatform , typename = std::enable_if_t<alpaka::isPlatform<TPlatform>>>
alpaka::Dev<TPlatform> const& cms::alpakatools::chooseDevice ( edm::StreamID  id)

Definition at line 16 of file chooseDevice.h.

References cms::Exception::addContext(), and devices().

16  {
18  if (not service->enabled()) {
19  cms::Exception ex("RuntimeError");
20  ex << "Unable to choose current device because " << ALPAKA_TYPE_ALIAS_NAME(AlpakaService) << " is disabled.\n"
21  << "If " << ALPAKA_TYPE_ALIAS_NAME(AlpakaService) << " was not explicitly disabled in the configuration,\n"
22  << "the probable cause is that there is no accelerator or there is some problem\n"
23  << "with the accelerator runtime or drivers.";
24  ex.addContext("Calling cms::alpakatools::chooseDevice()");
25  throw ex;
26  }
27 
28  // For startes we "statically" assign the device based on
29  // edm::Stream number. This is suboptimal if the number of
30  // edm::Streams is not a multiple of the number of devices
31  // (and even then there is no load balancing).
32 
33  // TODO: improve the "assignment" logic
34  auto const& devices = cms::alpakatools::devices<TPlatform>();
35  return devices[id % devices.size()];
36  }
std::vector< alpaka::Dev< TPlatform > > const & devices()
Definition: devices.h:35

◆ devices()

template<typename TPlatform , typename = std::enable_if_t<alpaka::isPlatform<TPlatform>>>
std::vector<alpaka::Dev<TPlatform> > const& cms::alpakatools::devices ( )
inline

◆ divide_up_by()

constexpr Idx cms::alpakatools::divide_up_by ( Idx  value,
Idx  divisor 
)
inline

Definition at line 19 of file workdivision.h.

Referenced by ALPAKA_ACCELERATOR_NAMESPACE::TestAlgo::fill().

19 { return (value + divisor - 1) / divisor; }
Definition: value.py:1

◆ getDeviceCachingAllocator()

template<typename TDev , typename TQueue , typename = std::enable_if_t<alpaka::isDevice<TDev> and alpaka::isQueue<TQueue>>>
CachingAllocator<TDev, TQueue>& cms::alpakatools::getDeviceCachingAllocator ( TDev const &  device)
inline

Definition at line 78 of file getDeviceCachingAllocator.h.

References cms::cuda::assert(), CMS_THREAD_SAFE, devices(), and findQualityFiles::size.

78  {
79  // initialise all allocators, one per device
80  CMS_THREAD_SAFE static auto allocators = detail::allocate_device_allocators<TDev, TQueue>();
81 
82  size_t const index = alpaka::getNativeHandle(device);
83  assert(index < cms::alpakatools::devices<alpaka::Pltf<TDev>>().size());
84 
85  // the public interface is thread safe
86  return allocators[index];
87  }
size
Write out results.
assert(be >=bs)
#define CMS_THREAD_SAFE
std::vector< alpaka::Dev< TPlatform > > const & devices()
Definition: devices.h:35

◆ getEventCache()

template<typename Event >
EventCache<Event>& cms::alpakatools::getEventCache ( )

Definition at line 91 of file EventCache.h.

References utilities::cache(), and CMS_THREAD_SAFE.

91  {
92  // the public interface is thread safe
93  CMS_THREAD_SAFE static EventCache<Event> cache;
94  return cache;
95  }
#define CMS_THREAD_SAFE
def cache(function)
Definition: utilities.py:3

◆ getHostCachingAllocator()

template<typename TQueue , typename = std::enable_if_t<alpaka::isQueue<TQueue>>>
CachingAllocator<alpaka_common::DevHost, TQueue>& cms::alpakatools::getHostCachingAllocator ( )
inline

Definition at line 16 of file getHostCachingAllocator.h.

References cms::alpakatools::config::binGrowth, CMS_THREAD_SAFE, host(), cms::alpakatools::config::maxBin, cms::alpakatools::config::maxCachedBytes, cms::alpakatools::config::maxCachedFraction, and cms::alpakatools::config::minBin.

16  {
17  // thread safe initialisation of the host allocator
18  CMS_THREAD_SAFE static CachingAllocator<alpaka_common::DevHost, TQueue> allocator(
19  host(),
25  false, // reuseSameQueueAllocations
26  false); // debug
27 
28  // the public interface is thread safe
29  return allocator;
30  }
string host
Definition: query.py:115
constexpr unsigned int minBin
constexpr unsigned int maxBin
constexpr double maxCachedFraction
#define CMS_THREAD_SAFE
constexpr size_t maxCachedBytes
constexpr unsigned int binGrowth

◆ getQueueCache()

template<typename Queue >
QueueCache<Queue>& cms::alpakatools::getQueueCache ( )

Definition at line 64 of file QueueCache.h.

References utilities::cache(), and CMS_THREAD_SAFE.

64  {
65  // the public interface is thread safe
66  CMS_THREAD_SAFE static QueueCache<Queue> cache;
67  return cache;
68  }
#define CMS_THREAD_SAFE
def cache(function)
Definition: utilities.py:3

◆ host()

alpaka::DevCpu const& cms::alpakatools::host ( )
inline

◆ make_device_buffer() [1/6]

template<typename T , typename TDev >
std::enable_if_t<alpaka::isDevice<TDev> and not std::is_array_v<T>, device_buffer<TDev, T> > cms::alpakatools::make_device_buffer ( TDev const &  device)

Definition at line 177 of file memory.h.

178  {
179  return alpaka::allocBuf<T, Idx>(device, Scalar{});
180  }
Vec< Dim0D > Scalar
Definition: config.h:27

◆ make_device_buffer() [2/6]

template<typename T , typename TDev >
std::enable_if_t<alpaka::isDevice<TDev> and cms::is_unbounded_array_v<T> and not std::is_array_v<std::remove_extent_t<T> >, device_buffer<TDev, T> > cms::alpakatools::make_device_buffer ( TDev const &  device,
Extent  extent 
)

Definition at line 186 of file memory.h.

186  {
187  return alpaka::allocBuf<std::remove_extent_t<T>, Idx>(device, Vec1D{extent});
188  }
Vec< Dim1D > Vec1D
Definition: config.h:24
uint32_t Idx
Definition: config.h:13

◆ make_device_buffer() [3/6]

template<typename T , typename TDev >
std::enable_if_t<alpaka::isDevice<TDev> and cms::is_bounded_array_v<T> and not std::is_array_v<std::remove_extent_t<T> >, device_buffer<TDev, T> > cms::alpakatools::make_device_buffer ( TDev const &  device)

Definition at line 194 of file memory.h.

194  {
195  return alpaka::allocBuf<std::remove_extent_t<T>, Idx>(device, Vec1D{std::extent_v<T>});
196  }
Vec< Dim1D > Vec1D
Definition: config.h:24
uint32_t Idx
Definition: config.h:13

◆ make_device_buffer() [4/6]

template<typename T , typename TQueue >
std::enable_if_t<alpaka::isQueue<TQueue> and not std::is_array_v<T>, device_buffer<alpaka::Dev<TQueue>, T> > cms::alpakatools::make_device_buffer ( TQueue const &  queue)

Definition at line 202 of file memory.h.

References allocator_policy, Asynchronous, Caching, createBeamHaloJobs::queue, and Synchronous.

202  {
203  if constexpr (allocator_policy<alpaka::Dev<TQueue>> == AllocatorPolicy::Caching) {
204  return allocCachedBuf<T, Idx>(alpaka::getDev(queue), queue, Scalar{});
205  }
206  if constexpr (allocator_policy<alpaka::Dev<TQueue>> == AllocatorPolicy::Asynchronous) {
207  return alpaka::allocAsyncBuf<T, Idx>(queue, Scalar{});
208  }
209  if constexpr (allocator_policy<alpaka::Dev<TQueue>> == AllocatorPolicy::Synchronous) {
210  return alpaka::allocBuf<T, Idx>(alpaka::getDev(queue), Scalar{});
211  }
212  }
Vec< Dim0D > Scalar
Definition: config.h:27
constexpr AllocatorPolicy allocator_policy

◆ make_device_buffer() [5/6]

template<typename T , typename TQueue >
std::enable_if_t<alpaka::isQueue<TQueue> and cms::is_unbounded_array_v<T> and not std::is_array_v<std::remove_extent_t<T> >, device_buffer<alpaka::Dev<TQueue>, T> > cms::alpakatools::make_device_buffer ( TQueue const &  queue,
Extent  extent 
)

Definition at line 218 of file memory.h.

References allocator_policy, Asynchronous, Caching, createBeamHaloJobs::queue, and Synchronous.

218  {
219  if constexpr (allocator_policy<alpaka::Dev<TQueue>> == AllocatorPolicy::Caching) {
220  return allocCachedBuf<std::remove_extent_t<T>, Idx>(alpaka::getDev(queue), queue, Vec1D{extent});
221  }
222  if constexpr (allocator_policy<alpaka::Dev<TQueue>> == AllocatorPolicy::Asynchronous) {
223  return alpaka::allocAsyncBuf<std::remove_extent_t<T>, Idx>(queue, Vec1D{extent});
224  }
225  if constexpr (allocator_policy<alpaka::Dev<TQueue>> == AllocatorPolicy::Synchronous) {
226  return alpaka::allocBuf<std::remove_extent_t<T>, Idx>(alpaka::getDev(queue), Vec1D{extent});
227  }
228  }
Vec< Dim1D > Vec1D
Definition: config.h:24
uint32_t Idx
Definition: config.h:13
constexpr AllocatorPolicy allocator_policy

◆ make_device_buffer() [6/6]

template<typename T , typename TQueue >
std::enable_if_t<alpaka::isQueue<TQueue> and cms::is_bounded_array_v<T> and not std::is_array_v<std::remove_extent_t<T> >, device_buffer<alpaka::Dev<TQueue>, T> > cms::alpakatools::make_device_buffer ( TQueue const &  queue)

Definition at line 234 of file memory.h.

References allocator_policy, Asynchronous, Caching, createBeamHaloJobs::queue, and Synchronous.

234  {
235  if constexpr (allocator_policy<alpaka::Dev<TQueue>> == AllocatorPolicy::Caching) {
236  return allocCachedBuf<std::remove_extent_t<T>, Idx>(alpaka::getDev(queue), queue, Vec1D{std::extent_v<T>});
237  }
238  if constexpr (allocator_policy<alpaka::Dev<TQueue>> == AllocatorPolicy::Asynchronous) {
239  return alpaka::allocAsyncBuf<std::remove_extent_t<T>, Idx>(queue, Vec1D{std::extent_v<T>});
240  }
241  if constexpr (allocator_policy<alpaka::Dev<TQueue>> == AllocatorPolicy::Synchronous) {
242  return alpaka::allocBuf<std::remove_extent_t<T>, Idx>(alpaka::getDev(queue), Vec1D{std::extent_v<T>});
243  }
244  }
Vec< Dim1D > Vec1D
Definition: config.h:24
uint32_t Idx
Definition: config.h:13
constexpr AllocatorPolicy allocator_policy

◆ make_device_view() [1/4]

template<typename T , typename TDev >
std::enable_if_t<not std::is_array_v<T>, device_view<TDev, T> > cms::alpakatools::make_device_view ( TDev const &  device,
T data 
)

Definition at line 252 of file memory.h.

References data.

252  {
253  return alpaka::ViewPlainPtr<TDev, T, Dim0D, Idx>(&data, device, Scalar{});
254  }
Vec< Dim0D > Scalar
Definition: config.h:27
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ make_device_view() [2/4]

template<typename T , typename TDev >
device_view<TDev, T[]> cms::alpakatools::make_device_view ( TDev const &  device,
T data,
Extent  extent 
)

Definition at line 257 of file memory.h.

References data.

257  {
258  return alpaka::ViewPlainPtr<TDev, T, Dim1D, Idx>(data, device, Vec1D{extent});
259  }
Vec< Dim1D > Vec1D
Definition: config.h:24
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ make_device_view() [3/4]

template<typename T , typename TDev >
std::enable_if_t<cms::is_unbounded_array_v<T> and not std::is_array_v<std::remove_extent_t<T> >, device_view<TDev, T> > cms::alpakatools::make_device_view ( TDev const &  device,
T data,
Extent  extent 
)

Definition at line 263 of file memory.h.

References data.

263  {
264  return alpaka::ViewPlainPtr<TDev, std::remove_extent_t<T>, Dim1D, Idx>(data, device, Vec1D{extent});
265  }
Vec< Dim1D > Vec1D
Definition: config.h:24
uint32_t Idx
Definition: config.h:13
alpaka::DimInt< 1u > Dim1D
Definition: config.h:18
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ make_device_view() [4/4]

template<typename T , typename TDev >
std::enable_if_t<cms::is_bounded_array_v<T> and not std::is_array_v<std::remove_extent_t<T> >, device_view<TDev, T> > cms::alpakatools::make_device_view ( TDev const &  device,
T data 
)

Definition at line 269 of file memory.h.

References data.

269  {
270  return alpaka::ViewPlainPtr<TDev, std::remove_extent_t<T>, Dim1D, Idx>(data, device, Vec1D{std::extent_v<T>});
271  }
Vec< Dim1D > Vec1D
Definition: config.h:24
uint32_t Idx
Definition: config.h:13
alpaka::DimInt< 1u > Dim1D
Definition: config.h:18
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ make_host_buffer() [1/9]

template<typename T >
std::enable_if_t<not std::is_array_v<T>, host_buffer<T> > cms::alpakatools::make_host_buffer ( )

Definition at line 64 of file memory.h.

References host().

64  {
65  return alpaka::allocBuf<T, Idx>(host(), Scalar{});
66  }
string host
Definition: query.py:115
Vec< Dim0D > Scalar
Definition: config.h:27

◆ make_host_buffer() [2/9]

template<typename T >
std::enable_if_t<cms::is_unbounded_array_v<T> and not std::is_array_v<std::remove_extent_t<T> >, host_buffer<T> > cms::alpakatools::make_host_buffer ( Extent  extent)

Definition at line 70 of file memory.h.

References host().

70  {
71  return alpaka::allocBuf<std::remove_extent_t<T>, Idx>(host(), Vec1D{extent});
72  }
string host
Definition: query.py:115
Vec< Dim1D > Vec1D
Definition: config.h:24
uint32_t Idx
Definition: config.h:13

◆ make_host_buffer() [3/9]

template<typename T >
std::enable_if_t<cms::is_bounded_array_v<T> and not std::is_array_v<std::remove_extent_t<T> >, host_buffer<T> > cms::alpakatools::make_host_buffer ( )

Definition at line 76 of file memory.h.

References host().

76  {
77  return alpaka::allocBuf<std::remove_extent_t<T>, Idx>(host(), Vec1D{std::extent_v<T>});
78  }
string host
Definition: query.py:115
Vec< Dim1D > Vec1D
Definition: config.h:24
uint32_t Idx
Definition: config.h:13

◆ make_host_buffer() [4/9]

template<typename T , typename TPlatform >
std::enable_if_t<not std::is_array_v<T>, host_buffer<T> > cms::alpakatools::make_host_buffer ( )

Definition at line 84 of file memory.h.

References host().

84  {
85  return alpaka::allocMappedBuf<TPlatform, T, Idx>(host(), Scalar{});
86  }
string host
Definition: query.py:115
Vec< Dim0D > Scalar
Definition: config.h:27

◆ make_host_buffer() [5/9]

template<typename T , typename TPlatform >
std::enable_if_t<cms::is_unbounded_array_v<T> and not std::is_array_v<std::remove_extent_t<T> >, host_buffer<T> > cms::alpakatools::make_host_buffer ( Extent  extent)

Definition at line 90 of file memory.h.

References host().

90  {
91  return alpaka::allocMappedBuf<TPlatform, std::remove_extent_t<T>, Idx>(host(), Vec1D{extent});
92  }
string host
Definition: query.py:115
Vec< Dim1D > Vec1D
Definition: config.h:24
uint32_t Idx
Definition: config.h:13

◆ make_host_buffer() [6/9]

template<typename T , typename TPlatform >
std::enable_if_t<cms::is_bounded_array_v<T> and not std::is_array_v<std::remove_extent_t<T> >, host_buffer<T> > cms::alpakatools::make_host_buffer ( )

Definition at line 96 of file memory.h.

References host().

96  {
97  return alpaka::allocMappedBuf<TPlatform, std::remove_extent_t<T>, Idx>(host(), Vec1D{std::extent_v<T>});
98  }
string host
Definition: query.py:115
Vec< Dim1D > Vec1D
Definition: config.h:24
uint32_t Idx
Definition: config.h:13

◆ make_host_buffer() [7/9]

template<typename T , typename TQueue >
std::enable_if_t<alpaka::isQueue<TQueue> and not std::is_array_v<T>, host_buffer<T> > cms::alpakatools::make_host_buffer ( TQueue const &  queue)

Definition at line 104 of file memory.h.

References allocator_policy, Caching, host(), and createBeamHaloJobs::queue.

105  {
106  if constexpr (allocator_policy<alpaka::Dev<TQueue>> == AllocatorPolicy::Caching) {
107  return allocCachedBuf<T, Idx>(host(), queue, Scalar{});
108  } else {
109  return alpaka::allocMappedBuf<alpaka::Pltf<alpaka::Dev<TQueue>>, T, Idx>(host(), Scalar{});
110  }
111  }
string host
Definition: query.py:115
uint32_t Idx
Definition: config.h:13
Vec< Dim0D > Scalar
Definition: config.h:27
constexpr AllocatorPolicy allocator_policy
long double T

◆ make_host_buffer() [8/9]

template<typename T , typename TQueue >
std::enable_if_t<alpaka::isQueue<TQueue> and cms::is_unbounded_array_v<T> and not std::is_array_v<std::remove_extent_t<T> >, host_buffer<T> > cms::alpakatools::make_host_buffer ( TQueue const &  queue,
Extent  extent 
)

Definition at line 117 of file memory.h.

References allocator_policy, Caching, host(), and createBeamHaloJobs::queue.

117  {
118  if constexpr (allocator_policy<alpaka::Dev<TQueue>> == AllocatorPolicy::Caching) {
119  return allocCachedBuf<std::remove_extent_t<T>, Idx>(host(), queue, Vec1D{extent});
120  } else {
121  return alpaka::allocMappedBuf<alpaka::Pltf<alpaka::Dev<TQueue>>, std::remove_extent_t<T>, Idx>(host(),
122  Vec1D{extent});
123  }
124  }
string host
Definition: query.py:115
Vec< Dim1D > Vec1D
Definition: config.h:24
uint32_t Idx
Definition: config.h:13
constexpr AllocatorPolicy allocator_policy

◆ make_host_buffer() [9/9]

template<typename T , typename TQueue >
std::enable_if_t<alpaka::isQueue<TQueue> and cms::is_bounded_array_v<T> and not std::is_array_v<std::remove_extent_t<T> >, host_buffer<T> > cms::alpakatools::make_host_buffer ( TQueue const &  queue)

Definition at line 130 of file memory.h.

References allocator_policy, Caching, host(), and createBeamHaloJobs::queue.

130  {
131  if constexpr (allocator_policy<alpaka::Dev<TQueue>> == AllocatorPolicy::Caching) {
132  return allocCachedBuf<std::remove_extent_t<T>, Idx>(host(), queue, Vec1D{std::extent_v<T>});
133  } else {
134  return alpaka::allocMappedBuf<alpaka::Pltf<alpaka::Dev<TQueue>>, std::remove_extent_t<T>, Idx>(
135  host(), Vec1D{std::extent_v<T>});
136  }
137  }
string host
Definition: query.py:115
Vec< Dim1D > Vec1D
Definition: config.h:24
uint32_t Idx
Definition: config.h:13
constexpr AllocatorPolicy allocator_policy

◆ make_host_view() [1/4]

template<typename T >
std::enable_if_t<not std::is_array_v<T>, host_view<T> > cms::alpakatools::make_host_view ( T data)

Definition at line 145 of file memory.h.

References data, and host().

145  {
146  return alpaka::ViewPlainPtr<DevHost, T, Dim0D, Idx>(&data, host(), Scalar{});
147  }
string host
Definition: query.py:115
Vec< Dim0D > Scalar
Definition: config.h:27
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ make_host_view() [2/4]

template<typename T >
host_view<T[]> cms::alpakatools::make_host_view ( T data,
Extent  extent 
)

Definition at line 150 of file memory.h.

References data, and host().

150  {
151  return alpaka::ViewPlainPtr<DevHost, T, Dim1D, Idx>(data, host(), Vec1D{extent});
152  }
string host
Definition: query.py:115
Vec< Dim1D > Vec1D
Definition: config.h:24
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ make_host_view() [3/4]

template<typename T >
std::enable_if_t<cms::is_unbounded_array_v<T> and not std::is_array_v<std::remove_extent_t<T> >, host_view<T> > cms::alpakatools::make_host_view ( T data,
Extent  extent 
)

Definition at line 156 of file memory.h.

References data, and host().

156  {
157  return alpaka::ViewPlainPtr<DevHost, std::remove_extent_t<T>, Dim1D, Idx>(data, host(), Vec1D{extent});
158  }
string host
Definition: query.py:115
Vec< Dim1D > Vec1D
Definition: config.h:24
uint32_t Idx
Definition: config.h:13
alpaka::DimInt< 1u > Dim1D
Definition: config.h:18
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ make_host_view() [4/4]

template<typename T >
std::enable_if_t<cms::is_bounded_array_v<T> and not std::is_array_v<std::remove_extent_t<T> >, host_view<T> > cms::alpakatools::make_host_view ( T data)

Definition at line 162 of file memory.h.

References data, and host().

162  {
163  return alpaka::ViewPlainPtr<DevHost, std::remove_extent_t<T>, Dim1D, Idx>(data, host(), Vec1D{std::extent_v<T>});
164  }
string host
Definition: query.py:115
Vec< Dim1D > Vec1D
Definition: config.h:24
uint32_t Idx
Definition: config.h:13
alpaka::DimInt< 1u > Dim1D
Definition: config.h:18
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ make_workdiv() [1/2]

template<typename TAcc , typename = std::enable_if_t<alpaka::isAccelerator<TAcc> and alpaka::Dim<TAcc>::value == 1>>
WorkDiv<Dim1D> cms::alpakatools::make_workdiv ( Idx  blocks,
Idx  elements 
)
inline

Definition at line 46 of file workdivision.h.

References gather_cfg::blocks, and bookConverter::elements.

46  {
47  if constexpr (not requires_single_thread_per_block_v<TAcc>) {
48  // On GPU backends, each thread is looking at a single element:
49  // - the number of threads per block is "elements";
50  // - the number of elements per thread is always 1.
51  return WorkDiv<Dim1D>(blocks, elements, Idx{1});
52  } else {
53  // On CPU backends, run serially with a single thread per block:
54  // - the number of threads per block is always 1;
55  // - the number of elements per thread is "elements".
56  return WorkDiv<Dim1D>(blocks, Idx{1}, elements);
57  }
58  }
uint32_t Idx
Definition: config.h:13
alpaka::WorkDivMembers< TDim, Idx > WorkDiv
Definition: config.h:30

◆ make_workdiv() [2/2]

template<typename TAcc , typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
WorkDiv<alpaka::Dim<TAcc> > cms::alpakatools::make_workdiv ( const Vec< alpaka::Dim< TAcc >> &  blocks,
const Vec< alpaka::Dim< TAcc >> &  elements 
)
inline

Definition at line 62 of file workdivision.h.

References gather_cfg::blocks, and bookConverter::elements.

63  {
64  using Dim = alpaka::Dim<TAcc>;
65  if constexpr (not requires_single_thread_per_block_v<TAcc>) {
66  // On GPU backends, each thread is looking at a single element:
67  // - the number of threads per block is "elements";
68  // - the number of elements per thread is always 1.
70  } else {
71  // On CPU backends, run serially with a single thread per block:
72  // - the number of threads per block is always 1;
73  // - the number of elements per thread is "elements".
75  }
76  }
alpaka::WorkDivMembers< TDim, Idx > WorkDiv
Definition: config.h:30
alpaka::Vec< TDim, Idx > Vec
Definition: config.h:23

◆ module_backend_config()

void cms::alpakatools::module_backend_config ( edm::ConfigurationDescriptions iDesc)

Definition at line 13 of file module_backend_config.cc.

References edm::ParameterSetDescription::addUntracked(), edm::ConfigurationDescriptions::defaultDescription(), edm::ParameterSetDescription::isLabelUnused(), kComment, AlCaHLTBitMon_QueryRunRegistry::string, and findQualityFiles::v.

Referenced by ALPAKA_ACCELERATOR_NAMESPACE::ESProducer::prevalidate(), and ALPAKA_ACCELERATOR_NAMESPACE::ProducerBase< edm::global::EDProducer, Args... >::prevalidate().

13  {
14  // the code below leads to 'alpaka = untracked.PSet(backend = untracked.string)' to be added to the generated cfi files
15  // TODO: I don't know if this is a desired behavior for HLT
17  descAlpaka.addUntracked<std::string>("backend", "")
18  ->setComment(
19  "Alpaka backend for this module. Can be empty string (for the global default), 'serial_sync', or "
20  " - depending on the architecture and available hardware - 'cuda_async', 'rocm_async'");
21 
22  if (iDesc.defaultDescription()) {
23  if (iDesc.defaultDescription()->isLabelUnused(kPSetName)) {
24  iDesc.defaultDescription()
25  ->addUntracked<edm::ParameterSetDescription>(kPSetName, descAlpaka)
26  ->setComment(kComment);
27  }
28  }
29  for (auto& v : iDesc) {
30  if (v.second.isLabelUnused(kPSetName)) {
31  v.second.addUntracked<edm::ParameterSetDescription>(kPSetName, descAlpaka)->setComment(kComment);
32  }
33  }
34  }
bool isLabelUnused(std::string const &label) const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterSetDescription * defaultDescription()
Returns 0 if no default has been assigned.
static const char *const kComment

◆ round_up_by()

constexpr Idx cms::alpakatools::round_up_by ( Idx  value,
Idx  divisor 
)
inline

Definition at line 16 of file workdivision.h.

16 { return (value + divisor - 1) / divisor * divisor; }
Definition: value.py:1

Variable Documentation

◆ allocator_policy

template<typename TDev , typename = std::enable_if_t<alpaka::isDevice<TDev>>>
constexpr AllocatorPolicy cms::alpakatools::allocator_policy = AllocatorPolicy::Synchronous
inline

Definition at line 17 of file AllocatorPolicy.h.

Referenced by make_device_buffer(), and make_host_buffer().

◆ requires_single_thread_per_block_v

template<typename TAcc , typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
constexpr bool cms::alpakatools::requires_single_thread_per_block_v = requires_single_thread_per_block<TAcc>::value
inline

Definition at line 42 of file workdivision.h.