10 #ifndef WRENCH_BATCHJOBSETCORELEVEL_H
11 #define WRENCH_BATCHJOBSETCORELEVEL_H
13 #include <wrench/services/compute/batch/BatchJob.h>
25 class BatchJobSetCoreLevel {
29 BatchJobSetCoreLevel() =
default;
32 std::set<std::shared_ptr<BatchJob>> jobs;
35 std::map<int, unsigned long> core_utilization;
42 BatchJobSetCoreLevel& operator += (
const BatchJobSetCoreLevel& right)
44 for (
const auto &j : right.jobs) {
55 BatchJobSetCoreLevel& operator -= (
const BatchJobSetCoreLevel& right)
57 for (
const auto &j : right.jobs) {
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();
73 this->core_utilization[i] += job->getRequestedCoresPerNode();
76 this->jobs.insert(job);
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();
89 this->jobs.erase(job);
101 #endif //WRENCH_BATCHJOBSETCORELEVEL_H