8 #include "GaudiKernel/IEvtSelector.h"
9 #include "GaudiKernel/IIncidentSvc.h"
10 #include "GaudiKernel/FileIncident.h"
11 #include "GaudiKernel/IIoComponentMgr.h"
12 #include "GaudiKernel/ISvcLocator.h"
15 #include <boost/interprocess/shared_memory_object.hpp>
16 #include <boost/interprocess/mapped_region.hpp>
28 ,
const std::string&
name
29 ,
const IInterface*
parent)
32 , m_useSharedReader(false)
33 , m_nEventsBeforeFork(0)
36 , m_nPositionInChunk(0)
39 , m_sharedEventQueue(0)
42 declareInterface<IAthenaMPTool>(
this);
55 int SharedEvtQueueProvider::makePool(
int maxevt,
int nprocs,
const std::string& topdir)
60 ATH_MSG_ERROR(
"Invalid number of events requested: " << maxevt );
83 ATH_MSG_ERROR(
"Unable to retrieve the pointer to Shared Event Queue" );
104 return StatusCode::FAILURE;
110 return StatusCode::FAILURE;
112 return StatusCode::SUCCESS;
120 filenames.push_back(counter_rundir.string()+std::string(
"/AthenaMP.log"));
133 *(
int*)(outwork->
data) = 1;
145 if(
mkdir(counter_rundir.string().c_str(),S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)==-1) {
146 ATH_MSG_ERROR(
"Unable to make event counter run directory: " << counter_rundir.string() <<
". " <<
fmterror(errno) );
154 ATH_MSG_INFO(
"Logs redirected in the AthenaMP event event counter PID=" << getpid() );
160 ATH_MSG_INFO(
"Io registry updated in the AthenaMP event event counter PID=" << getpid() );
171 ATH_MSG_INFO(
"File descriptors re-opened in the AthenaMP event event counter PID=" << getpid() );
175 IIncidentSvc* incsvc(0);
176 StatusCode sc = serviceLocator()->service(
"IncidentSvc",incsvc);
177 if(
sc.isFailure() || incsvc==0) {
182 incsvc->addListener(
this,
"EndInputFile");
190 ATH_MSG_ERROR(
"Failed to dyncast event selector to IEventShare" );
194 ATH_MSG_ERROR(
"Failed to make the event selector a share server");
197 ATH_MSG_DEBUG(
"Successfully made the event selector a share server");
203 if(!
m_ioMgr->io_reinitialize().isSuccess()) {
212 IService* evtSelSvc =
dynamic_cast<IService*
>(
m_evtSelector);
214 ATH_MSG_ERROR(
"Failed to dyncast event selector to IService" );
217 if(!evtSelSvc->start().isSuccess()) {
221 ATH_MSG_DEBUG(
"Successfully restarted the event selector" );
225 if(chdir(counter_rundir.string().c_str())==-1) {
226 ATH_MSG_ERROR(
"Failed to chdir to " << counter_rundir.string() );
231 *(
int*)(outwork->
data) = 0;
237 ATH_MSG_INFO(
"Exec function in the AthenaMP Event Counter PID=" << getpid());
242 IEvtSelector::Context* evtContext(
nullptr);
246 IProperty* propertyServer =
dynamic_cast<IProperty*
>(
m_evtSelector);
247 if(propertyServer==0) {
248 ATH_MSG_ERROR(
"Unable to cast event selector to IProperty" );
252 std::string propertyName(
"SkipEvents");
253 IntegerProperty skipEventsProp(propertyName,
skipEvents);
254 if(propertyServer->getProperty(&skipEventsProp).isFailure()) {
255 ATH_MSG_INFO(
"Event Selector does not have SkipEvents property" );
265 ATH_MSG_ERROR(
"Failed to create the event selector context");
272 ATH_MSG_ERROR(
"Unexpected error: EventsBeforeFork>EventsInInputFiles");
311 <<
", Event Chunk size in the queue is " <<
m_nChunkSize);
327 if(
m_appMgr->finalize().isFailure()) {
328 std::cerr <<
"Unable to finalize AppMgr" << std::endl;
337 *(
int*)(outwork->
data) = (all_ok?0:1);
352 *(
int*)(outwork->
data) = 0;
361 const FileIncident* fileInc =
dynamic_cast<const FileIncident*
>(&inc);
367 if(fileInc->type()==
"EndInputFile") {
384 ATH_MSG_INFO(
"Sent to the queue 0x" << std::hex << newValueForQueue << std::dec