CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
cms::alpakatools::EventCache< Event > Class Template Reference

#include <EventCache.h>

Public Types

using Device = alpaka::Dev< Event >
 
using Platform = alpaka::Platform< Device >
 

Public Member Functions

 EventCache ()
 
std::shared_ptr< Eventget (Device dev)
 

Private Member Functions

void clear ()
 
std::shared_ptr< EventmakeOrGet (Device dev)
 

Private Attributes

std::vector< edm::ReusableObjectHolder< Event > > cache_
 

Detailed Description

template<typename Event>
class cms::alpakatools::EventCache< Event >

Definition at line 19 of file EventCache.h.

Member Typedef Documentation

◆ Device

template<typename Event >
using cms::alpakatools::EventCache< Event >::Device = alpaka::Dev<Event>

Definition at line 34 of file EventCache.h.

◆ Platform

template<typename Event >
using cms::alpakatools::EventCache< Event >::Platform = alpaka::Platform<Device>

Definition at line 35 of file EventCache.h.

Constructor & Destructor Documentation

◆ EventCache()

template<typename Event >
cms::alpakatools::EventCache< Event >::EventCache ( )
inline

Definition at line 39 of file EventCache.h.

39 : cache_(devices<Platform>().size()) {}
std::vector< edm::ReusableObjectHolder< Event > > cache_
Definition: EventCache.h:90

Member Function Documentation

◆ clear()

template<typename Event >
void cms::alpakatools::EventCache< Event >::clear ( void  )
inlineprivate

Definition at line 80 of file EventCache.h.

References cms::alpakatools::EventCache< Event >::cache_, and cms::alpakatools::size.

80  {
81  // Reset the contents of the caches, but leave an
82  // edm::ReusableObjectHolder alive for each device. This is needed
83  // mostly for the unit tests, where the function-static
84  // EventCache lives through multiple tests (and go through
85  // multiple shutdowns of the framework).
86  cache_.clear();
87  cache_.resize(devices<Platform>().size());
88  }
std::vector< edm::ReusableObjectHolder< Event > > cache_
Definition: EventCache.h:90

◆ get()

template<typename Event >
std::shared_ptr<Event> cms::alpakatools::EventCache< Event >::get ( Device  dev)
inline

Definition at line 47 of file EventCache.h.

References edmPickEvents::event, cms::alpakatools::EventCache< Event >::makeOrGet(), and eostools::move().

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), submitPVValidationJobs.BetterConfigParser::__updateDict(), rrapi.RRApi::columns(), rrapi.RRApi::count(), rrapi.RRApi::data(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), submitPVValidationJobs.BetterConfigParser::getResultingSection(), rrapi.RRApi::report(), rrapi.RRApi::reports(), rrapi.RRApi::tables(), rrapi.RRApi::tags(), rrapi.RRApi::templates(), and rrapi.RRApi::workspaces().

47  {
48  auto event = makeOrGet(dev);
49  // captured work has completed, or a just-created event
50  if (alpaka::isComplete(*event)) {
51  return event;
52  }
53 
54  // Got an event with incomplete captured work. Try again until we
55  // get a completed (or a just-created) event. Need to keep all
56  // incomplete events until a completed event is found in order to
57  // avoid ping-pong with an incomplete event.
58  std::vector<std::shared_ptr<Event>> ptrs{std::move(event)};
59  bool completed;
60  do {
61  event = makeOrGet(dev);
62  completed = alpaka::isComplete(*event);
63  if (not completed) {
64  ptrs.emplace_back(std::move(event));
65  }
66  } while (not completed);
67  return event;
68  }
std::shared_ptr< Event > makeOrGet(Device dev)
Definition: EventCache.h:71
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1

◆ makeOrGet()

template<typename Event >
std::shared_ptr<Event> cms::alpakatools::EventCache< Event >::makeOrGet ( Device  dev)
inlineprivate

Definition at line 71 of file EventCache.h.

References cms::alpakatools::EventCache< Event >::cache_, and ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr().

Referenced by cms::alpakatools::EventCache< Event >::get().

71  {
72  return cache_[alpaka::getNativeHandle(dev)].makeOrGet([dev]() {
73  // We want non-busy waits
74  bool constexpr busyWait = false;
75  return std::make_unique<Event>(dev, busyWait);
76  });
77  }
std::vector< edm::ReusableObjectHolder< Event > > cache_
Definition: EventCache.h:90

Member Data Documentation

◆ cache_

template<typename Event >
std::vector<edm::ReusableObjectHolder<Event> > cms::alpakatools::EventCache< Event >::cache_
private