1 #include "boost/program_options.hpp"
10 #include "DataFormats/TestObjects/interface/ToyProducts.h"
31 using SentType = std::pair<edmtest::IntProduct, edm::RandomNumberGeneratorState>;
33 using namespace edm::shared_memory;
40 auto lumi = tester_.testBeginLuminosityBlock(iLumi);
41 return *
lumi.get<edmtest::IntProduct>(
"lumi");
45 auto event = tester_.test();
46 return *
event.get<edmtest::IntProduct>();
57 descString +=
"] memory_name";
58 boost::program_options::options_description
desc(descString);
62 boost::program_options::value<std::string>(),
63 "memory name")(
kUniqueIDCommandOpt, boost::program_options::value<std::string>(),
"unique id");
65 boost::program_options::positional_options_description
p;
69 boost::program_options::options_description all_options(
"All Options");
70 all_options.add(desc);
72 boost::program_options::variables_map vm;
74 store(boost::program_options::command_line_parser(argc, argv).
options(all_options).positional(p).
run(), vm);
77 std::cout << argv[0] <<
": Error while trying to process command line arguments:\n"
78 << iException.what() <<
"\nFor usage and an options list, please do 'cmsRun --help'.";
88 std::cout <<
" no argument given" << std::endl;
93 std::cout <<
" no second argument given" << std::endl;
113 auto lockPtr = communicationChannel.
accessLock();
122 TCSerializer serializer(sm_buffer);
123 TCSerializer bl_serializer(sm_buffer);
126 TCDeserializer random_deserializer(sm_readbuffer);
128 std::cerr << uniqueID <<
" process: initializing " << std::endl;
133 for (
int i = 0;
i < nlines; ++
i) {
135 std::getline(std::cin, c);
137 configuration += c +
"\n";
144 Harness harness(configuration, serviceToken);
149 std::cerr << uniqueID <<
" process: done initializing" << std::endl;
152 std::cerr << uniqueID <<
" process: waiting " << counter << std::endl;
155 switch (iTransition) {
157 std::cerr << uniqueID <<
" process: start beginLumi " << std::endl;
158 auto randState = random_deserializer.deserialize();
159 std::cerr <<
" state " << randState.seed_ << std::endl;
160 randomService->
setState(randState.state_, randState.seed_);
163 toSend.second.state_ = randomService->
getState();
164 toSend.second.seed_ = randomService->
mySeed();
165 bl_serializer.serialize(toSend);
166 std::cerr << uniqueID <<
" process: end beginLumi " << toSend.first.value << std::endl;
171 std::cerr << uniqueID <<
" process: begin event " << counter << std::endl;
172 auto randState = random_deserializer.deserialize();
173 randomService->
setState(randState.state_, randState.seed_);
176 toSend.second.state_ = randomService->
getState();
177 toSend.second.seed_ = randomService->
mySeed();
178 std::cerr << uniqueID <<
" process: end event " << counter << std::endl;
180 serializer.serialize(toSend);
181 std::cerr << uniqueID <<
" process: " << toSend.first.value <<
" " << counter << std::endl;
189 std::cerr << uniqueID <<
" process: notifying and waiting" << counter << std::endl;
193 std::cerr <<
"caught exception \n" << iExcept.what() <<
"\n";
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 ...
edmtest::ThingCollection getBeginLumiValue(unsigned int iLumi)
void setState(std::vector< unsigned long > const &, long seed)
void handleTransitions(F &&iF)
void setupSignalHandling()
Sets the unix signal handler which communicates with the thread.
void setAction(std::function< void()> iFunc)
static char const *const kHelpOpt
std::vector< unsigned long > getState() const
edmtest::IntProduct getBeginLumiValue(unsigned int iLumi)
BufferInfo * toWorkerBufferInfo()
This can be used with ReadBuffer to keep Controller and Worker in sync.
void workerSetupDone()
Matches the ControllerChannel::setupWorker call.
std::pair< edmtest::IntProduct, edm::RandomNumberGeneratorState > SentType
static ServiceToken createContaining(std::unique_ptr< T > iService)
create a service token that holds the service defined by iService
std::uint32_t mySeed() const final
edmtest::IntProduct getEventValue()
BufferInfo * fromWorkerBufferInfo()
This can be used with WriteBuffer to keep Controller and Worker in sync.
static char const *const kUniqueIDCommandOpt
static char const *const kMemoryNameOpt
static char const *const kHelpCommandOpt
Harness(std::string const &iConfig, edm::ServiceToken iToken)
static char const *const kMemoryNameCommandOpt
static std::atomic< unsigned int > counter
static char const *const kUniqueIDOpt