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::Pltf< 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 18 of file EventCache.h.

Member Typedef Documentation

◆ Device

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

Definition at line 33 of file EventCache.h.

◆ Platform

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

Definition at line 34 of file EventCache.h.

Constructor & Destructor Documentation

◆ EventCache()

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

Definition at line 38 of file EventCache.h.

38 : cache_(alpaka::getDevCount<Platform>()) {}
std::vector< edm::ReusableObjectHolder< Event > > cache_
Definition: EventCache.h:85

Member Function Documentation

◆ clear()

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

Definition at line 75 of file EventCache.h.

References cms::alpakatools::EventCache< Event >::cache_.

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

◆ get()

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

Definition at line 46 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().

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

References cms::alpakatools::EventCache< Event >::cache_.

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

70  {
71  return cache_[alpaka::getNativeHandle(dev)].makeOrGet([dev]() { return std::make_unique<Event>(dev); });
72  }
std::vector< edm::ReusableObjectHolder< Event > > cache_
Definition: EventCache.h:85

Member Data Documentation

◆ cache_

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