LIB_CLIENT_IDL = Logger.idl SALOME_MPIObject.idl SALOME_TestMPIComponent.idl
# Executables targets
-BIN = TestMPIContainer TestBidon
+BIN = TestMPIContainer
BIN_SRC =
BIN_CLIENT_IDL = Logger.idl SALOME_MPIObject.idl SALOME_MPIContainer.idl SALOME_TestMPIComponent.idl
BIN_SERVER_IDL =
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : TestMPIComponentEngine.cxx
+// Created : mer jui 4 12:28:26 CEST 2003
+// Author : Bernard SECHER, 2003
+// Project : SALOME
+// Copyright : CEA 2003
+// $Header$
+//=============================================================================
+
+#include "utilities.h"
+#include "TestMPIComponentEngine.hxx"
+
+TestMPIComponentEngine::TestMPIComponentEngine(int nbproc, int numproc,
+ CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
+ const char *instanceName,
+ const char *interfaceName,
+ bool regist) :
+ Engines_Component_i(orb, poa, contId, instanceName, interfaceName,true,regist), MPIObject_i(nbproc,numproc)
+{
+ MESSAGE("activate object")
+ _thisObj = this ;
+ _id = _poa->activate_object(_thisObj);
+}
+
+TestMPIComponentEngine::TestMPIComponentEngine(): Engines_Component_i(), MPIObject_i()
+{
+}
+
+TestMPIComponentEngine::~TestMPIComponentEngine()
+{
+}
+
+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()");
+}
+
+void TestMPIComponentEngine::SPCoucou(CORBA::Long L)
+{
+ BEGIN_OF("[" << _numproc << "] TestMPIComponentEngine::SPCoucou()");
+ MESSAGE("[" << _numproc << "] TestMPIComponentEngine : L = " << L);
+ END_OF("[" << _numproc << "] TestMPIComponentEngine::SPCoucou()");
+}
+
+extern "C"
+{
+ PortableServer::ObjectId * TestMPIComponentEngine_factory(
+ int nbproc, int numproc,
+ CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
+ const char *instanceName,
+ const char *interfaceName)
+ {
+ bool regist;
+ TestMPIComponentEngine * myTestMPIComponent;
+ MESSAGE("[" << numproc << "] PortableServer::ObjectId * TestMPIComponentEngine_factory()");
+ SCRUTE(interfaceName);
+ if(numproc==0)
+ regist = true;
+ else
+ regist = false;
+
+ myTestMPIComponent
+ = new TestMPIComponentEngine(nbproc,numproc,orb, poa, contId, instanceName, interfaceName,regist);
+ return myTestMPIComponent->getId() ;
+ }
+}
+
--- /dev/null
+//=============================================================================
+// File : TestMPIComponentEngine.hxx
+// Created : mer jui 4 12:28:30 CEST 2003
+// Author : Bernard SECHER, CEA
+// Project : SALOME
+// Copyright : CEA 2003
+// $Header$
+//=============================================================================
+
+#ifndef _SALOME_TESTCOMPONENT_I_HXX_
+#define _SALOME_TESTCOMPONENT_I_HXX_
+
+#include <iostream.h>
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOME_TestMPIComponent)
+#include "SALOME_Component_i.hxx"
+#include "MPIObject_i.hxx"
+
+class TestMPIComponentEngine:
+ public POA_Engines::TestMPIComponent,
+ public Engines_Component_i, public MPIObject_i
+{
+public:
+ TestMPIComponentEngine();
+ TestMPIComponentEngine(int nbproc, int numproc,
+ CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
+ const char *instanceName,
+ const char *interfaceName,
+ bool regist);
+
+ virtual ~TestMPIComponentEngine();
+
+ void Coucou(CORBA::Long L);
+ void SPCoucou(CORBA::Long L);
+
+};
+
+#endif
--- /dev/null
+// using namespace std;
+//=============================================================================
+// File : TestMPIContainer.cxx
+// Created : mer jui 4 13:11:27 CEST 2003
+// Author : Bernard SECHER, 2003
+// Project : SALOME
+// Copyright : CEA 2003
+// $Header$
+//=============================================================================
+
+#include "utilities.h"
+#include <iostream>
+#include <unistd.h>
+#include <string>
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SALOME_MPIContainer)
+#include CORBA_CLIENT_HEADER(SALOME_TestMPIComponent)
+
+# include "Utils_ORB_INIT.hxx"
+# include "Utils_SINGLETON.hxx"
+#include "SALOME_NamingService.hxx"
+#include "OpUtil.hxx"
+
+int main (int argc, char * argv[])
+{
+
+ 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) ;
+
+ // Use Name Service to find container
+ SALOME_NamingService NS(orb) ;
+ string containerName = "/Containers/" ;
+ 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);
+
+ if(CORBA::is_nil(iGenFact)){
+
+ // Launch MPI Container
+ string cmd("mpirun -np ");
+ cmd += argv[2];
+ cmd += " ";
+ cmd += getenv("KERNEL_ROOT_DIR");
+ cmd += "/bin/salome/SALOME_MPIContainer MPIFactoryServer_";
+ cmd += argv[2];
+ cmd += " &";
+ MESSAGE(cmd);
+ status = system(cmd.c_str());
+ if (status == -1) {
+ INFOS("TestMPIContainer launch MPI Container failed (system command status -1)") ;
+ }
+ else if (status == 217) {
+ INFOS("TestMPIContainer launch MPI Container failed (system command status 217)") ;
+ }
+
+ // Try to resolve MPI Container
+ int it = 0;
+ do{
+ sleep(1);
+ obj = NS.Resolve(containerName.c_str()) ;
+ iGenFact = Engines::Container::_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");
+ exit(1);
+ }
+
+ Engines::TestMPIComponent_var m1;
+
+ 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);
+ }
+ }
+ // Clean-up.
+ iGenFact->finalize_removal() ;
+ orb->destroy();
+ }
+ catch(CORBA::COMM_FAILURE& ex) {
+ INFOS("Caught system exception COMM_FAILURE -- unable to contact the object.");
+ }
+ catch(CORBA::SystemException&) {
+ INFOS("Caught a CORBA::SystemException.");
+ }
+ catch(CORBA::Exception&) {
+ INFOS("Caught CORBA::Exception.");
+ }
+ catch(...) {
+ INFOS("Caught unknown exception.");
+ }
+
+ return 0;
+}