1 #include "boost/program_options.hpp" 47 auto lumi = tester_.testBeginLuminosityBlock(iLumi);
55 auto event = tester_.test();
63 auto lumi = tester_.testEndLuminosityBlock();
68 auto run = tester_.testEndRun();
81 boost::interprocess::scoped_lock<boost::interprocess::named_mutex>* s_sharedLock =
nullptr;
83 void atexit_handler() {
85 std::cerr <<
"early exit called: unlock\n";
86 s_sharedLock->unlock();
95 descString +=
"] memory_name";
96 boost::program_options::options_description desc(descString);
103 boost::program_options::positional_options_description
p;
107 boost::program_options::options_description all_options(
"All Options");
108 all_options.add(desc);
110 boost::program_options::variables_map vm;
112 store(boost::program_options::command_line_parser(argc, argv).
options(all_options).positional(p).
run(), vm);
115 std::cout << argv[0] <<
": Error while trying to process command line arguments:\n" 116 << iException.what() <<
"\nFor usage and an options list, please do 'cmsRun --help'.";
131 std::cout <<
" no argument given" << std::endl;
136 std::cout <<
" no second argument given" << std::endl;
156 auto lockPtr = communicationChannel.
accessLock();
166 s_sharedLock = lockPtr;
167 auto unsetLockPtr = [](
void*) { s_sharedLock =
nullptr; };
168 std::unique_ptr<decltype(s_sharedLock), decltype(unsetLockPtr)> sharedLockGuard{&s_sharedLock, unsetLockPtr};
169 std::atexit(atexit_handler);
170 auto releaseLock = []() {
172 std::cerr <<
"terminate called: unlock\n";
173 s_sharedLock->unlock();
174 s_sharedLock =
nullptr;
177 struct sigaction act;
178 act.sa_sigaction =
nullptr;
179 act.sa_flags = SA_SIGINFO;
180 sigemptyset(&act.sa_mask);
181 sigaction(SIGABRT, &act,
nullptr);
185 std::set_terminate(releaseLock);
194 std::cerr << uniqueID <<
" process: initializing " << std::endl;
199 for (
int i = 0;
i < nlines; ++
i) {
201 std::getline(std::cin, c);
205 configuration += c +
"\n";
211 Harness harness(configuration, serviceToken);
215 std::set_terminate(releaseLock);
218 std::cerr << uniqueID <<
" process: done initializing" << std::endl;
223 std::cerr << uniqueID <<
" process: waiting " << counter << std::endl;
226 switch (iTransition) {
229 std::cerr << uniqueID <<
" process: start beginRun " << std::endl;
231 std::cerr << uniqueID <<
" process: end beginRun " << std::endl;
237 std::cerr << uniqueID <<
" process: start beginLumi " << std::endl;
238 auto randState = random_deserializer.
deserialize();
240 std::cerr << uniqueID <<
" random " << randState.state_.size() <<
" " << randState.seed_ << std::endl;
241 randomService->
setState(randState.state_, randState.seed_);
244 value.randomState_.seed_ = randomService->
mySeed();
248 std::cerr << uniqueID <<
" process: end beginLumi " << std::endl;
250 std::cerr << uniqueID <<
" rand " <<
value.randomState_.state_.size() <<
" " <<
value.randomState_.seed_
256 std::cerr << uniqueID <<
" process: event " << counter << std::endl;
257 auto randState = random_deserializer.
deserialize();
258 randomService->
setState(randState.state_, randState.seed_);
261 value.randomState_.seed_ = randomService->
mySeed();
264 std::cerr << uniqueID <<
" process: event " << counter << std::endl;
269 <<
" " << counter << std::endl;
275 std::cerr << uniqueID <<
" process: start endLumi " << std::endl;
280 std::cerr << uniqueID <<
" process: end endLumi " << std::endl;
286 std::cerr << uniqueID <<
" process: start endRun " << std::endl;
291 std::cerr << uniqueID <<
" process: end endRun " << std::endl;
300 std::cerr << uniqueID <<
" process: notifying and waiting " << counter << std::endl;
304 std::cerr <<
"caught exception \n" << iExcept.what() <<
"\n";
edmtest::ThingCollection getEndLumiValue()
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
void setAction(std::function< void()> iFunc)
static char const *const kHelpCommandOpt
GenLumiInfoProduct getEndLumiValue()
std::vector< unsigned long > getState() const
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)
static char const *const kVerboseCommandOpt
std::uint32_t mySeed() const final
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[])