]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
- Adding PaCO++ files for idl generation
authorribes <ribes>
Tue, 10 Apr 2007 14:35:03 +0000 (14:35 +0000)
committerribes <ribes>
Tue, 10 Apr 2007 14:35:03 +0000 (14:35 +0000)
- Adding methods to the resources manager and
- the container manager for launching parallel container.

13 files changed:
idl/DSC_Engines.idl
idl/DSC_Engines.xml [new file with mode: 0644]
idl/Makefile.am
idl/SALOME_Component.idl
idl/SALOME_Component.xml [new file with mode: 0644]
idl/SALOME_ContainerManager.idl
idl/SALOME_Ports.idl
idl/SALOME_Ports.xml [new file with mode: 0644]
src/Container/Makefile.am
src/Container/SALOME_ContainerManager.cxx
src/Container/SALOME_ContainerManager.hxx
src/ResourcesManager/SALOME_ResourcesManager.cxx
src/ResourcesManager/SALOME_ResourcesManager.hxx

index c81968158051dec57f7005d1937fd709368d21b0..e473fc35a281b0010393a5d554dbed2df3ff6564 100644 (file)
@@ -18,7 +18,7 @@
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //  File   : DSC_Engines.idl
-//  Author : André RIBES, EDF
+//  Author : Andre RIBES, EDF
 //  $Header:
 
 #ifndef _DSC_ENGINES_IDL_
diff --git a/idl/DSC_Engines.xml b/idl/DSC_Engines.xml
new file mode 100644 (file)
index 0000000..6a27f45
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<GridCCM_Interface_description
+      xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+      xsi:noNamespaceSchemaLocation='$PACOPATH/IDL2Tool/interface.xsd'
+>
+
+<Module>
+ <Name>Engines</Name>
+ <Interface>
+  <Name>DSC</Name>
+  <Method>
+   <Name>connect_provides_port</Name>
+   <Type>distributed</Type>
+ </Method>
+ <Method>
+   <Name>connect_uses_port</Name>
+   <Type>distributed</Type>
+ </Method>
+ </Interface>
+ <Interface>
+   <Name>Parallel_DSC</Name>
+   <Method>
+     <Name>set_paco_proxy</Name>
+     <Type>distributed</Type>
+   </Method>
+   <Method>
+     <Name>init_service</Name>
+     <Type>distributed</Type>
+   </Method>
+ </Interface>
+</Module>
+</GridCCM_Interface_description>
index d2364a53b65510179d3bf6ad25b381db5fcb562c..df3667ab6ee5eda544bd61bb57f793563cdf354a 100644 (file)
@@ -26,6 +26,9 @@
 
 include $(top_srcdir)/salome_adm/unix/make_common_starter.am
 
+# To avoid problems with parallel compilation.
+MAKEFLAGS = -j1
+
 BASEIDL_FILES = \
   SALOME_Exception.idl \
   SALOME_Comm.idl \
@@ -102,17 +105,69 @@ endif
 # also install all generated headers to use result library from another modules
 #salomeinclude_DATA= $(IDL_SOURCES:%SK.cc=%.hh)
 
