WRENCH  1.11
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
BatchJobSetCoreLevel.h
1 
10 #ifndef WRENCH_BATCHJOBSETCORELEVEL_H
11 #define WRENCH_BATCHJOBSETCORELEVEL_H
12 
13 #include "wrench/services/compute/batch/BatchJob.h"
14 
15 
16 namespace wrench {
17 
18  /***********************/
20  /***********************/
21 
25  class BatchJobSetCoreLevel {
26 
27  public:
28 
29  BatchJobSetCoreLevel() = default;
30 
32  std::set<std::shared_ptr<BatchJob>> jobs;
33 
35  std::map<int, unsigned long> core_utilization;
36 
42  BatchJobSetCoreLevel& operator += (const BatchJobSetCoreLevel& right)
43  {
44  for (const auto &j : right.jobs) {
45  add(j);
46  }
47  return *this;
48  }
49 
55  BatchJobSetCoreLevel& operator -= (const BatchJobSetCoreLevel& right)
56  {
57  for (const auto &j : right.jobs) {
58  remove(j);
59  }
60  return *this;
61  }
62 
67  void inline add(std::shared_ptr<BatchJob> job) {
68  if (this->jobs.find(job) == this->jobs.end()) {
69  for (auto const &i : job->getAllocatedNodeIndices()) {
70  if (this->core_utilization.find(i) == this->core_utilization.end()) {
71  this->core_utilization[i] = job->getRequestedCoresPerNode();
72  } else {
73  this->core_utilization[i] += job->getRequestedCoresPerNode();
74  }
75  }
76  this->jobs.insert(job);
77  }
78  }
79 
84  void inline remove(std::shared_ptr<BatchJob> job) {
85  if (this->jobs.find(job) != this->jobs.end()) {
86  for (auto const &i : job->getAllocatedNodeIndices()) {
87  this->core_utilization[i] -= job->getRequestedCoresPerNode();
88  }
89  this->jobs.erase(job);
90  }
91  }
92 
93  };
94 
95  /***********************/
97  /***********************/
98 
99 }
100 
101 #endif //WRENCH_BATCHJOBSETCORELEVEL_H
wrench
Definition: Action.cpp:28