CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
edmtest::TestESConcurrentSource Class Reference
Inheritance diagram for edmtest::TestESConcurrentSource:
edm::eventsetup::ESProductResolverProvider edm::EventSetupRecordIntervalFinder

Public Types

using EventSetupRecordKey = edm::eventsetup::EventSetupRecordKey
 

Public Member Functions

void busyWait (char const *msg) const
 
void incrementCount ()
 
 TestESConcurrentSource (edm::ParameterSet const &)
 
 ~TestESConcurrentSource () override
 
- Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
void createKeyedResolvers (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
const ComponentDescriptiondescription () const
 
 ESProductResolverProvider ()
 
 ESProductResolverProvider (const ESProductResolverProvider &)=delete
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedResolverskeyedResolvers (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const ESProductResolverProvideroperator= (const ESProductResolverProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
virtual void updateLookup (ESRecordsToProductResolverIndices const &)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~ESProductResolverProvider () noexcept(false)
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
bool concurrentFinder () const
 
const eventsetup::ComponentDescriptiondescriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
 EventSetupRecordIntervalFinder (const EventSetupRecordIntervalFinder &)=delete
 
std::set< eventsetup::EventSetupRecordKeyfindingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
bool nonconcurrentAndIOVNeedsUpdate (const eventsetup::EventSetupRecordKey &key, const IOVSyncValue &syncValue) const
 
const EventSetupRecordIntervalFinderoperator= (const EventSetupRecordIntervalFinder &)=delete
 
void resetInterval (const eventsetup::EventSetupRecordKey &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
static void prevalidate (ConfigurationDescriptions &)
 

Public Attributes

std::atomic< unsigned int > count_
 
std::atomic< unsigned int > count_initializeForNewIOV_
 
std::atomic< unsigned int > count_setIntervalFor_
 
std::atomic< unsigned int > maxCount_
 

Private Member Functions

void initConcurrentIOVs (EventSetupRecordKey const &, unsigned int nConcurrentIOVs) override
 
bool isConcurrentFinder () const override
 
KeyedResolversVector registerResolvers (EventSetupRecordKey const &, unsigned int iovIndex) override
 
void setIntervalFor (EventSetupRecordKey const &, edm::IOVSyncValue const &, edm::ValidityInterval &) override
 

Private Attributes

bool checkIOVInitialization_
 
unsigned int expectedNumberOfConcurrentIOVs_
 
const unsigned int iterations_
 
unsigned int nConcurrentIOVs_ = 0
 
const double pi_
 
std::set< edm::IOVSyncValuesetOfIOV_
 

Additional Inherited Members

- Protected Types inherited from edm::eventsetup::ESProductResolverProvider
using KeyedResolversVector = std::vector< std::pair< DataKey, std::shared_ptr< ESProductResolver > >>
 
- Protected Member Functions inherited from edm::eventsetup::ESProductResolverProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 
- Protected Member Functions inherited from edm::EventSetupRecordIntervalFinder
template<class T >
void findingRecord ()
 
void findingRecordWithKey (const eventsetup::EventSetupRecordKey &)
 

Detailed Description

Definition at line 55 of file TestESConcurrentSource.cc.

Member Typedef Documentation

◆ EventSetupRecordKey

Definition at line 58 of file TestESConcurrentSource.cc.

Constructor & Destructor Documentation

◆ TestESConcurrentSource()

edmtest::TestESConcurrentSource::TestESConcurrentSource ( edm::ParameterSet const &  pset)
explicit

Definition at line 122 of file TestESConcurrentSource.cc.

References muonDTDigis_cfi::pset, setOfIOV_, groupFilesInBlocks::temp, and heppy_batch::val.

123  : count_(0),
124  maxCount_(0),
127  iterations_(pset.getParameter<unsigned int>("iterations")),
128  pi_(std::acos(-1)),
129  expectedNumberOfConcurrentIOVs_(pset.getParameter<unsigned int>("expectedNumberOfConcurrentIOVs")),
130  checkIOVInitialization_(pset.getParameter<bool>("checkIOVInitialization")) {
131  std::vector<unsigned int> temp(pset.getParameter<std::vector<unsigned int>>("firstValidLumis"));
132  for (auto val : temp) {
134  }
135 
136  findingRecord<ESTestRecordI>();
137  usingRecord<ESTestRecordI>();
138  }
std::atomic< unsigned int > count_
std::atomic< unsigned int > count_initializeForNewIOV_
std::atomic< unsigned int > count_setIntervalFor_
std::set< edm::IOVSyncValue > setOfIOV_
std::atomic< unsigned int > maxCount_

◆ ~TestESConcurrentSource()

edmtest::TestESConcurrentSource::~TestESConcurrentSource ( )
override

Definition at line 140 of file TestESConcurrentSource.cc.

References maxCount_.

140  {
141  edm::LogAbsolute("TestESConcurrentSource") << "max concurrency seen " << maxCount_.load();
142  }
Log< level::System, true > LogAbsolute
std::atomic< unsigned int > maxCount_

Member Function Documentation

◆ busyWait()

void edmtest::TestESConcurrentSource::busyWait ( char const *  msg) const

Definition at line 234 of file TestESConcurrentSource.cc.

References funct::cos(), mps_fire::i, iterations_, mps_check::msg, and pi_.

Referenced by edmtest::TestESConcurrentSourceTestResolver::prefetch(), and setIntervalFor().

234  {
235  edm::LogAbsolute("TestESConcurrentSource::busyWait") << "Start TestESConcurrentSource::busyWait " << msg;
236  double sum = 0.;
237  const double stepSize = pi_ / iterations_;
238  for (unsigned int i = 0; i < iterations_; ++i) {
239  sum += stepSize * cos(i * stepSize);
240  }
241  edm::LogAbsolute("TestESConcurrentSource::busyWait")
242  << "Stop TestESConcurrentSource::busyWait " << msg << " " << sum;
243  }
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
tuple msg
Definition: mps_check.py:286
Log< level::System, true > LogAbsolute

◆ fillDescriptions()

void edmtest::TestESConcurrentSource::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 144 of file TestESConcurrentSource.cc.

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

144  {
146  std::vector<unsigned int> emptyVector;
147  desc.add<unsigned int>("iterations", 10 * 1000 * 1000);
148  desc.add<bool>("checkIOVInitialization", false);
149  desc.add<unsigned int>("expectedNumberOfConcurrentIOVs", 0);
150  desc.add<std::vector<unsigned int>>("firstValidLumis", emptyVector);
151  descriptions.addDefault(desc);
152  }
void addDefault(ParameterSetDescription const &psetDescription)

◆ incrementCount()

void edmtest::TestESConcurrentSource::incrementCount ( )
inline

Definition at line 66 of file TestESConcurrentSource.cc.

References count_, visualization-live-secondInstance_cfg::m, maxCount_, and findQualityFiles::v.

Referenced by edmtest::TestESConcurrentSourceTestResolver::prefetch(), and setIntervalFor().

66  {
67  auto const v = ++count_;
68  auto m = maxCount_.load();
69  while (m < v) {
70  maxCount_.compare_exchange_strong(m, v);
71  }
72  }
std::atomic< unsigned int > count_
std::atomic< unsigned int > maxCount_

◆ initConcurrentIOVs()

void edmtest::TestESConcurrentSource::initConcurrentIOVs ( EventSetupRecordKey const &  key,
unsigned int  nConcurrentIOVs 
)
overrideprivatevirtual

Reimplemented from edm::eventsetup::ESProductResolverProvider.

Definition at line 220 of file TestESConcurrentSource.cc.

References Exception, expectedNumberOfConcurrentIOVs_, submitPVResolutionJobs::key, and nConcurrentIOVs_.

220  {
221  edm::LogAbsolute("TestESConcurrentSource::initConcurrentIOVs")
222  << "Start TestESConcurrentSource::initConcurrentIOVs " << nConcurrentIOVs << " " << key.name();
223  if (EventSetupRecordKey::makeKey<ESTestRecordI>() != key) {
224  throw cms::Exception("TestFailure") << "TestESConcurrentSource::initConcurrentIOVs,"
225  << " unexpected EventSetupRecordKey";
226  }
227  if (expectedNumberOfConcurrentIOVs_ != 0 && nConcurrentIOVs != expectedNumberOfConcurrentIOVs_) {
228  throw cms::Exception("TestFailure") << "TestESConcurrentSource::initConcurrentIOVs,"
229  << " unexpected number of concurrent IOVs";
230  }
231  nConcurrentIOVs_ = nConcurrentIOVs;
232  }
key
prepare the HTCondor submission files and eventually submit them
Log< level::System, true > LogAbsolute

◆ isConcurrentFinder()

bool edmtest::TestESConcurrentSource::isConcurrentFinder ( ) const
inlineoverrideprivatevirtual

Reimplemented from edm::EventSetupRecordIntervalFinder.

Definition at line 79 of file TestESConcurrentSource.cc.

79 { return true; }

◆ registerResolvers()

edm::eventsetup::ESProductResolverProvider::KeyedResolversVector edmtest::TestESConcurrentSource::registerResolvers ( EventSetupRecordKey const &  ,
unsigned int  iovIndex 
)
overrideprivatevirtual

Implements edm::eventsetup::ESProductResolverProvider.

Definition at line 198 of file TestESConcurrentSource.cc.

References Exception, expectedNumberOfConcurrentIOVs_, and nConcurrentIOVs_.

199  {
201  throw cms::Exception("TestFailure") << "TestESConcurrentSource::registerResolvers,"
202  << " unexpected number of concurrent IOVs";
203  }
204  KeyedResolversVector keyedResolversVector;
205 
206  {
207  edm::eventsetup::DataKey dataKey(edm::eventsetup::DataKey::makeTypeTag<IOVTestInfo>(),
209  keyedResolversVector.emplace_back(dataKey, std::make_shared<TestESConcurrentSourceTestResolver>(this));
210  }
211  {
212  edm::eventsetup::DataKey dataKey(edm::eventsetup::DataKey::makeTypeTag<IOVTestInfo>(),
213  edm::eventsetup::IdTags("other"));
214  keyedResolversVector.emplace_back(dataKey, std::make_shared<TestESConcurrentSourceTestResolver>(this));
215  }
216 
217  return keyedResolversVector;
218  }
std::vector< std::pair< DataKey, std::shared_ptr< ESProductResolver > >> KeyedResolversVector

◆ setIntervalFor()

void edmtest::TestESConcurrentSource::setIntervalFor ( EventSetupRecordKey const &  ,
edm::IOVSyncValue const &  syncValue,
edm::ValidityInterval iov 
)
overrideprivatevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 154 of file TestESConcurrentSource.cc.

References busyWait(), checkIOVInitialization_, count_, count_initializeForNewIOV_, count_setIntervalFor_, edm::IOVSyncValue::endOfTime(), Exception, incrementCount(), edm::ValidityInterval::invalidInterval(), edm::EventID::maxEventNumber(), and setOfIOV_.

156  {
158  // Note that this check should pass with the specific configuration where I enable
159  // the check, but in general it does not have to be true. The counts are offset
160  // by 1 because the beginRun IOV is invalid (no IOV initialization).
162  throw cms::Exception("TestFailure") << "TestESConcurrentSource::setIntervalFor,"
163  << " unexpected number of IOV initializations";
164  }
165  }
166  incrementCount();
168  busyWait("setIntervalFor");
170 
171  if (setOfIOV_.empty()) {
172  --count_;
173  return;
174  }
175 
176  std::pair<std::set<edm::IOVSyncValue>::iterator, std::set<edm::IOVSyncValue>::iterator> itFound =
177  setOfIOV_.equal_range(syncValue);
178 
179  if (itFound.first == itFound.second) {
180  if (itFound.first == setOfIOV_.begin()) {
181  //request is before first valid interval, so fail
182  --count_;
183  return;
184  }
185  //go back one step
186  --itFound.first;
187  }
188 
190  if (itFound.second != setOfIOV_.end()) {
191  endOfInterval = edm::IOVSyncValue(
192  edm::EventID(1, itFound.second->eventID().luminosityBlock() - 1, edm::EventID::maxEventNumber()));
193  }
194  iov = edm::ValidityInterval(*(itFound.first), endOfInterval);
195  --count_;
196  }
void busyWait(char const *msg) const
std::atomic< unsigned int > count_
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
std::atomic< unsigned int > count_initializeForNewIOV_
std::atomic< unsigned int > count_setIntervalFor_
std::set< edm::IOVSyncValue > setOfIOV_
static EventNumber_t maxEventNumber()
Definition: EventID.h:96
static const ValidityInterval & invalidInterval()

Member Data Documentation

◆ checkIOVInitialization_

bool edmtest::TestESConcurrentSource::checkIOVInitialization_
private

Definition at line 89 of file TestESConcurrentSource.cc.

Referenced by setIntervalFor().

◆ count_

std::atomic<unsigned int> edmtest::TestESConcurrentSource::count_

◆ count_initializeForNewIOV_

std::atomic<unsigned int> edmtest::TestESConcurrentSource::count_initializeForNewIOV_

◆ count_setIntervalFor_

std::atomic<unsigned int> edmtest::TestESConcurrentSource::count_setIntervalFor_

Definition at line 75 of file TestESConcurrentSource.cc.

Referenced by setIntervalFor().

◆ expectedNumberOfConcurrentIOVs_

unsigned int edmtest::TestESConcurrentSource::expectedNumberOfConcurrentIOVs_
private

Definition at line 87 of file TestESConcurrentSource.cc.

Referenced by initConcurrentIOVs(), and registerResolvers().

◆ iterations_

const unsigned int edmtest::TestESConcurrentSource::iterations_
private

Definition at line 85 of file TestESConcurrentSource.cc.

Referenced by busyWait().

◆ maxCount_

std::atomic<unsigned int> edmtest::TestESConcurrentSource::maxCount_

Definition at line 74 of file TestESConcurrentSource.cc.

Referenced by incrementCount(), and ~TestESConcurrentSource().

◆ nConcurrentIOVs_

unsigned int edmtest::TestESConcurrentSource::nConcurrentIOVs_ = 0
private

Definition at line 88 of file TestESConcurrentSource.cc.

Referenced by initConcurrentIOVs(), and registerResolvers().

◆ pi_

const double edmtest::TestESConcurrentSource::pi_
private

Definition at line 86 of file TestESConcurrentSource.cc.

Referenced by busyWait().

◆ setOfIOV_

std::set<edm::IOVSyncValue> edmtest::TestESConcurrentSource::setOfIOV_
private

Definition at line 84 of file TestESConcurrentSource.cc.

Referenced by setIntervalFor(), and TestESConcurrentSource().