1 #include "boost/program_options.hpp"
41 using namespace edm::shared_memory;
48 auto lumi = tester_.testBeginLuminosityBlock(iLumi);
56 auto event = tester_.test();
64 auto lumi = tester_.testEndLuminosityBlock();
69 auto run = tester_.testEndRun();
82 boost::interprocess::scoped_lock<boost::interprocess::named_mutex>* s_sharedLock =
nullptr;
84 void atexit_handler() {
86 std::cerr <<
"early exit called: unlock\n";
87 s_sharedLock->unlock();
96 descString +=
"] memory_name";
97 boost::program_options::options_description
desc(descString);
104 boost::program_options::positional_options_description
p;
108 boost::program_options::options_description all_options(
"All Options");
109 all_options.add(desc);
111 boost::program_options::variables_map vm;
113 store(boost::program_options::command_line_parser(argc, argv).
options(all_options).positional(p).
run(), vm);
116 std::cout << argv[0] <<
": Error while trying to process command line arguments:\n"
117 << iException.what() <<
"\nFor usage and an options list, please do 'cmsRun --help'.";
132 std::cout <<
" no argument given" << std::endl;
137 std::cout <<
" no second argument given" << std::endl;
141 using namespace std::string_literals;
142 using namespace std::filesystem;
145 create_directory(newDir);
146 current_path(newDir);
164 auto lockPtr = communicationChannel.
accessLock();
166 monitorThread.setAction([lockPtr]() {
174 s_sharedLock = lockPtr;
175 auto unsetLockPtr = [](
void*) { s_sharedLock =
nullptr; };
176 std::unique_ptr<decltype(s_sharedLock), decltype(unsetLockPtr)> sharedLockGuard{&s_sharedLock, unsetLockPtr};
177 std::atexit(atexit_handler);
178 auto releaseLock = []() {
180 std::cerr <<
"terminate called: unlock\n";
181 s_sharedLock->unlock();
182 s_sharedLock =
nullptr;
185 struct sigaction act;
186 act.sa_sigaction =
nullptr;
187 act.sa_flags = SA_SIGINFO;
188 sigemptyset(&act.sa_mask);
189 sigaction(SIGABRT, &act,
nullptr);
193 std::set_terminate(releaseLock);
202 std::cerr << uniqueID <<
" process: initializing " << std::endl;
207 for (
int i = 0;
i < nlines; ++
i) {
209 std::getline(std::cin, c);
213 configuration += c +
"\n";
219 Harness harness(configuration, serviceToken);
222 monitorThread.setupSignalHandling();
223 std::set_terminate(releaseLock);
226 std::cerr << uniqueID <<
" process: done initializing" << std::endl;
231 std::cerr << uniqueID <<
" process: waiting " << counter << std::endl;
234 switch (iTransition) {
237 std::cerr << uniqueID <<
" process: start beginRun " << std::endl;
239 std::cerr << uniqueID <<
" process: end beginRun " << std::endl;
245 std::cerr << uniqueID <<
" process: start beginLumi " << std::endl;
246 auto randState = random_deserializer.
deserialize();
248 std::cerr << uniqueID <<
" random " << randState.state_.size() <<
" " << randState.seed_ << std::endl;
249 randomService->
setState(randState.state_, randState.seed_);
252 value.randomState_.seed_ = randomService->
mySeed();
256 std::cerr << uniqueID <<
" process: end beginLumi " << std::endl;
258 std::cerr << uniqueID <<
" rand " <<
value.randomState_.state_.size() <<
" " <<
value.randomState_.seed_
264 std::cerr << uniqueID <<
" process: event " << counter << std::endl;
265 auto randState = random_deserializer.
deserialize();
266 randomService->
setState(randState.state_, randState.seed_);
269 value.randomState_.seed_ = randomService->
mySeed();
272 std::cerr << uniqueID <<
" process: event " << counter << std::endl;
277 <<
" " << counter << std::endl;
283 std::cerr << uniqueID <<
" process: start endLumi " << std::endl;
288 std::cerr << uniqueID <<
" process: end endLumi " << std::endl;
294 std::cerr << uniqueID <<
" process: start endRun " << std::endl;
299 std::cerr << uniqueID <<
" process: end endRun " << std::endl;
308 std::cerr << uniqueID <<
" process: notifying and waiting " << counter << std::endl;
312 std::cerr <<
"caught exception \n" << iExcept.what() <<
"\n";
edmtest::ThingCollection getEndLumiValue()
const edm::EventSetup & c
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()
static char const *const kMemoryNameOpt
static char const *const kHelpCommandOpt
GenLumiInfoProduct getEndLumiValue()
std::vector< unsigned long > getState() const
static constexpr int verbose
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