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 SmartIF<IIncidentSvc> incsvc(serviceLocator()->service(
"IncidentSvc"));
181 incsvc->addListener(
this,
"EndInputFile");
189 ATH_MSG_ERROR(
"Failed to dyncast event selector to IEventShare" );
193 ATH_MSG_ERROR(
"Failed to make the event selector a share server");
196 ATH_MSG_DEBUG(
"Successfully made the event selector a share server");
202 if(!
m_ioMgr->io_reinitialize().isSuccess()) {
213 ATH_MSG_ERROR(
"Failed to dyncast event selector to IService" );
216 if(!evtSelSvc->start().isSuccess()) {
220 ATH_MSG_DEBUG(
"Successfully restarted the event selector" );
224 if(chdir(counter_rundir.string().c_str())==-1) {
225 ATH_MSG_ERROR(
"Failed to chdir to " << counter_rundir.string() );
230 *(
int*)(outwork->
data) = 0;
236 ATH_MSG_INFO(
"Exec function in the AthenaMP Event Counter PID=" << getpid());
241 IEvtSelector::Context* evtContext(
nullptr);
246 if(propertyServer==0) {
247 ATH_MSG_ERROR(
"Unable to cast event selector to IProperty" );
251 std::string propertyName(
"SkipEvents");
252 IntegerProperty skipEventsProp(propertyName,
skipEvents);
253 if(propertyServer->getProperty(&skipEventsProp).isFailure()) {
254 ATH_MSG_INFO(
"Event Selector does not have SkipEvents property" );
264 ATH_MSG_ERROR(
"Failed to create the event selector context");
271 ATH_MSG_ERROR(
"Unexpected error: EventsBeforeFork>EventsInInputFiles");
310 <<
", Event Chunk size in the queue is " <<
m_nChunkSize);
326 if(
m_appMgr->finalize().isFailure()) {
327 std::cerr <<
"Unable to finalize AppMgr" << std::endl;
336 *(
int*)(outwork->
data) = (all_ok?0:1);
351 *(
int*)(outwork->
data) = 0;
360 const FileIncident* fileInc =
dynamic_cast<const FileIncident*
>(&inc);
366 if(fileInc->type()==
"EndInputFile") {
383 ATH_MSG_INFO(
"Sent to the queue 0x" << std::hex << newValueForQueue << std::dec