Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added a ComputeService::getHosts() method
  • Loading branch information
henricasanova committed Aug 4, 2021
1 parent ce0fd4d commit 3715a24
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
2 changes: 2 additions & 0 deletions include/wrench/services/compute/ComputeService.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ namespace wrench {

unsigned long getNumHosts();

std::vector<std::string> getHosts();

std::map<std::string, unsigned long> getPerHostNumCores();

unsigned long getTotalNumCores();
Expand Down
28 changes: 28 additions & 0 deletions src/wrench/services/compute/ComputeService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,34 @@ namespace wrench {
return count;
}

/**
* @brief Get the list of the compute service's compute host
* @return a vector of hostnames
*
* @throw WorkflowExecutionException
* @throw std::runtime_error
*/
std::vector<std::string> ComputeService::getHosts() {

std::map<std::string, std::map<std::string, double>> dict;
try {
dict = this->getServiceResourceInformation();
} catch (WorkflowExecutionException &e) {
throw;
}

std::vector<std::string> to_return;

if (dict.find("num_cores") != dict.end()) {
for (auto x : dict["num_cores"]) {
to_return.emplace_back(x.first);
}
}

return to_return;
}



/**
* @brief Get core counts for each of the compute service's host
Expand Down
7 changes: 0 additions & 7 deletions src/wrench/simulation/SimulationOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,19 +881,12 @@ namespace wrench {

try {

// auto simgrid_engine = simgrid::s4u::Engine::get_instance();

std::vector<simgrid::s4u::Host *> hosts = get_all_physical_hosts();

nlohmann::json hosts_energy_consumption_information;
for (const auto &host : hosts) {
nlohmann::json datum;

// Ignore VMs!
if (S4U_VirtualMachine::vm_to_pm_map.find(host->get_name()) != S4U_VirtualMachine::vm_to_pm_map.end()) {
continue;
}

datum["hostname"] = host->get_name();

// for each pstate, we need to record the following:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ class ResourceInformationTestWMS : public wrench::WMS {
throw std::runtime_error("getNumHosts() should return 2 for compute service #2");
}

// Get Host list
std::vector<std::string> host_list;
host_list = this->test->compute_servcice1->getHosts();
if (host_list.size() != 2) {
throw std::runtime_error("getHosts() should return a list with 2 items for compute service #1");
}
if (std::find(host_list.begin(), host_list.end(), "Host1") == host_list.end()) {
throw std::runtime_error("getHosts() should return a list that contains 'Host1' for compute service #1");
}
if (std::find(host_list.begin(), host_list.end(), "Host2") == host_list.end()) {
throw std::runtime_error("getHosts() should return a list that contains 'Host2' for compute service #1");
}

// Get number of Cores
std::map<std::string, unsigned long> num_cores;
Expand Down

0 comments on commit 3715a24

Please sign in to comment.