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::DataProxyProvider 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::DataProxyProvider
void createKeyedProxies (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
 DataProxyProvider ()
 
 DataProxyProvider (const DataProxyProvider &)=delete
 
const ComponentDescriptiondescription () const
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const DataProxyProvideroperator= (const DataProxyProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
virtual void updateLookup (ESRecordsToProxyIndices const &)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () 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::DataProxyProvider
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
 
KeyedProxiesVector registerProxies (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::DataProxyProvider
using KeyedProxiesVector = std::vector< std::pair< DataKey, std::shared_ptr< DataProxy > >>
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
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 57 of file TestESConcurrentSource.cc.

Constructor & Destructor Documentation

◆ TestESConcurrentSource()

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

Definition at line 121 of file TestESConcurrentSource.cc.

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

122  : count_(0),
123  maxCount_(0),
126  iterations_(pset.getParameter<unsigned int>("iterations")),
127  pi_(std::acos(-1)),
128  expectedNumberOfConcurrentIOVs_(pset.getParameter<unsigned int>("expectedNumberOfConcurrentIOVs")),
129  checkIOVInitialization_(pset.getParameter<bool>("checkIOVInitialization")) {
130  std::vector<unsigned int> temp(pset.getParameter<std::vector<unsigned int>>("firstValidLumis"));
131  for (auto val : temp) {
133  }
134 
135  findingRecord<ESTestRecordI>();
136  usingRecord<ESTestRecordI>();
137  }
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 139 of file TestESConcurrentSource.cc.

References maxCount_.

139  {
140  edm::LogAbsolute("TestESConcurrentSource") << "max concurrency seen " << maxCount_.load();
141  }
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 233 of file TestESConcurrentSource.cc.

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

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

233  {
234  edm::LogAbsolute("TestESConcurrentSource::busyWait") << "Start TestESConcurrentSource::busyWait " << msg;
235  double sum = 0.;
236  const double stepSize = pi_ / iterations_;
237  for (unsigned int i = 0; i < iterations_; ++i) {
238  sum += stepSize * cos(i * stepSize);
239  }
240  edm::LogAbsolute("TestESConcurrentSource::busyWait")
241  << "Stop TestESConcurrentSource::busyWait " << msg << " " << sum;
242  }
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 143 of file TestESConcurrentSource.cc.

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

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

◆ incrementCount()

void edmtest::TestESConcurrentSource::incrementCount ( )
inline

Definition at line 65 of file TestESConcurrentSource.cc.

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

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

65  {
66  auto const v = ++count_;
67  auto m = maxCount_.load();
68  while (m < v) {
69  maxCount_.compare_exchange_strong(m, v);
70  }
71  }
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::DataProxyProvider.

Definition at line 219 of file TestESConcurrentSource.cc.

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

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

◆ isConcurrentFinder()

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

Reimplemented from edm::EventSetupRecordIntervalFinder.

Definition at line 78 of file TestESConcurrentSource.cc.

78 { return true; }

◆ registerProxies()

edm::eventsetup::DataProxyProvider::KeyedProxiesVector edmtest::TestESConcurrentSource::registerProxies ( EventSetupRecordKey const &  ,
unsigned int  iovIndex 
)
overrideprivatevirtual

Implements edm::eventsetup::DataProxyProvider.

Definition at line 197 of file TestESConcurrentSource.cc.

References Exception, expectedNumberOfConcurrentIOVs_, and nConcurrentIOVs_.

198  {
200  throw cms::Exception("TestFailure") << "TestESConcurrentSource::registerProxies,"
201  << " unexpected number of concurrent IOVs";
202  }
203  KeyedProxiesVector keyedProxiesVector;
204 
205  {
206  edm::eventsetup::DataKey dataKey(edm::eventsetup::DataKey::makeTypeTag<IOVTestInfo>(),
208  keyedProxiesVector.emplace_back(dataKey, std::make_shared<TestESConcurrentSourceTestProxy>(this));
209  }
210  {
211  edm::eventsetup::DataKey dataKey(edm::eventsetup::DataKey::makeTypeTag<IOVTestInfo>(),
212  edm::eventsetup::IdTags("other"));
213  keyedProxiesVector.emplace_back(dataKey, std::make_shared<TestESConcurrentSourceTestProxy>(this));
214  }
215 
216  return keyedProxiesVector;
217  }
std::vector< std::pair< DataKey, std::shared_ptr< DataProxy > >> KeyedProxiesVector

◆ setIntervalFor()

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

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 153 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_.

155  {
157  // Note that this check should pass with the specific configuration where I enable
158  // the check, but in general it does not have to be true. The counts are offset
159  // by 1 because the beginRun IOV is invalid (no IOV initialization).
161  throw cms::Exception("TestFailure") << "TestESConcurrentSource::setIntervalFor,"
162  << " unexpected number of IOV initializations";
163  }
164  }
165  incrementCount();
167  busyWait("setIntervalFor");
169 
170  if (setOfIOV_.empty()) {
171  --count_;
172  return;
173  }
174 
175  std::pair<std::set<edm::IOVSyncValue>::iterator, std::set<edm::IOVSyncValue>::iterator> itFound =
176  setOfIOV_.equal_range(syncValue);
177 
178  if (itFound.first == itFound.second) {
179  if (itFound.first == setOfIOV_.begin()) {
180  //request is before first valid interval, so fail
181  --count_;
182  return;
183  }
184  //go back one step
185  --itFound.first;
186  }
187 
189  if (itFound.second != setOfIOV_.end()) {
190  endOfInterval = edm::IOVSyncValue(
191  edm::EventID(1, itFound.second->eventID().luminosityBlock() - 1, edm::EventID::maxEventNumber()));
192  }
193  iov = edm::ValidityInterval(*(itFound.first), endOfInterval);
194  --count_;
195  }
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 88 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 74 of file TestESConcurrentSource.cc.

Referenced by setIntervalFor().

◆ expectedNumberOfConcurrentIOVs_

unsigned int edmtest::TestESConcurrentSource::expectedNumberOfConcurrentIOVs_
private

Definition at line 86 of file TestESConcurrentSource.cc.

Referenced by initConcurrentIOVs(), and registerProxies().

◆ iterations_

const unsigned int edmtest::TestESConcurrentSource::iterations_
private

Definition at line 84 of file TestESConcurrentSource.cc.

Referenced by busyWait().

◆ maxCount_

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

Definition at line 73 of file TestESConcurrentSource.cc.

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

◆ nConcurrentIOVs_

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

Definition at line 87 of file TestESConcurrentSource.cc.

Referenced by initConcurrentIOVs(), and registerProxies().

◆ pi_

const double edmtest::TestESConcurrentSource::pi_
private

Definition at line 85 of file TestESConcurrentSource.cc.

Referenced by busyWait().

◆ setOfIOV_

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

Definition at line 83 of file TestESConcurrentSource.cc.

Referenced by setIntervalFor(), and TestESConcurrentSource().