English Français

Documentation / Developer's manual

Available modules

Calibration,  DataServer,  Launcher,  MetaModelOptim,  Modeler,  Optimizer,  ReLauncher,  Reliability,  ReOptimizer,  Sampler,  Sensitivity,  UncertModeler,  XmlProblem,   Uranie / Launcher: TLauncherByStepRemote.h Source File
Uranie / Launcher  v4.10.0
/* @license-end */
TLauncherByStepRemote.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2024 CEA/DES
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as published
6 // by the Free Software Foundation, either version 3 of the License, or any
7 // later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 // $Id$
19 // $Author$
20 // $Date$
21 // $Revision$
22 // $State$
24 
34 #ifndef TLAUNCHERBYSTEPREMOTE_H
35 #define TLAUNCHERBYSTEPREMOTE_H
36 
37 #include "TNamed.h"
38 
39 #include <iostream>
40 #include <fstream>
41 //#define LIBSSH_STATIC 1
42 //#include <libssh/libssh.h>
43 using std::cout;
44 using std::endl;
45 
46 // ROOT
47 #include "Rtypes.h"
48 
49 // Uranie
50 #include "TLauncher.h"
51 #include "Launcher.h"
52 #include "TCluster.h"
53 #include "TEcCluster.h"
54 
55 #include "TInputFileFlag.h"
56 #include "TAttribute.h"
57 #define LIBSSH_STATIC 1
58 #include <libssh/libssh.h>
59 #include <libssh/sftp.h>
60 #include <semaphore.h>
61 
62 #ifdef WITH_LIBSSH
63 namespace URANIE
64 {
65 namespace Launcher
66 {
67 class TLauncherByStepRemote: public TLauncher
68 {
69 
70 
71 public:
72  TCluster *_cluster;
73 
74  enum EDistrib { kUnknown,kLSB, kSLURM,kMPI, kPBS, kSGE , kEc};
75 
76  EDistrib _edistrib;
77  TString eType;
78 
79  //---------------------------------------------
83  TLauncherByStepRemote(URANIE::DataServer::TDataServer *tds, TCode *code,EDistrib _edistrib=kUnknown, Option_t *option="" );
85  TLauncherByStepRemote(URANIE::DataServer::TDataServer *tds, TCode *code,TCluster *cluster, Option_t *option="" );
86 
88  virtual ~TLauncherByStepRemote();
90  //---------------------------------------------
94 
98  virtual void preTreatment(Option_t *option = "");
99 
100 
102 
105  virtual void run(Option_t *option = "");
106 
107 
108 
109  void clusterRun(Option_t *option = "");
110 
111 
113 
116  virtual void postTreatment(Option_t *option = "");
118 
122  void *retrieveOutputs(void);
123  static void *staticRetrieveOutputs(void *dummyPtr)
124  {
125  return ((TLauncherByStepRemote *)dummyPtr)->retrieveOutputs();
126 
127  }
128 
129  //---------------------------------------------
133  virtual void printLog(Option_t *option = "");
136 
137  //-----------------------------------------------
141 
145  void setNumberOfCores(Int_t ncores)
146  {
147  _nAllocatedCores = ncores;
148  }
149 
151 
154  void setSingleJob()
155  {
156  _sSingleJob = !_sSingleJob;
157  }
159 
162  Bool_t getSingleJob()
163  {
164  return _sSingleJob;
165  }
170  Int_t getNumberOfCores() const
171  {
172  return _nAllocatedCores;
173  }
175 
178  void setAllocatedTime(Int_t nseconds)
179  {
180  _nAllocatedSeconds = nseconds;
181  }
186  Int_t getAllocatedTime() const
187  {
188  return _nAllocatedSeconds;
189  }
191 
194  void setProjectName(TString project_name)
195  {
196  _sProjectName = project_name;
197  }
198 
203  TString getProjectName() const
204  {
205  return _sProjectName;
206  }
207 
208 
209 
210  void setNumberOfChunks(Int_t numberofChunks)
211  {
212  _sNumberOfChunks = numberofChunks;
213 
214  }
215  void setJobName(TString path)
216  {
217  _sJobName = path;
218  _cluster->setJobName(path);
219  }
220 
221  void addCluster(TCluster *cluster)
222  {
223  _cluster->_tds = _tds;
224  _cluster->_code= _code;
225  _cluster->setCluster(cluster);
226 
227  }
228 
230 
234  Int_t getNumberOfChunks() const
235  {
236  return _sNumberOfChunks;
237  }
239 
243  Int_t getNRetries() const
244  {
245  return _sRetries;
246  }
247 
248  void UpdateJobListStatus();
249  void RetrieveJobOutput(std::pair<Int_t,Int_t> split);
250  void compileBinary();
251 
252  TCluster* getCluster();
253  TCluster* setCluster();
254 
255  //CODE-Compiler
256 
258 
263  void addCompilerDirective(TString directive, TString value);
264 
265  void addCodeDependency(TString destinationLib, TString sourceList);
266  void addCodeLibrary(TString libName, TString sourcesList);
267  void addCodeExternalLibrary(TString libName, TString libPath , TString includePath);
268  void addCodeExternalLibrary(TString libName);
269 
270 
271  void substituteCompilerCode();
272 
273 
274 
275 
276 
277 
278 
280 
281 private:
282 
283 
288  Int_t _nAllocatedSeconds;
292  Int_t _nAllocatedCores;
296  TString _sProjectName;
297 
298 
299 
303  std::list<std::pair<TString,std::pair<Int_t,Int_t>>> _sActiveJobs;
307  std::list<std::pair<TString,std::pair<Int_t,Int_t>>> _sCompletedJobs;
308 
309  sem_t _sshSemaphore;
310 
315  Int_t _sNumberOfChunks=1;
320  Int_t _sChunkSize;
321 
322 
327  Bool_t _sSingleJob=false;
333  TString _sJobName;
338  Int_t _sRetries =5;
342  std::list<std::pair<TString,std::pair<Int_t,Int_t>>> _sJobList;
346  std::list<TString> _sJobStatus;
350  TString _sJobIDs="";
351 
355  std::pair<Int_t,Int_t> _sLastSplit;
356 
360  std::map<TString,TString> _sListCompilerDirectives;
364  std::map<TString,TString> _sCodeLibs;
368  std::list<std::pair<TString,std::pair<TString,TString>> > _sExternalLib;
369 
373  std::map<TString,TString> _sCodeDependencies;
374  TString _sCompilerSkeleton = "CMakeLists.txt.in";
375  ClassDef(URANIE::Launcher::TLauncherByStepRemote, ID_LAUNCHER)
376  //The description
377 };
378 
379 } // End Of namespace Launcher
380 } // End Of namespace URANIE
381 #endif
382 #endif
383 // End Of File TLauncherByStepRemote.h
Definition: TCluster.h:66
Interface of the class URANIE::Launcher::TLauncher.
Interface of the class URANIE::Launcher::TCluster.
Interface of the class URANIE::Launcher::TInputFileFlag.