Versatile::iterator Vit;
_username = string(params[USER]);
- string subCommand = string("mkdir -p ") + string(params[TMPDIR]);
+ string subCommand = string("mkdir -p ") + string(params[TMPDIR]) + string("/logs");
string command = _protocol.getExecCommand(subCommand, _hostname, _username);
cerr << command.c_str() << endl;
status = system(command.c_str());
}
}
+ // Copy logs
+ int status = _protocol.copyFile(string(params[TMPDIR]) + string("/logs"), _hostname, _username,
+ directory, "", "");
+ if (status) {
+ std::string mess("Copy logs directory failed ! status is :");
+ ostringstream status_str;
+ status_str << status;
+ mess += status_str.str();
+ cerr << mess << endl;
+ }
+
}
MpiImpl *BatchManager_eClient::FactoryMpiImpl(string mpiImpl) throw(EmulationException)
# define BATCH_EXPORT
#endif
+#ifdef WIN32
+#define BATCH_CHMOD(name, mode) _chmod(name, mode)
+#else
+#define BATCH_CHMOD(name, mode) chmod(name, mode)
+#endif
+
#endif
virtual Batch::BatchManager_eClient * operator() (const char * hostname,
CommunicationProtocolType protocolType,
- const char * mpi) const = 0;
+ const char * mpi,
+ int nb_proc_per_node = 1) const = 0;
protected:
BatchManager_eClient * FactBatchManager_eLSF::operator() (const char * hostname,
CommunicationProtocolType protocolType,
- const char * mpiImpl) const
+ const char * mpiImpl,
+ int nb_proc_per_node) const
{
// MESSAGE("Building new BatchManager_LSF on host '" << hostname << "'");
return new BatchManager_eLSF(this, hostname, protocolType, mpiImpl);
virtual BatchManager * operator() (const char * hostname) const;
virtual BatchManager_eClient * operator() (const char * hostname,
CommunicationProtocolType protocolType,
- const char * mpiImpl) const;
+ const char * mpiImpl,
+ int nb_proc_per_node = 1) const;
protected:
namespace Batch {
BatchManager_ePBS::BatchManager_ePBS(const FactBatchManager * parent, const char * host,
- CommunicationProtocolType protocolType, const char * mpiImpl)
+ CommunicationProtocolType protocolType, const char * mpiImpl,
+ int nb_proc_per_node)
: BatchManager_eClient(parent, host, protocolType, mpiImpl),
BatchManager(parent, host)
{
// Nothing to do
+ _nb_proc_per_node = nb_proc_per_node;
}
// Destructeur
{
int status;
Parametre params = job.getParametre();
- const std::string dirForTmpFiles = params[TMPDIR];
+ const std::string workDir = params[WORKDIR];
const string fileToExecute = params[EXECUTABLE];
string::size_type p1 = fileToExecute.find_last_of("/");
string::size_type p2 = fileToExecute.find_last_of(".");
string logFile = generateTemporaryFileName("PBS-submitlog");
// define command to submit batch
- string subCommand = string("cd ") + dirForTmpFiles + "; qsub " +
- fileNameToExecute + "_Batch.sh";
+ string subCommand = string("cd ") + workDir + "; qsub " + fileNameToExecute + "_Batch.sh";
string command = _protocol.getExecCommand(subCommand, _hostname, _username);
command += " > ";
command += logFile;
}
void BatchManager_ePBS::buildBatchScript(const Job & job)
+ {
+ std::cerr << "BuildBatchScript" << std::endl;
+ Parametre params = job.getParametre();
+
+ // Job Parameters
+ string workDir = "";
+ string fileToExecute = "";
+ int nbproc = 0;
+ int edt = 0;
+ int mem = 0;
+ string queue = "";
+
+ // Mandatory parameters
+ if (params.find(WORKDIR) != params.end())
+ workDir = params[WORKDIR].str();
+ else
+ throw EmulationException("params[WORKDIR] is not defined ! Please defined it, cannot submit this job");
+ if (params.find(EXECUTABLE) != params.end())
+ fileToExecute = params[EXECUTABLE].str();
+ else
+ throw EmulationException("params[EXECUTABLE] is not defined ! Please defined it, cannot submit this job");
+
+ // Optional parameters
+ if (params.find(NBPROC) != params.end())
+ nbproc = params[NBPROC];
+ if (params.find(MAXWALLTIME) != params.end())
+ edt = params[MAXWALLTIME];
+ if (params.find(MAXRAMSIZE) != params.end())
+ mem = params[MAXRAMSIZE];
+
+ string::size_type p1 = fileToExecute.find_last_of("/");
+ string::size_type p2 = fileToExecute.find_last_of(".");
+ string rootNameToExecute = fileToExecute.substr(p1+1,p2-p1-1);
+ string fileNameToExecute = fileToExecute.substr(p1+1);
+
+ // Create batch submit file
+ ofstream tempOutputFile;
+ std::string TmpFileName = createAndOpenTemporaryFile("PBS-script", tempOutputFile);
+
+ tempOutputFile << "#! /bin/sh -f" << endl;
+ if (nbproc > 0)
+ {
+ // Division - arrondi supérieur
+ int nodes_requested = (nbproc + _nb_proc_per_node -1) / _nb_proc_per_node;
+ tempOutputFile << "#PBS -l nodes=" << nodes_requested << endl;
+ }
+ if (queue != "")
+ tempOutputFile << "#BSUB -q " << queue << endl;
+ if( edt > 0 )
+ tempOutputFile << "#PBS -l walltime=" << edt*60 << endl;
+ if( mem > 0 )
+ tempOutputFile << "#PBS -l mem=" << mem << "mb" << endl;
+ tempOutputFile << "#PBS -o " << workDir << "/logs/output.log." << rootNameToExecute << endl ;
+ tempOutputFile << "#PBS -e " << workDir << "/logs/error.log." << rootNameToExecute << endl ;
+ tempOutputFile << "cd " << workDir << endl ;
+ tempOutputFile << "./" + fileNameToExecute << endl;;
+ tempOutputFile.flush();
+ tempOutputFile.close();
+
+ BATCH_CHMOD(TmpFileName.c_str(), 0x1ED);
+ cerr << "Batch script file generated is: " << TmpFileName.c_str() << endl;
+
+ int status = _protocol.copyFile(TmpFileName, "", "",
+ workDir + "/" + rootNameToExecute + "_Batch.sh",
+ _hostname, _username);
+ if (status)
+ throw EmulationException("Error of connection on remote host, cannot copy batch submission file");
+ }
+
+ void BatchManager_ePBS::oldbuildBatchScript(const Job & job)
{
Parametre params = job.getParametre();
Environnement env = job.getEnvironnement();
public:
// Constructeur et destructeur
BatchManager_ePBS(const FactBatchManager * parent, const char * host="localhost",
- CommunicationProtocolType protocolType = SSH, const char * mpiImpl="nompi"); // connexion a la machine host
+ CommunicationProtocolType protocolType = SSH, const char * mpiImpl="nompi",
+ int nb_proc_per_node=1); // connexion a la machine host
virtual ~BatchManager_ePBS();
// Recupere le nom du serveur par defaut
protected:
void buildBatchScript(const Job & job);
+ void oldbuildBatchScript(const Job & job);
private:
+ int _nb_proc_per_node;
#ifdef SWIG
public:
BatchManager_eClient * FactBatchManager_ePBS::operator() (const char * hostname,
CommunicationProtocolType protocolType,
- const char * mpiImpl) const
+ const char * mpiImpl,
+ int nb_proc_per_node) const
{
// MESSAGE("Building new BatchManager_PBS on host '" << hostname << "'");
- return new BatchManager_ePBS(this, hostname, protocolType, mpiImpl);
+ return new BatchManager_ePBS(this, hostname, protocolType, mpiImpl, nb_proc_per_node);
}
virtual BatchManager * operator() (const char * hostname) const;
virtual BatchManager_eClient * operator() (const char * hostname,
CommunicationProtocolType protocolType,
- const char * mpiImpl) const;
+ const char * mpiImpl,
+ int nb_proc_per_node = 1) const;
protected:
BatchManager_eClient * FactBatchManager_eSGE::operator() (const char * hostname,
CommunicationProtocolType protocolType,
- const char * mpiImpl) const
+ const char * mpiImpl,
+ int nb_proc_per_node) const
{
// MESSAGE("Building new BatchManager_SGE on host '" << hostname << "'");
return new BatchManager_eSGE(this, hostname, protocolType, mpiImpl);
virtual BatchManager * operator() (const char * hostname) const;
virtual BatchManager_eClient * operator() (const char * hostname,
CommunicationProtocolType protocolType,
- const char * mpiImpl) const;
+ const char * mpiImpl,
+ int nb_proc_per_node = 1) const;
protected:
Batch::BatchManager_eClient *
Batch::FactBatchManager_eSSH::operator() (const char * hostname,
CommunicationProtocolType protocolType,
- const char * mpiImpl) const
+ const char * mpiImpl,
+ int nb_proc_per_node) const
{
//protocolType and mpiImpl are ignored.
std::cerr << "[Batch::FactBatchManager_eSSH] creating new Batch::BatchManager_eSSH with hostname = " << hostname << std::endl;
virtual BatchManager * operator() (const char * hostname) const; // From FactBacthManager
virtual BatchManager_eClient * operator() (const char * hostname,
CommunicationProtocolType protocolType,
- const char * mpiImpl) const; // From FactBatchManager_eClient
+ const char * mpiImpl,
+ int nb_proc_per_node = 1) const; // From FactBatchManager_eClient
};
}