KaliVeda
Toolkit for HIC analysis
KVXtermBatch.cpp
1 #include "KVDataSetAnalyser.h"
2 #include "KVXtermBatch.h"
3 #include <cassert>
4 
5 
9 
11 {
12  //Processes the job requests for the batch system.
13  //In multijobs mode, this submits one job for each run in the runlist associated to fAnalyser
14 
15  if (!CheckJobParameters()) return;
16 
17  //submit jobs for every GetRunsPerJob() runs in runlist
18  KVDataSetAnalyser* ana = dynamic_cast<KVDataSetAnalyser*>(fAnalyser);
19  assert(ana);
20  auto runs = ana->GetRunList();
21  Int_t remaining_runs = runs.GetNValues();
22 
23  // to optimize use of CPUs, some jobs will have multiple runs
24  std::vector<int> runs_per_job(max_num_cpus);
25  int job_index = 0;
26 
27  for (auto& r : runs) {
28  ++runs_per_job[job_index++];
29  if (job_index == max_num_cpus) job_index = 0;
30  }
31 
32  fCurrJobRunList.Clear();
33  job_index = 0;
34  bool submitted = false;
35  for (auto& run : runs) {
36  if (!remaining_runs) break;
37  remaining_runs--;
38  fCurrJobRunList.Add(run);
39  submitted = false;
40  if (fCurrJobRunList.GetNValues() == runs_per_job[job_index]) {
41  // submit job for run
43  ana->SetFullRunList(runs);
44  std::cout << "Submitting job " << job_index + 1 << " for runs:" << fCurrJobRunList.AsString() << std::endl;
45  SubmitJob();
46  fCurrJobRunList.Clear();
47  ++job_index;
48  submitted = true;
49  }
50  }
51  if (!submitted && !fCurrJobRunList.IsEmpty()) {
52  // submit last job for run
54  ana->SetFullRunList(runs);
55  std::cout << "Submitting job " << job_index + 1 << " for runs:" << fCurrJobRunList.AsString() << std::endl;
56  SubmitJob();
57  fCurrJobRunList.Clear();
58  ++job_index;
59  }
60  ana->SetRuns(runs, kFALSE);
61 }
62 
63 
65 
66 
67 
68 
73 void KVXtermBatch::GetBatchSystemParameterList(KVNameValueList& nl)
74 {
75  // Add to batch parameters the number of CPUs to use
76  //
77  // By default, it is the number of CPUs on the machine
78 
80  nl.SetValue("MaxNumCPUs", max_num_cpus);
81 }
82 
83 
84 
89 
91 {
92  // Add to batch parameters the number of CPUs to use
93  //
94  // By default, it is the number of CPUs on the machine
95 
97  max_num_cpus = nl.GetIntValue("MaxNumCPUs");
98 }
99 
100 
101 
102 
int Int_t
ROOT::R::TRInterface & r
constexpr Bool_t kFALSE
virtual void SubmitJob()
virtual void SetBatchSystemParameters(const KVNameValueList &)
Use the parameters in the list to set all relevant parameters for batch system.
run_index_list fCurrJobRunList
runlist for (multi job mode) job being submitted
Definition: KVBatchSystem.h:89
KVDataAnalyser * fAnalyser
the analyser object which requests job submission, it has all details on the job
Definition: KVBatchSystem.h:82
virtual void GetBatchSystemParameterList(KVNameValueList &)
virtual Bool_t CheckJobParameters()
Checks the job and ask for the job name if needed.
Pilots user analysis of experimental data.
void SetRuns(const run_index_list &nl, Bool_t check=kTRUE)
const run_index_list & GetRunList() const
void SetFullRunList(const run_index_list &nl)
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
Int_t GetIntValue(const Char_t *name) const
Run analysis in multiple xterm windows.
Definition: KVXtermBatch.h:24
void Run() override
void SetBatchSystemParameters(const KVNameValueList &nl) override
ClassImp(TPyArg)