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;
151 WriteBuffer sm_buffer{memoryName, communicationChannel.fromWorkerBufferInfo()};
152 ReadBuffer sm_readbuffer{
std::string(
"Rand") + memoryName, communicationChannel.toWorkerBufferInfo()};
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;
220 communicationChannel.workerSetupDone();
223 std::cerr << uniqueID <<
" process: waiting " << counter << std::endl;
224 communicationChannel.handleTransitions([&](
edm::Transition iTransition,
unsigned long long iTransitionID) {
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_);
242 auto value = harness.getBeginLumiValue(iTransitionID);
244 value.randomState_.seed_ = randomService->
mySeed();
246 bl_serializer.serialize(
value);
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_);
259 auto value = harness.getEventValue();
261 value.randomState_.seed_ = randomService->
mySeed();
264 std::cerr << uniqueID <<
" process: event " << counter << std::endl;
266 serializer.serialize(
value);
269 <<
" " << counter << std::endl;
275 std::cerr << uniqueID <<
" process: start endLumi " << std::endl;
276 auto value = harness.getEndLumiValue();
278 el_serializer.serialize(
value);
280 std::cerr << uniqueID <<
" process: end endLumi " << std::endl;
286 std::cerr << uniqueID <<
" process: start endRun " << std::endl;
287 auto value = harness.getEndRunValue();
289 er_serializer.serialize(
value);
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";
static char const *const kHelpOpt
static char const *const kMemoryNameCommandOpt
void setState(std::vector< unsigned long > const &, long seed)
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
std::vector< unsigned long > getState() const
static ServiceToken createContaining(std::unique_ptr< T > iService)
create a service token that holds the service defined by iService
static char const *const kVerboseOpt
static char const *const kVerboseCommandOpt
std::uint32_t mySeed() const final
static char const *const kUniqueIDCommandOpt
static char const *const kUniqueIDOpt
static std::atomic< unsigned int > counter