-BUILT_SOURCES = $(IDL_SOURCES)
+if WITH_PACO_PARALLEL
+PAR = SALOME_ComponentPaCO.h SALOME_ComponentPaCO.cc \
+      SALOME_PortsPaCO.h SALOME_PortsPaCO.cc \
+      DSC_EnginesPaCO.h DSC_EnginesPaCO.cc 
+
+PAR_LIB = libSalomeParallelIDLKernel.la
+
+IDL_PACO      = SALOME_ComponentPaCO.idl SALOME_PortsPaCO.idl DSC_EnginesPaCO.idl
+
+GEN_PACO = SALOME_ComponentPaCO_Engines_Container_server.cc \
+          SALOME_ComponentPaCO_Engines_Container_client.cc \
+          SALOME_ComponentPaCO_Engines_Component_server.cc \
+          SALOME_ComponentPaCO_Engines_Component_client.cc \
+          SALOME_PortsPaCO_Ports_Port_server.cc \
+          SALOME_PortsPaCO_Ports_Port_client.cc \
+          DSC_EnginesPaCO_Engines_DSC_server.cc \
+          DSC_EnginesPaCO_Engines_DSC_client.cc \
+          DSC_EnginesPaCO_Engines_Parallel_DSC_server.cc \
+          DSC_EnginesPaCO_Engines_Parallel_DSC_client.cc
+
+INCLUDES_PACO = SALOME_ComponentPaCO_Engines_Container_server.h \
+               SALOME_ComponentPaCO_Engines_Container_client.h \
+                SALOME_ComponentPaCO_Engines_Component_server.h \
+               SALOME_ComponentPaCO_Engines_Component_client.h \
+               SALOME_ComponentPaCO.h \
+               SALOME_PortsPaCO_Ports_Port_server.h \
+               SALOME_PortsPaCO_Ports_Port_client.h \
+               SALOME_PortsPaCO.h \
+               DSC_EnginesPaCO_Engines_DSC_server.h \
+               DSC_EnginesPaCO_Engines_DSC_client.h \
+               DSC_EnginesPaCO_Engines_Parallel_DSC_server.h \
+               DSC_EnginesPaCO_Engines_Parallel_DSC_client.h \
+               DSC_EnginesPaCO.h
+
+XML           = SALOME_Component.xml DSC_Engines.xml SALOME_Ports.xml
+endif
+
+idldir = $(prefix)/idl/salome
+nodist_idl_DATA = ${XML} ${IDL_PACO} 
+nodist_include_HEADERS = ${INCLUDES_PACO} 
+
+BUILT_SOURCES = $(IDL_SOURCES) $(PAR)
 
-lib_LTLIBRARIES = libSalomeIDLKernel.la
-nodist_libSalomeIDLKernel_la_SOURCES = $(BUILT_SOURCES)
-libSalomeIDLKernel_la_CPPFLAGS =\
-       -I$(top_builddir)/salome_adm/unix \
-       -I$(top_builddir)/idl \
-       @CORBA_CXXFLAGS@ @CORBA_INCLUDES@
+SALOME_ComponentPaCO.h SALOME_ComponentPaCO.cc : SALOME_Component.idl SALOME_Component.xml
+SALOME_PortsPaCO.h SALOME_PortsPaCO.cc : SALOME_Ports.idl SALOME_Ports.xml
+DSC_EnginesPaCO.h DSC_EnginesPaCO.cc : DSC_Engines.idl DSC_Engines.xml
+
+lib_LTLIBRARIES = libSalomeIDLKernel.la $(PAR_LIB)
+
+nodist_libSalomeIDLKernel_la_SOURCES = $(IDL_SOURCES)
+libSalomeIDLKernel_la_CPPFLAGS =-I$(top_builddir)/salome_adm/unix \
+                               -I$(top_builddir)/idl \
+                               @CORBA_CXXFLAGS@ @CORBA_INCLUDES@
 libSalomeIDLKernel_la_LDFLAGS = -no-undefined -version-info=0:0:0
 libSalomeIDLKernel_la_LIBADD  = @CORBA_LIBS@
 
+nodist_libSalomeParallelIDLKernel_la_SOURCES = $(PAR) $(GEN_PACO)
+libSalomeParallelIDLKernel_la_CPPFLAGS =-I$(top_builddir)/idl \
+                                       @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ \
+                                       @PACO_INCLUDES@
+libSalomeParallelIDLKernel_la_LDFLAGS = -no-undefined -version-info=0:0:0
+libSalomeParallelIDLKernel_la_LIBADD  = libSalomeIDLKernel.la @PACO_LIBS@
+
 # These variables defines the building process of CORBA files
 OMNIORB_IDL         = @OMNIORB_IDL@
 OMNIORB_IDLCXXFLAGS = @OMNIORB_IDLCXXFLAGS@
@@ -127,6 +182,8 @@ SUFFIXES = .idl .hh SK.cc
 .idl.hh:
        $(OMNIORB_IDL) $(IDLCXXFLAGS) $(OMNIORB_IDLCXXFLAGS) $<
 
+%PaCO.h %PaCO.cc : %.idl %.xml
+       @PACO_IDL@ -I $(srcdir):@PACOPATH@/idl $^ omniORB4 0
 
 install-exec-local: $(IDL_FILES:%=$(top_srcdir)/idl/%)
        $(INSTALL) -d  $(pkgpythondir)
@@ -157,3 +214,6 @@ mostlyclean-local:
 
 -include .depidl
 
