// start MPI container executable
MPIContainer start_MPIimpl( in string ContainerName, in short nbproc );
+ // shutdown corba server
+ void MPIShutdown() ;
+
// asynchronous version to load and remove parallel component in parallel
oneway void SPload_impl(in string nameToRegister, in string componentName);
oneway void SPremove_impl(in Component component_i);
{
MESSAGE("[" << numproc << "] activate object");
_id = _poa->activate_object(this);
+ this->_add_ref();
if(numproc==0){
ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting()) ;
_NS->init_orb( orb ) ;
- Engines::Container_ptr pCont
- = Engines::Container::_narrow(POA_Engines::MPIContainer::_this());
+// Engines::Container_ptr pCont
+// = Engines::Container::_narrow(POA_Engines::MPIContainer::_this());
+ Engines::Container_ptr pCont = Engines::Container::_narrow(_poa->id_to_reference(*_id));
SCRUTE(_containerName);
_NS->Register(pCont, _containerName.c_str());
}
END_OF("[" << _numproc << "] MPIContainer_i::Lfinalize_removal");
}
+
+// Load component
+void Engines_MPIContainer_i::MPIShutdown()
+{
+ int ip;
+ MESSAGE("[" << _numproc << "] shutdown of Corba Server");
+ if( _numproc == 0 ){
+ for(ip= 1;ip<_nbproc;ip++)
+ (Engines::MPIContainer::_narrow((*_tior)[ip]))->Shutdown();
+ }
+
+ Shutdown();
+
+}
+
// synchronous version for process 0
Engines::Component_ptr load_impl(const char* nameToRegister,
const char* componentName);
+ // shutdown corba server
+ void MPIShutdown();
+
// asynchronous version for other process
void SPload_impl(const char* nameToRegister, const char* componentName);
#include "Utils_SINGLETON.hxx"
#include "utilities.h"
#include <mpi.h>
+#include "LocalTraceCollector.hxx"
using namespace std;
int main(int argc, char* argv[])
int flag;
Engines_MPIContainer_i * myContainer=NULL;
- BEGIN_OF(argv[0])
+ MPI_Init(&argc,&argv);
+ MPI_Comm_size(MPI_COMM_WORLD,&nbproc);
+ MPI_Comm_rank(MPI_COMM_WORLD,&numproc);
+
+ // Initialise the ORB.
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ CORBA::ORB_var &orb = init( argc , argv ) ;
+ LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb);
+
+ BEGIN_OF("[" << numproc << "] " << argv[0])
try {
- MESSAGE("Connection MPI");
- MPI_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nbproc);
- MPI_Comm_rank(MPI_COMM_WORLD,&numproc);
-
- MESSAGE("[" << numproc << "] Initialisation CORBA");
- // Initialise the ORB.
- // CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
- ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
- ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
- CORBA::ORB_var &orb = init( argc , argv ) ;
-
// Obtain a reference to the root POA.
CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
containerName = argv[1] ;
}
- MESSAGE("[" << numproc << "] Chargement container");
+ MESSAGE("[" << numproc << "] MPIContainer: load MPIContainer servant");
myContainer = new Engines_MPIContainer_i(nbproc,numproc,orb,factory_poa, containerName,argc,argv);
pman->activate();
if(flag)
MPI_Finalize();
- END_OF(argv[0]);
+ END_OF("[" << numproc << "] " << argv[0]);
+ delete myThreadTrace;
+ return 0 ;
}
BIN_CLIENT_IDL = Logger.idl SALOME_MPIObject.idl SALOME_MPIContainer.idl SALOME_TestMPIComponent.idl
BIN_SERVER_IDL =
-LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeMPILifeCycleCORBA -lSalomeLifeCycleCORBA -lSalomeMPIContainer -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace
+LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeMPILifeCycleCORBA -lSalomeLifeCycleCORBA -lSalomeMPIContainer -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace ${MPI_LIBS}
+CXXFLAGS+=${MPI_INCLUDES}
+CXX_DEPEND_FLAG+=${MPI_INCLUDES}
@CONCLUDE@
// $Header$
//=============================================================================
+#include <mpi.h>
#include "utilities.h"
#include "TestMPIComponentEngine.hxx"
using namespace std;
{
MESSAGE("activate object")
_thisObj = this ;
- _id = _poa->activate_object(_thisObj);
+ _id = _poa->reference_to_id(_thisObj->_this());
}
TestMPIComponentEngine::TestMPIComponentEngine(): Engines_Component_i(), MPIObject_i()
void TestMPIComponentEngine::Coucou(CORBA::Long L)
{
- BEGIN_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()");
if(_numproc==0)
for(int ip=1;ip<_nbproc;ip++)
Engines::TestMPIComponent::_narrow((*_tior)[ip])->SPCoucou(L);
- MESSAGE("[" << _numproc << "] TestMPIComponentEngine : L = " << L);
- END_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()");
+ SPCoucou(L);
}
void TestMPIComponentEngine::SPCoucou(CORBA::Long L)
{
- BEGIN_OF("[" << _numproc << "] TestMPIComponentEngine::SPCoucou()");
+ BEGIN_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()");
MESSAGE("[" << _numproc << "] TestMPIComponentEngine : L = " << L);
- END_OF("[" << _numproc << "] TestMPIComponentEngine::SPCoucou()");
+ END_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()");
+ MPI_Barrier(MPI_COMM_WORLD);
}
extern "C"
# include "Utils_SINGLETON.hxx"
#include "SALOME_NamingService.hxx"
#include "OpUtil.hxx"
+#include "LocalTraceCollector.hxx"
using namespace std;
int main (int argc, char * argv[])
{
+ // Initializing omniORB
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ CORBA::ORB_var &orb = init( argc , argv ) ;
+ LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb);
+
+ BEGIN_OF(argv[0])
try{
int status;
- MESSAGE("COUCOU");
if( argc != 3 || strcmp(argv[1],"-np") ){
cout << "Usage: TestMPIContainer -np nbproc" << endl;
exit(0);
}
- // Initializing omniORB
- CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
-
// Obtain a reference to the root POA
CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ;
PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ;
string hostName = GetHostname();
containerName += hostName + "/MPIFactoryServer_" + argv[2];
- MESSAGE(containerName);
-
string dirn(getenv("KERNEL_ROOT_DIR"));
dirn += "/lib/salome/libSalomeTestMPIComponentEngine.so";
- MESSAGE(dirn.c_str());
// Try to resolve MPI Container
obj = NS.Resolve(containerName.c_str()) ;
- Engines::Container_var iGenFact = Engines::Container::_narrow(obj);
+ Engines::MPIContainer_var iGenFact = Engines::MPIContainer::_narrow(obj);
if(CORBA::is_nil(iGenFact)){
do{
sleep(1);
obj = NS.Resolve(containerName.c_str()) ;
- iGenFact = Engines::Container::_narrow(obj);
+ iGenFact = Engines::MPIContainer::_narrow(obj);
MESSAGE("Waiting for MPI Container " << containerName << " : it = " << it );
}while( CORBA::is_nil(iGenFact) && (it++<15) );
}
if(CORBA::is_nil(iGenFact)){
- MESSAGE("echec recuperation poignee container");
+ MESSAGE("launching container failed");
exit(1);
}
+
Engines::TestMPIComponent_var m1;
- for (int iter = 0; iter < 1 ; iter++){
- MESSAGE("----------------------------------------------------" << iter);
- obj = iGenFact->load_impl("TestMPIComponent",dirn.c_str());
+// for (int iter = 0; iter < 1 ; iter++){
+// MESSAGE("----------------------------------------------------" << iter);
+ obj = iGenFact->load_impl("TestMPIComponent",dirn.c_str());
- m1 = Engines::TestMPIComponent::_narrow(obj);
- if(CORBA::is_nil(m1)){
- INFOS("echec recuperation poignee composant");
- }
- else{
-
- INFOS("recup m1");
- SCRUTE(m1->instanceName());
- INFOS("Lancement de coucou");
- m1->Coucou(1L);
- INFOS("On remove le composant");
- iGenFact->remove_impl(m1) ;
- sleep(5);
- }
+ INFOS("Get Handle on MPI Component");
+ m1 = Engines::TestMPIComponent::_narrow(obj);
+ if(CORBA::is_nil(m1)){
+ INFOS("getting handle on MPI component failed");
+ }
+ else{
+ m1->Coucou(1L);
+// // sleep(5);
+ INFOS("Unload MPI Component");
+ iGenFact->remove_impl(m1) ;
}
- // Clean-up.
- iGenFact->finalize_removal() ;
- orb->destroy();
+// }
+// // Clean-up.
+// // iGenFact->finalize_removal() ;
+// // sleep(5);
+ iGenFact->MPIShutdown();
+// INFOS("shut down corba server for Test MPI Container");
+// orb->destroy();
}
catch(CORBA::COMM_FAILURE& ex) {
INFOS("Caught system exception COMM_FAILURE -- unable to contact the object.");
INFOS("Caught unknown exception.");
}
- return 0;
+ END_OF(argv[0]);
+ delete myThreadTrace;
+ return 0 ;
}