From f6583038012426d6cac73f42c2af98cefc1c425f Mon Sep 17 00:00:00 2001 From: ribes Date: Thu, 23 Apr 2009 09:52:54 +0000 Subject: [PATCH] Adding a mew Method: getMachineFile for PaCO++ parallel container remote launch Currently only works with the Dummy parallel library --- .../SALOME_ResourcesManager.cxx | 73 +++++++++++++++++++ .../SALOME_ResourcesManager.hxx | 11 +-- 2 files changed, 79 insertions(+), 5 deletions(-) diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index f55839341..3a1bb0294 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -25,6 +25,7 @@ #include "OpUtil.hxx" #include +#include #ifndef WIN32 #include #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 list_of_machines; + std::list::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::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; +} diff --git a/src/ResourcesManager/SALOME_ResourcesManager.hxx b/src/ResourcesManager/SALOME_ResourcesManager.hxx index 959822e49..9ad497341 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.hxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.hxx @@ -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; -- 2.39.2