]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Adding a mew Method: getMachineFile for PaCO++ parallel container remote launch
authorribes <ribes>
Thu, 23 Apr 2009 09:52:54 +0000 (09:52 +0000)
committerribes <ribes>
Thu, 23 Apr 2009 09:52:54 +0000 (09:52 +0000)
Currently only works with the Dummy parallel library

src/ResourcesManager/SALOME_ResourcesManager.cxx
src/ResourcesManager/SALOME_ResourcesManager.hxx

index f558393410d6b12c1f81fc585b39426567493161..3a1bb029427c9b952250c7e4181102da257456b5 100644 (file)
@@ -25,6 +25,7 @@
 #include "OpUtil.hxx"
 
 #include <stdlib.h>
+#include <stdio.h>
 #ifndef WIN32
 #include <unistd.h>
 #else
@@ -238,3 +239,75 @@ Engines::MachineParameters* SALOME_ResourcesManager::GetMachineParameters(const
   return p_ptr;
 }
 
+std::string 
+SALOME_ResourcesManager::getMachineFile(std::string hostname, CORBA::Long nb_procs, 
+                                       std::string parallelLib)
+{
+  std::string machine_file_name("");
+
+  if (parallelLib == "Dummy")
+  {
+    MESSAGE("[getMachineFile] parallelLib is Dummy");
+    MapOfParserResourcesType resourcesList = _rm.GetList();
+    if (resourcesList.find(hostname) != resourcesList.end())
+    {
+      ParserResourcesType resource = resourcesList[hostname];
+
+      // Check if resource is cluster or not
+      if (resource.ClusterMembersList.empty())
+      {
+       //It is not a cluster so we create a cluster with one machine
+       ParserResourcesClusterMembersType fake_node;
+       fake_node.HostName = resource.HostName;
+       fake_node.Protocol = resource.Protocol;
+       fake_node.UserName = resource.UserName;
+       fake_node.AppliPath = resource.AppliPath;
+       fake_node.DataForSort = resource.DataForSort;
+
+       resource.ClusterMembersList.push_front(fake_node);
+      }
+
+      // Creating list of machines for creating the machine file
+      std::list<std::string> list_of_machines;
+      std::list<ParserResourcesClusterMembersType>::iterator cluster_it = 
+       resource.ClusterMembersList.begin();
+      while (cluster_it != resource.ClusterMembersList.end())
+      {
+       // For each member of the cluster we add a nbOfNodes * nbOfProcPerNode in the list
+       unsigned int number_of_proc = (*cluster_it).DataForSort._nbOfNodes * 
+                                     (*cluster_it).DataForSort._nbOfProcPerNode;
+       for (unsigned int i = 0; i < number_of_proc; i++)
+         list_of_machines.push_back((*cluster_it).HostName);
+       cluster_it++;
+      }
+
+      // Creating machine file
+      machine_file_name = tmpnam(NULL);
+      std::ofstream machine_file(machine_file_name.c_str(), ios_base::out);
+
+      CORBA::Long machine_number = 0;
+      std::list<std::string>::iterator it = list_of_machines.begin();
+      while (machine_number != nb_procs)
+      {
+       // Adding a new node to the machine file
+       machine_file << *it << endl;
+
+       // counting...
+       it++;
+       if (it == list_of_machines.end())
+         it = list_of_machines.begin();
+       machine_number++;
+      }
+    }
+    else
+      INFOS("[getMachineFile] Error hostname not found in resourcesList -> " << hostname);
+  }
+  else if (parallelLib == "Mpi")
+  {
+    MESSAGE("[getMachineFile] parallelLib is Mpi");
+  }
+  else
+    INFOS("[getMachineFile] Error parallelLib is not handled -> " << parallelLib);
+
+  return machine_file_name;
+}
index 959822e492b863a469b3f44219faee555169a283..9ad49734184808a75c7a6641ec73ac0330a63cad 100644 (file)
@@ -63,20 +63,21 @@ class SALOMERESOURCESMANAGER_EXPORT SALOME_ResourcesManager:
 
     ~SALOME_ResourcesManager();
 
+    // CORBA Methods
     Engines::MachineList *
     GetFittingResources(const Engines::MachineParameters& params,
                         const Engines::CompoList& componentList);
-
     char* FindFirst(const Engines::MachineList& listOfMachines);
-
     Engines::MachineParameters* GetMachineParameters(const char *hostname);
 
+    // Cpp Methods
     void Shutdown();
-
-    static const char *_ResourcesManagerNameInNS;
-
     ResourcesManager_cpp *GetImpl() { return &_rm; }
+    std::string getMachineFile(std::string hostname, CORBA::Long nb_procs,
+                              std::string parallelLib);
+
 
+    static const char *_ResourcesManagerNameInNS;
   protected:
     
     SALOME_NamingService *_NS;