From 4a8e8db6347cfb9a5f83e8d11955a8c486bd3345 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Tue, 13 Dec 2016 11:35:24 +0100 Subject: [PATCH] preprocessor: parallel: add NumberOfThreadsPerJob option. #1349 --- preprocessor/ConfigFile.cc | 21 ++++++++++++++------- preprocessor/ConfigFile.hh | 7 ++++--- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/preprocessor/ConfigFile.cc b/preprocessor/ConfigFile.cc index f40a49be1..d1fbd8b7b 100644 --- a/preprocessor/ConfigFile.cc +++ b/preprocessor/ConfigFile.cc @@ -52,11 +52,12 @@ Path::Path(vector &includepath_arg) SlaveNode::SlaveNode(string &computerName_arg, string port_arg, int minCpuNbr_arg, int maxCpuNbr_arg, string &userName_arg, string &password_arg, string &remoteDrive_arg, string &remoteDirectory_arg, - string &dynarePath_arg, string &matlabOctavePath_arg, bool singleCompThread_arg, + string &dynarePath_arg, string &matlabOctavePath_arg, bool singleCompThread_arg, int numberOfThreadsPerJob_arg, string &operatingSystem_arg) : computerName(computerName_arg), port(port_arg), minCpuNbr(minCpuNbr_arg), maxCpuNbr(maxCpuNbr_arg), userName(userName_arg), password(password_arg), remoteDrive(remoteDrive_arg), remoteDirectory(remoteDirectory_arg), dynarePath(dynarePath_arg), - matlabOctavePath(matlabOctavePath_arg), singleCompThread(singleCompThread_arg), operatingSystem(operatingSystem_arg) + matlabOctavePath(matlabOctavePath_arg), singleCompThread(singleCompThread_arg), numberOfThreadsPerJob(numberOfThreadsPerJob_arg), + operatingSystem(operatingSystem_arg) { if (computerName.empty()) { @@ -163,6 +164,7 @@ ConfigFile::getConfigFileInfo(const string &config_file) global_init_file; vector includepath; int minCpuNbr = 0, maxCpuNbr = 0; + int numberOfThreadsPerJob = 1; bool singleCompThread = false; member_nodes_t member_nodes; @@ -194,7 +196,7 @@ ConfigFile::getConfigFileInfo(const string &config_file) addParallelConfFileElement(inNode, inCluster, member_nodes, name, computerName, port, minCpuNbr, maxCpuNbr, userName, password, remoteDrive, remoteDirectory, - dynarePath, matlabOctavePath, singleCompThread, + dynarePath, matlabOctavePath, singleCompThread, numberOfThreadsPerJob, operatingSystem); //! Reset communication vars / option defaults @@ -232,6 +234,7 @@ ConfigFile::getConfigFileInfo(const string &config_file) = operatingSystem = global_init_file = ""; includepath.clear(); minCpuNbr = maxCpuNbr = 0; + numberOfThreadsPerJob = 1; singleCompThread = false; member_nodes.clear(); } @@ -349,6 +352,8 @@ ConfigFile::getConfigFileInfo(const string &config_file) dynarePath = tokenizedLine.back(); else if (!tokenizedLine.front().compare("MatlabOctavePath")) matlabOctavePath = tokenizedLine.back(); + else if (!tokenizedLine.front().compare("NumberOfThreadsPerJob")) + numberOfThreadsPerJob = atoi(tokenizedLine.back().c_str()); else if (!tokenizedLine.front().compare("SingleCompThread")) if (tokenizedLine.back().compare("true") == 0) singleCompThread = true; @@ -437,7 +442,7 @@ ConfigFile::getConfigFileInfo(const string &config_file) addParallelConfFileElement(inNode, inCluster, member_nodes, name, computerName, port, minCpuNbr, maxCpuNbr, userName, password, remoteDrive, remoteDirectory, - dynarePath, matlabOctavePath, singleCompThread, + dynarePath, matlabOctavePath, singleCompThread, numberOfThreadsPerJob, operatingSystem); configFile->close(); @@ -472,7 +477,7 @@ void ConfigFile::addParallelConfFileElement(bool inNode, bool inCluster, member_nodes_t member_nodes, string &name, string &computerName, string port, int minCpuNbr, int maxCpuNbr, string &userName, string &password, string &remoteDrive, string &remoteDirectory, - string &dynarePath, string &matlabOctavePath, bool singleCompThread, + string &dynarePath, string &matlabOctavePath, bool singleCompThread, int numberOfThreadsPerJob, string &operatingSystem) { //! ADD NODE @@ -491,7 +496,8 @@ ConfigFile::addParallelConfFileElement(bool inNode, bool inCluster, member_nodes else slave_nodes[name] = new SlaveNode(computerName, port, minCpuNbr, maxCpuNbr, userName, password, remoteDrive, remoteDirectory, dynarePath, - matlabOctavePath, singleCompThread, operatingSystem); + matlabOctavePath, singleCompThread, numberOfThreadsPerJob, + operatingSystem); //! ADD CLUSTER else if (inCluster) if (minCpuNbr > 0 || maxCpuNbr > 0 || !userName.empty() @@ -746,7 +752,8 @@ ConfigFile::writeCluster(ostream &output) const << "'DynarePath', '" << it->second->dynarePath << "', " << "'MatlabOctavePath', '" << it->second->matlabOctavePath << "', " << "'OperatingSystem', '" << it->second->operatingSystem << "', " - << "'NodeWeight', '" << (cluster_it->second->member_nodes.find(it->first))->second << "', "; + << "'NodeWeight', '" << (cluster_it->second->member_nodes.find(it->first))->second << "', " + << "'NumberOfThreadsPerJob', " << it->second->numberOfThreadsPerJob << ", "; if (it->second->singleCompThread) output << "'SingleCompThread', 'true');" << endl; diff --git a/preprocessor/ConfigFile.hh b/preprocessor/ConfigFile.hh index 0a6d2e6c0..3c761753b 100644 --- a/preprocessor/ConfigFile.hh +++ b/preprocessor/ConfigFile.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2015 Dynare Team + * Copyright (C) 2010-2016 Dynare Team * * This file is part of Dynare. * @@ -57,7 +57,7 @@ class SlaveNode public: SlaveNode(string &computerName_arg, string port_arg, int minCpuNbr_arg, int maxCpuNbr_arg, string &userName_arg, string &password_arg, string &remoteDrive_arg, string &remoteDirectory_arg, - string &dynarePath_arg, string &matlabOctavePath_arg, bool singleCompThread_arg, + string &dynarePath_arg, string &matlabOctavePath_arg, bool singleCompThread_arg, int numberOfThreadsPerJob_arg, string &operatingSystem_arg); ~SlaveNode(); @@ -73,6 +73,7 @@ protected: const string dynarePath; const string matlabOctavePath; const bool singleCompThread; + const int numberOfThreadsPerJob; const string operatingSystem; }; @@ -116,7 +117,7 @@ private: void addParallelConfFileElement(bool inNode, bool inCluster, member_nodes_t member_nodes, string &name, string &computerName, string port, int minCpuNbr, int maxCpuNbr, string &userName, string &password, string &remoteDrive, string &remoteDirectory, - string &dynarePath, string &matlabOctavePath, bool singleCompThread, + string &dynarePath, string &matlabOctavePath, bool singleCompThread, int numberOfThreadsPerJob, string &operatingSystem); public: //! Parse config file