+CLEANFILES = *PaCO* *.h
+EXTRA_DIST = SALOME_Component.xml DSC_Engines.xml SALOME_Ports.xml
+
index 5503ed3f200b3cd034bb3ab091c644795e46a428..d750af3776b2e88499f9c1be1a82e1089ab086dc 100644 (file)
@@ -81,8 +81,8 @@ module Engines
                             >0 otherwise (== study id)
       \return a loaded component
     */
-    Component create_component_instance(in string componentName,
-                                       in long studyId);
+    Engines::Component create_component_instance(in string componentName,
+                                                 in long studyId);
 
     /*!
       Finds a servant instance of a component
diff --git a/idl/SALOME_Component.xml b/idl/SALOME_Component.xml
new file mode 100644 (file)
index 0000000..2dddce1
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<GridCCM_Interface_description
+      xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+      xsi:noNamespaceSchemaLocation='$PACOPATH/IDL2Tool/interface.xsd'
+>
+
+<Module>
+ <Name>Engines</Name>
+ <Interface>
+  <Name>Container</Name>
+  <Method>
+   <Name>ping</Name>
+   <Type>distributed</Type>
+  </Method>
+  <Method>
+   <Name>create_component_instance</Name>
+   <Type>distributed</Type>
+  </Method>
+  <Method>
+   <Name>load_component_Library</Name>
+   <Type>distributed</Type>
+  </Method>
+ </Interface>
+ <Interface>
+  <Name>Component</Name>
+  <Method>
+   <Name>ping</Name>
+   <Type>distributed</Type>
+  </Method>
+ </Interface>
+</Module>
+</GridCCM_Interface_description>
index e2999e9e8e9faec2a3d965d10fecd1878b24ed79..9814c828f231cb88d501635b82ef88940ca2c989 100644 (file)
@@ -39,6 +39,10 @@ struct MachineParameters
   long nb_proc_per_node;
   long nb_node;
   boolean isMPI;
+
+  // PaCO specific informations
+  string parallelLib;
+  long nb_component_nodes;
 };
 
 /*!
@@ -61,6 +65,17 @@ struct MachineParameters
     Container FindOrStartContainer( in MachineParameters params,
                                    in MachineList possibleComputers);
 
+    /*!
+      This operation launches a PaCO++ container.
+
+      \param Description of the container resquested.
+      \param List of computers ressources.
+
+      \return Container's CORBA reference.
+    */
+    Container FindOrStartParallelContainer( in MachineParameters params,
+                                           in MachineList possibleComputers);
+
     string FindBest(in MachineList possibleComputers);
 
     MachineList GetFittingResources( in MachineParameters params,
index 9be003c82493c34a8e6e01ba0e60cb847e905892..eac841f906d0a535dda3582168f8251db8877855 100644 (file)
@@ -18,7 +18,7 @@
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //  File   : SALOME_Ports.idl
-//  Author : André RIBES, EDF
+//  Author : Andre RIBES, EDF
 //  $Header:
 
 #ifndef _SALOME_PORTS_IDL_
diff --git a/idl/SALOME_Ports.xml b/idl/SALOME_Ports.xml
new file mode 100644 (file)
index 0000000..1e51a31
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<GridCCM_Interface_description
+      xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+      xsi:noNamespaceSchemaLocation='$PACOPATH/IDL2Tool/interface.xsd'
+>
+
+<Module>
+ <Name>Ports</Name>
+ <Interface>
+  <Name>Port</Name>
+ </Interface>
+ <Interface>
+  <Name>Control_Port</Name>
+ </Interface>
+</Module>
+</GridCCM_Interface_description>
index 4b633933a2bb02b2a0f16cbd83b3e9ed7b29ffe3..34b2f9e0064befe21c2f251feabf5dedc231d282 100644 (file)
@@ -74,7 +74,7 @@ COMMON_CPPFLAGS=\
        -I$(srcdir)/../ResourcesManager \
        -I$(top_builddir)/salome_adm/unix \
        -I$(top_builddir)/idl \
-       @CORBA_CXXFLAGS@ @CORBA_INCLUDES@
+       @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ 
 
 # This local variable defines the list of dependant libraries common to all target in this package.
 COMMON_LIBS =\
@@ -101,7 +101,6 @@ libSalomeContainer_la_SOURCES=\
        Container_i.cxx \
        SALOME_FileTransfer_i.cxx \
        SALOME_FileRef_i.cxx \
-       SALOME_ContainerManager.cxx \
        Container_init_python.cxx 
 
 libSalomeContainer_la_CPPFLAGS =\
@@ -128,15 +127,14 @@ SALOME_Container_SOURCES =\
 SALOME_Container_CPPFLAGS =\
        $(COMMON_CPPFLAGS)
 
-
 SALOME_Container_LDADD =\
        libSalomeContainer.la \
        $(COMMON_LIBS) \
        ../Basics/libSALOMEBasics.la
 
-
 SALOME_ContainerManagerServer_SOURCES =\
-       SALOME_ContainerManagerServer.cxx
+       SALOME_ContainerManagerServer.cxx \
+       SALOME_ContainerManager.cxx
 
 SALOME_ContainerManagerServer_CPPFLAGS=\
        $(COMMON_CPPFLAGS)
@@ -144,4 +142,10 @@ SALOME_ContainerManagerServer_CPPFLAGS=\
 SALOME_ContainerManagerServer_LDADD =\
        libSalomeContainer.la \
        $(COMMON_LIBS) \
-       ../Basics/libSALOMEBasics.la
+       ../Basics/libSALOMEBasics.la 
+
+if WITH_PACO_PARALLEL
+SALOME_ContainerManagerServer_CPPFLAGS += -DWITH_PACO_PARALLEL @PACO_INCLUDES@
+SALOME_ContainerManagerServer_LDADD += @PACO_LIBS@
+endif
+
index 8998aa2e32d6c8bdd33e1f335abe6dc42b5a5461..ebe204223121f50f03efc122736de06f752505d6 100644 (file)
 #include <vector>
 #include "Utils_CorbaException.hxx"
 
+#ifdef WITH_PACO_PARALLEL
+#include "PaCO++.h"
+#endif
+
 #define TIME_OUT_TO_LAUNCH_CONT 21
 
 using namespace std;
@@ -240,6 +244,140 @@ FindOrStartContainer(const Engines::MachineParameters& params,
     }
 }
 
