1 #include "boost/program_options.hpp" 53 auto lumi = tester_.testBeginLuminosityBlock(iLumi);
61 auto event = tester_.test();
69 auto lumi = tester_.testEndLuminosityBlock();
74 auto run = tester_.testEndRun();
87 CMS_THREAD_SAFE boost::interprocess::scoped_lock<boost::interprocess::named_mutex>* s_sharedLock =
nullptr;
89 void atexit_handler() {
92 s_sharedLock->unlock();
101 descString +=
"] memory_name";
102 boost::program_options::options_description
desc(descString);
109 boost::program_options::positional_options_description
p;
113 boost::program_options::options_description all_options(
"All Options");
114 all_options.add(
desc);
116 boost::program_options::variables_map vm;
118 store(boost::program_options::command_line_parser(
argc,
argv).
options(all_options).positional(
p).
run(), vm);
121 std::cout <<
argv[0] <<
": Error while trying to process command line arguments:\n" 122 << iException.what() <<
"\nFor usage and an options list, please do 'cmsRun --help'.";
137 std::cout <<
" no argument given" << std::endl;
142 std::cout <<
" no second argument given" << std::endl;
147 using namespace std::filesystem;
150 create_directory(newDir);
151 current_path(newDir);
157 std::string presentState =
"setting up communicationChannel";
167 presentState =
"setting up read/write buffers";
172 presentState =
"setting up monitor thread";
174 auto lockPtr = communicationChannel.
accessLock();
183 presentState =
"setting up termination handler";
185 s_sharedLock = lockPtr;
186 auto unsetLockPtr = [](
void*) { s_sharedLock =
nullptr; };
187 std::unique_ptr<decltype(s_sharedLock), decltype(unsetLockPtr)> sharedLockGuard{&s_sharedLock, unsetLockPtr};
188 std::atexit(atexit_handler);
189 auto releaseLock = []() {
192 s_sharedLock->unlock();
193 s_sharedLock =
nullptr;
196 struct sigaction act;
197 act.sa_sigaction =
nullptr;
198 act.sa_flags = SA_SIGINFO;
199 sigemptyset(&act.sa_mask);
200 sigaction(SIGABRT, &act,
nullptr);
204 std::set_terminate(releaseLock);
206 presentState =
"setting up serializers";
214 presentState =
"reading configuration";
215 std::cerr << uniqueID <<
" process: initializing " << std::endl;
220 for (
int i = 0;
i < nlines; ++
i) {
222 std::getline(std::cin,
c);
229 presentState =
"setting up random number generator";
237 std::set_terminate(releaseLock);
240 std::cerr << uniqueID <<
" process: done initializing" << std::endl;
242 presentState =
"finished initialization";
245 presentState =
"waiting for transition";
250 switch (iTransition) {
252 presentState =
"beginRun transition";
254 std::cerr << uniqueID <<
" process: start beginRun " << std::endl;
256 std::cerr << uniqueID <<
" process: end beginRun " << std::endl;
261 presentState =
"begin lumi";
263 std::cerr << uniqueID <<
" process: start beginLumi " << std::endl;
264 auto randState = random_deserializer.
deserialize();
265 presentState =
"deserialized random state in begin lumi";
267 std::cerr << uniqueID <<
" random " << randState.state_.size() <<
" " << randState.seed_ << std::endl;
268 randomService->
setState(randState.state_, randState.seed_);
269 presentState =
"processing begin lumi";
272 value.randomState_.seed_ = randomService->
mySeed();
274 presentState =
"serialize lumi";
277 std::cerr << uniqueID <<
" process: end beginLumi " << std::endl;
279 std::cerr << uniqueID <<
" rand " <<
value.randomState_.state_.size() <<
" " <<
value.randomState_.seed_
284 presentState =
"begin event";
287 presentState =
"deserialized random state in event";
288 auto randState = random_deserializer.
deserialize();
289 randomService->
setState(randState.state_, randState.seed_);
290 presentState =
"processing event";
293 value.randomState_.seed_ = randomService->
mySeed();
298 presentState =
"serialize event";
302 <<
" " <<
counter << std::endl;
307 presentState =
"begin end lumi";
309 std::cerr << uniqueID <<
" process: start endLumi " << std::endl;
310 presentState =
"processing end lumi";
313 presentState =
"serialize end lumi";
316 std::cerr << uniqueID <<
" process: end endLumi " << std::endl;
321 presentState =
"begin end run";
323 std::cerr << uniqueID <<
" process: start endRun " << std::endl;
324 presentState =
"process end run";
327 presentState =
"serialize end run";
330 std::cerr << uniqueID <<
" process: end endRun " << std::endl;
338 presentState =
"notifying and waiting after " + presentState;
340 std::cerr << uniqueID <<
" process: notifying and waiting " <<
counter << std::endl;
344 std::cerr <<
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n" 345 <<
s_uniqueID <<
" process: caught exception \n" 346 << iExcept.what() <<
"\n" 347 <<
" while " << presentState <<
"\n" 348 <<
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
351 std::cerr <<
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n" 352 <<
s_uniqueID <<
" process: caught unknown exception\n while " << presentState <<
"\n" 353 <<
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
edmtest::ThingCollection getEndLumiValue()
std::vector< unsigned long > getState() const
edmtest::ThingCollection getEventValue()
boost::interprocess::scoped_lock< boost::interprocess::named_mutex > * accessLock()
the lock is made accessible so that the WorkerMonitorThread can be used to unlock it in the event of ...
ExternalGeneratorEventInfo getEventValue()
static char const *const kHelpOpt
static char const *const kMemoryNameCommandOpt
edmtest::ThingCollection getBeginLumiValue(unsigned int iLumi)
void setState(std::vector< unsigned long > const &, long seed)
void serialize(T &iValue)
void handleTransitions(F &&iF)
GenRunInfoProduct getEndRunValue()
void setupSignalHandling()
Sets the unix signal handler which communicates with the thread.
static char const *const kMemoryNameOpt
static std::string s_uniqueID
void setAction(std::function< void()> iFunc)
static char const *const kHelpCommandOpt
GenLumiInfoProduct getEndLumiValue()
GenEventInfoProduct eventInfo_
BufferInfo * toWorkerBufferInfo()
This can be used with ReadBuffer to keep Controller and Worker in sync.
void workerSetupDone()
Matches the ControllerChannel::setupWorker call.
static ServiceToken createContaining(std::unique_ptr< T > iService)
create a service token that holds the service defined by iService
static char const *const kVerboseOpt
ExternalGeneratorLumiInfo getBeginLumiValue(unsigned int iLumi)
std::uint32_t mySeed() const final
static char const *const kVerboseCommandOpt
BufferInfo * fromWorkerBufferInfo()
This can be used with WriteBuffer to keep Controller and Worker in sync.
GenLumiInfoHeader header_
static char const *const kUniqueIDCommandOpt
Harness(std::string const &iConfig, edm::ServiceToken iToken)
edmtest::ThingCollection getEndRunValue()
static char const *const kUniqueIDOpt
static std::atomic< unsigned int > counter
int main(int argc, char *argv[])