parallel: add port option to config file

time-shift
Houtan Bastani 2012-05-09 12:44:57 +02:00
parent 1be5566d89
commit 4186a431ff
3 changed files with 29 additions and 10 deletions

View File

@ -6971,6 +6971,10 @@ be used but the range will be adjusted to begin at one.
The name or IP address of the node. If you want to run locally, use
@code{localhost} (case-sensitive).
@item Port = @var{INTEGER}
The port number to connect to on the node. The default is empty,
meaning that the connection will be made to the default SSH port (22).
@item UserName = @var{USER_NAME}
The username used to log into a remote system. Required for remote
runs on all platforms.
@ -7026,6 +7030,7 @@ MatlabOctavePath = matlab
[node]
Name = n3
ComputerName = dynserv.dynare.org
Port = 3333
CPUnbr = [2:4]
UserName = usern
RemoteDirectory = /home/usern/Remote

View File

@ -30,11 +30,11 @@
using namespace std;
SlaveNode::SlaveNode(string &computerName_arg, int minCpuNbr_arg, int maxCpuNbr_arg, string &userName_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 &operatingSystem_arg) :
computerName(computerName_arg), minCpuNbr(minCpuNbr_arg), maxCpuNbr(maxCpuNbr_arg), userName(userName_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)
{
@ -118,7 +118,7 @@ ConfigFile::getConfigFileInfo(const string &parallel_config_file)
}
}
string name, computerName, userName, password, remoteDrive,
string name, computerName, port, userName, password, remoteDrive,
remoteDirectory, dynarePath, matlabOctavePath, operatingSystem;
int minCpuNbr = 0, maxCpuNbr = 0;
bool singleCompThread = true;
@ -137,7 +137,7 @@ ConfigFile::getConfigFileInfo(const string &parallel_config_file)
if (!line.compare("[node]") || !line.compare("[cluster]"))
{
addConfFileElement(inNode, inCluster, member_nodes, name,
computerName, minCpuNbr, maxCpuNbr, userName,
computerName, port, minCpuNbr, maxCpuNbr, userName,
password, remoteDrive, remoteDirectory,
dynarePath, matlabOctavePath, singleCompThread,
operatingSystem);
@ -154,7 +154,7 @@ ConfigFile::getConfigFileInfo(const string &parallel_config_file)
inCluster = true;
}
name = userName = computerName = password = remoteDrive
name = userName = computerName = port = password = remoteDrive
= remoteDirectory = dynarePath = matlabOctavePath
= operatingSystem = "";
minCpuNbr = maxCpuNbr = 0;
@ -220,6 +220,8 @@ ConfigFile::getConfigFileInfo(const string &parallel_config_file)
minCpuNbr = tmp;
}
}
else if (!tokenizedLine.front().compare("Port"))
port = tokenizedLine.back();
else if (!tokenizedLine.front().compare("ComputerName"))
computerName = tokenizedLine.back();
else if (!tokenizedLine.front().compare("UserName"))
@ -315,7 +317,7 @@ ConfigFile::getConfigFileInfo(const string &parallel_config_file)
}
addConfFileElement(inNode, inCluster, member_nodes, name,
computerName, minCpuNbr, maxCpuNbr, userName,
computerName, port, minCpuNbr, maxCpuNbr, userName,
password, remoteDrive, remoteDirectory,
dynarePath, matlabOctavePath, singleCompThread,
operatingSystem);
@ -325,7 +327,7 @@ ConfigFile::getConfigFileInfo(const string &parallel_config_file)
void
ConfigFile::addConfFileElement(bool inNode, bool inCluster, member_nodes_t member_nodes,
string &name, string &computerName, int minCpuNbr, int maxCpuNbr, string &userName,
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 &operatingSystem)
@ -344,7 +346,7 @@ ConfigFile::addConfFileElement(bool inNode, bool inCluster, member_nodes_t membe
exit(EXIT_FAILURE);
}
else
slave_nodes[name] = new SlaveNode(computerName, minCpuNbr, maxCpuNbr, userName,
slave_nodes[name] = new SlaveNode(computerName, port, minCpuNbr, maxCpuNbr, userName,
password, remoteDrive, remoteDirectory, dynarePath,
matlabOctavePath, singleCompThread, operatingSystem);
//! ADD CLUSTER
@ -393,6 +395,16 @@ ConfigFile::checkPass(WarningConsolidation &warnings) const
<< "used in parallel processing. This will be adjusted for you such that the "
<< "same number of CPUs are used." << endl;
#endif
if (!it->second->port.empty())
try
{
boost::lexical_cast< int >(it->second->port);
}
catch (const boost::bad_lexical_cast &)
{
cerr << "ERROR (node " << it->first << "): the port must be an integer." << endl;
exit(EXIT_FAILURE);
}
if (!it->second->computerName.compare("localhost")) // We are working locally
{
if (!it->second->remoteDrive.empty())
@ -526,6 +538,7 @@ ConfigFile::writeCluster(ostream &output) const
output << "1, ";
output << "'ComputerName', '" << it->second->computerName << "', "
<< "'Port', '" << it->second->port << "', "
<< "'CPUnbr', [" << it->second->minCpuNbr << ":" << it->second->maxCpuNbr << "], "
<< "'UserName', '" << it->second->userName << "', "
<< "'Password', '" << it->second->password << "', "

View File

@ -34,7 +34,7 @@ class SlaveNode
{
friend class ConfigFile;
public:
SlaveNode(string &computerName_arg, int minCpuNbr_arg, int maxCpuNbr_arg, string &userName_arg,
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 &operatingSystem_arg);
@ -42,6 +42,7 @@ public:
protected:
const string computerName;
const string port;
int minCpuNbr;
int maxCpuNbr;
const string userName;
@ -84,7 +85,7 @@ private:
map<string, SlaveNode *> slave_nodes;
//! Add a SlaveNode or a Cluster object
void addConfFileElement(bool inNode, bool inCluster, member_nodes_t member_nodes, string &name,
string &computerName, int minCpuNbr, int maxCpuNbr, string &userName,
string &computerName, string port, int minCpuNbr, int maxCpuNbr, string &userName,
string &password, string &remoteDrive, string &remoteDirectory,
string &dynarePath, string &matlabOctavePath, bool singleCompThread,
string &operatingSystem);