+#ifdef WITH_PACO_PARALLEL
+//=============================================================================
+/*! CORBA Method:
+ *  Find or Start a suitable PaCO++ Parallel Container in a list of machines.
+ *  \param params            Machine Parameters required for the container
+ *  \param possibleComputers list of machines usable for find or start
+ *
+ *  \return CORBA container reference.
+ */
+//=============================================================================
+Engines::Container_ptr
+SALOME_ContainerManager::
+FindOrStartParallelContainer(const Engines::MachineParameters& params_const,
+                            const Engines::MachineList& possibleComputers)
+{
+  CORBA::Object_var obj;
+  Engines::Container_ptr ret = Engines::Container::_nil();
+  Engines::MachineParameters params(params_const);
+
+  // Step 1 : Try to find a suitable container
+  // Currently not as good as could be since
+  // we have to verified the number of nodes of the container
+  // if a user tell that.
+  ret = FindContainer(params, possibleComputers);
+
+  if(CORBA::is_nil(ret)) {
+    // Step 2 : Starting a new parallel container
+    INFOS("[FindOrStartParallelContainer] Starting a parallel container");
+    
+    // Step 2.1 : Choose a computer
+    string theMachine = _ResManager->FindBest(possibleComputers);
+    if(theMachine == "") {
+      INFOS("[FindOrStartParallelContainer] !!!!!!!!!!!!!!!!!!!!!!!!!!");
+      INFOS("[FindOrStartParallelContainer] No possible computer found");
+      INFOS("[FindOrStartParallelContainer] !!!!!!!!!!!!!!!!!!!!!!!!!!");
+    }
+    else {
+      INFOS("[FindOrStartParallelContainer] on machine : " << theMachine);
+      string command;
+      if(theMachine == GetHostname()) {
+       // Step 3 : starting parallel container proxy
+       params.hostname = CORBA::string_dup(theMachine.c_str());
+       Engines::MachineParameters params_proxy(params);
+       command = _ResManager->BuildCommandToLaunchLocalParallelContainer("SALOME_ParallelContainerProxy", params_proxy, "xterm");
+       // LaunchParallelContainer uses this value to know if it launches the proxy or the nodes
+       params_proxy.nb_component_nodes = 0;
+       obj = LaunchParallelContainer(command, params_proxy, _NS->ContainerName(params));
+       ret = Engines::Container::_narrow(obj);
+
+       // Step 4 : starting parallel container nodes
+       command = _ResManager->BuildCommandToLaunchLocalParallelContainer("SALOME_ParallelContainerNode", params, "xterm");
+       string name = _NS->ContainerName(params) + "Node";
+       LaunchParallelContainer(command, params, name);
+
+       // Step 5 : connecting nodes and the proxy to actually create a parallel container
+       try {
+       for (int i = 0; i < params.nb_component_nodes; i++) {
+
+       char buffer [5];
+       snprintf(buffer,5,"%d",i);
+       string name_cont = name + string(buffer);
+
+       string theNodeMachine(CORBA::string_dup(params.hostname));
+       string containerNameInNS = _NS->BuildContainerNameForNS(name_cont.c_str(),theNodeMachine.c_str());
+       int count = TIME_OUT_TO_LAUNCH_CONT;
+       obj = _NS->Resolve(containerNameInNS.c_str());
+       while (CORBA::is_nil(obj) && count) {
+         INFOS("[FindOrStartParallelContainer] CONNECTION FAILED !!!!!!!!!!!!!!!!!!!!!!!!");
+#ifndef WNT
+         sleep(1) ;
+#else
+         Sleep(1000);
+#endif
+         count-- ;
+         obj = _NS->Resolve(containerNameInNS.c_str());
+       }
+
+       PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(obj);
+       MESSAGE("[FindOrStartParallelContainer] Deploying node : " << name);
+       node->deploy(i);
+       }
+       }
+       catch(CORBA::SystemException& e)
+       {
+         INFOS("Caught CORBA::SystemException. : " << e);
+       }
+       catch(PortableServer::POA::ServantAlreadyActive&)
+       {
+         INFOS("Caught CORBA::ServantAlreadyActiveException");
+       }
+       catch(CORBA::Exception&)
+       {
+         INFOS("Caught CORBA::Exception.");
+       }
+       catch(std::exception& exc)
+       {
+         INFOS("Caught std::exception - "<<exc.what()); 
+       }
+       catch(...)
+       {
+         INFOS("Caught unknown exception.");
+       }
+       INFOS("[FindOrStartParallelContainer] node " << name << " deployed");
+      }
+
+      else {
+       INFOS("[FindOrStartParallelContainer] Currently parallel containers are launched only on the local host");
+      }
+    }
+  }
+  return ret;
+}
+#else
+//=============================================================================
+/*! CORBA Method:
+ *  Find or Start a suitable PaCO++ Parallel Container in a list of machines.
+ *  \param params            Machine Parameters required for the container
+ *  \param possibleComputers list of machines usable for find or start
+ *
+ *  \return CORBA container reference.
+ */
+//=============================================================================
+Engines::Container_ptr
+SALOME_ContainerManager::
+FindOrStartParallelContainer(const Engines::MachineParameters& params,
+                            const Engines::MachineList& possibleComputers)
+{
+  Engines::Container_ptr ret = Engines::Container::_nil();
+  INFOS("[FindOrStartParallelContainer] is disabled !");
+  INFOS("[FindOrStartParallelContainer] recompile SALOME Kernel to enable parallel extension");
+  return ref;
+}
+#endif
+
 //=============================================================================
 /*! 
  * 
@@ -330,6 +468,91 @@ FindContainer(const Engines::MachineParameters& params,
   return Engines::Container::_nil();
 }
 
+//=============================================================================
+/*! This method launches the parallel container.
+ *  It will may be placed on the ressources manager.
+ *
+ * \param command to launch
+ * \param container's parameters
+ * \param name of the container
+ *
+ * \return CORBA container reference
+ */
+//=============================================================================
+CORBA::Object_ptr 
+SALOME_ContainerManager::LaunchParallelContainer(const std::string& command, 
+                                                const Engines::MachineParameters& params,
+                                                const std::string& name)
+{
+  CORBA::Object_ptr obj = CORBA::Object::_nil();
+  string containerNameInNS;
+
+  if (params.nb_component_nodes == 0) {
+    INFOS("[LaunchParallelContainer] launching the proxy of the parallel container");
+    int status = system(command.c_str());
+    if (status == -1) {
+      INFOS("[LaunchParallelContainer] failed : system command status -1");
+    }
+    else if (status == 217) {
+      INFOS("[LaunchParallelContainer] failed : system command status 217");
+    }
+
+    int count = TIME_OUT_TO_LAUNCH_CONT;
+    string theMachine(CORBA::string_dup(params.hostname));
+    containerNameInNS = _NS->BuildContainerNameForNS((char*) name.c_str(),theMachine.c_str());
+
+    INFOS("[LaunchContainer]  Waiting for Parallel Container proxy on " << theMachine);
+    while (CORBA::is_nil(obj) && count) {
+#ifndef WNT
+      sleep(1) ;
+#else
+      Sleep(1000);
+#endif
+      count-- ;
+      obj = _NS->Resolve(containerNameInNS.c_str());
+    }
+  }
+  else {
+    INFOS("[LaunchParallelContainer] launching the nodes of the parallel container");
+    int status = system(command.c_str());
+    if (status == -1) {
+      INFOS("[LaunchParallelContainer] failed : system command status -1");
+    }
+    else if (status == 217) {
+      INFOS("[LaunchParallelContainer] failed : system command status 217");
+    }
+    // We are waiting all the nodes
+    for (int i = 0; i < params.nb_component_nodes; i++) {
+      obj = CORBA::Object::_nil();
+      int count = TIME_OUT_TO_LAUNCH_CONT;
+
+      // Name of the node
+      char buffer [5];
+      snprintf(buffer,5,"%d",i);
+      string name_cont = name + string(buffer);
+
+      // I don't like this...
+      string theMachine(CORBA::string_dup(params.hostname));
+      containerNameInNS = _NS->BuildContainerNameForNS((char*) name_cont.c_str(),theMachine.c_str());
+      cerr << "[LaunchContainer]  Waiting for Parllel Container node " << containerNameInNS << " on " << theMachine << endl;
+      while (CORBA::is_nil(obj) && count) {
+#ifndef WNT
+       sleep(1) ;
+#else
+       Sleep(1000);
+#endif
+       count-- ;
+       obj = _NS->Resolve(containerNameInNS.c_str());
+      }
+    }
+  }
+
+  if ( CORBA::is_nil(obj) ) {
+    INFOS("[LaunchParallelContainer] failed");
+  }
+  return obj;
+}
+
 //=============================================================================
 /*! 
  * Get Id for container: a parallel container registers in Naming Service
index d74988084cc78050d98abce9a0da77aa2b963d65..9369135e99bc4bab8273314ee0e9230493338e96 100644 (file)
@@ -56,6 +56,10 @@ public:
 
   static const char *_ContainerManagerNameInNS;
 
+  // Parallel extension
+  Engines::Container_ptr
+  FindOrStartParallelContainer(const Engines::MachineParameters& params,
+                              const Engines::MachineList& possibleComputer);
 protected:
   Engines::Container_ptr
   FindContainer(const Engines::MachineParameters& params,
@@ -65,6 +69,12 @@ protected:
   FindContainer(const Engines::MachineParameters& params,
                const char *theMachine);
 
+  // Parallel extension
+  CORBA::Object_ptr 
+  LaunchParallelContainer(const std::string& command, 
+                         const Engines::MachineParameters& params,
+                         const std::string& name);
+
   long GetIdForContainer(void);
   long _id;
 
index 9a7b615a06765846b1ddb76928f4695fbd9d6380..67bb35f752f1d5c419bd5bd15819ca60994a8124 100644 (file)
@@ -58,6 +58,7 @@ SALOME_ResourcesManager(CORBA::ORB_ptr orb,
     _path_resources(xmlFilePath)
 {
   _NS = new SALOME_NamingService(orb);
+  _MpiStarted = false;
 }
 
 //=============================================================================
@@ -75,6 +76,7 @@ SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb)
 {
   _NS = new SALOME_NamingService(orb);
   _isAppliSalomeDefined = (getenv("APPLI") != 0);
+  _MpiStarted = false;
 
   if (_isAppliSalomeDefined)
     {
@@ -902,6 +904,139 @@ SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer
 
 }
 
+//=============================================================================
+/*! Creates a command line that the container manager uses to launch
+ * a parallel container.
+ */ 
+//=============================================================================
+string 
+SALOME_ResourcesManager::BuildCommandToLaunchLocalParallelContainer(const std::string& exe_name,
+                                                                   const Engines::MachineParameters& params,
+                                                                   const std::string& log)
+{
+  // This method knows the differences between the proxy and the nodes.
+  // nb_component_nodes is not used in the same way if it is a proxy or 
+  // a node.
 
+  string command;
+  string parallelLib(CORBA::string_dup(params.parallelLib));
+  string hostname(CORBA::string_dup(params.hostname));
+  int par = exe_name.find("Proxy");
+  int nbproc = params.nb_component_nodes;
+  char buffer [33];
+  sprintf(buffer,"%d",nbproc);
+
+  Engines::MachineParameters_var rtn = new Engines::MachineParameters();
+  rtn->container_name = params.container_name;
+  rtn->hostname = params.hostname;
+  rtn->OS = params.OS;
+  rtn->mem_mb = params.mem_mb;
+  rtn->cpu_clock = params.cpu_clock;
+  rtn->nb_proc_per_node = params.nb_proc_per_node;
+  rtn->nb_node = params.nb_node;
+  rtn->isMPI = params.isMPI;
+
+  string real_exe_name  = exe_name + parallelLib;
+
+  if (parallelLib == "Dummy")
+  {
+    //command = "gdb --args ";
+    //command += real_exe_name;
+    command = real_exe_name;
+    command += " " + _NS->ContainerName(rtn);
+    command += " " + parallelLib;
+    command += " " + hostname;
+    command += " -";
+    AddOmninamesParams(command);
+  }
+
+  if (parallelLib == "Mpi")
+  {
+    // Step 1 : check if MPI is started
+    if (_MpiStarted == false)
+    {
+      startMPI();
+    }
+
+    if (par < 0)
+    {
+      // Nodes case
+      command = "mpiexec -np " + string(buffer) + " ";
+      command += real_exe_name;
+      command += " " + _NS->ContainerName(rtn);
+      command += " " + parallelLib;
+      command += " " + hostname;
+      command += " -";
+      AddOmninamesParams(command);
+    }
+    else                                          
+    {
+      // Proxy case
+      command = "mpiexec -np 1 ";
+      command += real_exe_name;
+      command += " " + _NS->ContainerName(rtn);
+      command += " " + string(buffer);
+      command += " " + parallelLib;
+      command += " " + hostname;
+      command += " -";
+      AddOmninamesParams(command);
+    }
+  }
+
+  // log choice
+  if (log == "default")
+  {
+    command += " > /tmp/";
+    command += _NS->ContainerName(rtn);
+    command += "_";
+    command += GetHostname();
+    command += "_";
+    command += getenv( "USER" ) ;
+    command += ".log 2>&1 &" ;
+  }
+  if (log == "xterm")
+  {
+    command = "/usr/X11R6/bin/xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH;  " 
+      + command + " \" &";
+  }
+  return command;
+
+/*  if (log == "xterm")
+  {
+    command = "/usr/X11R6/bin/xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH; echo $LD_LIBRARY_PATH; echo $PATH; " + command + "; cat \" &";
+  }
+*/
+/*  command = "cd ; rm " + fichier_commande + "; touch " + \
+            fichier_commande + "; echo \" export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; " + \
+            command + " >& /tmp/ribes_" + fichier_commande + " & \" > " + fichier_commande + ";";
+  command += "ssh cn01 sh " + fichier_commande + " &";
+  cerr << "La commande : " << command << endl;
+*/
+}
+
+void SALOME_ResourcesManager::startMPI()
+{
+  cerr << "----------------------------------------------" << endl;
+  cerr << "----------------------------------------------" << endl;
+  cerr << "----------------------------------------------" << endl;
+  cerr << "-Only Lam on Localhost is currently supported-" << endl;
+  cerr << "----------------------------------------------" << endl;
+  cerr << "----------------------------------------------" << endl;
+  cerr << "----------------------------------------------" << endl;
+
+  int status = system("lamboot");
+  if (status == -1)
+  {
+    INFOS("lamboot failed : system command status -1");
+  }
+  else if (status == 217)
+  {
+    INFOS("lamboot failed : system command status 217");
+  }
+  else
+  {
+    _MpiStarted = true;
+  }
+}
 
 
index 9d17619a31866db40d6d48e582395a1acf2ecc89..e9699380803fa6b94e1b318904903ca5bb13f016 100644 (file)
@@ -84,7 +84,16 @@ class RESOURCESMANAGER_EXPORT SALOME_ResourcesManager
 
     const MapOfParserResourcesType& GetList() const;
 
+    // Parallel extension
+    std::string BuildCommandToLaunchLocalParallelContainer(const std::string& exe_name, 
+                                                          const Engines::MachineParameters& params, 
+                                                          const std::string& log = "default");
   protected:
+    
+    // Parallel extension
+    void startMPI();
+    bool _MpiStarted;
+
     SALOME_NamingService *_NS;
 
     std::string BuildTempFileToLaunchRemoteContainer