From 34ce2ab2219250d138ea9cd500fbd3fa7cc7f7f1 Mon Sep 17 00:00:00 2001 From: Rafael Ferreira da Silva Date: Fri, 1 Dec 2017 11:07:18 -0800 Subject: [PATCH] comestic changes and fixing batch example --- doc/getting_started.md | 2 +- examples/batch_hosts.xml | 20 ++++++++ examples/simple-wms/SimpleWMSBatch.cpp | 19 ++------ .../simple-wms/scheduler/BatchScheduler.cpp | 48 ++++++++----------- .../simple-wms/scheduler/BatchScheduler.h | 4 +- .../standard_job_executor/ComputeThread.cpp | 2 +- 6 files changed, 48 insertions(+), 47 deletions(-) create mode 100644 examples/batch_hosts.xml diff --git a/doc/getting_started.md b/doc/getting_started.md index 242be61be6..0bbc0d4649 100644 --- a/doc/getting_started.md +++ b/doc/getting_started.md @@ -29,7 +29,7 @@ one of the following commands: wrench-simple-wms-cloud /examples/cloud_hosts.xml /examples/genome.dax # running the batch-based implementation -wrench-simple-wms-batch /examples/two_hosts.xml /examples/genome.dax +wrench-simple-wms-batch /examples/batch_hosts.xml /examples/genome.dax ~~~~~~~~~~~~~ ## Understanding the Simple-WMS Examples {#getting-started-example-simplewms} diff --git a/examples/batch_hosts.xml b/examples/batch_hosts.xml new file mode 100644 index 0000000000..e921224929 --- /dev/null +++ b/examples/batch_hosts.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/simple-wms/SimpleWMSBatch.cpp b/examples/simple-wms/SimpleWMSBatch.cpp index dc0a9e8476..5239a421bb 100644 --- a/examples/simple-wms/SimpleWMSBatch.cpp +++ b/examples/simple-wms/SimpleWMSBatch.cpp @@ -41,7 +41,7 @@ int main(int argc, char **argv) { char *workflow_file = argv[2]; -/* Reading and parsing the workflow description file to create a wrench::Workflow object */ + /* Reading and parsing the workflow description file to create a wrench::Workflow object */ std::cerr << "Loading workflow..." << std::endl; wrench::Workflow workflow; wrench::WorkflowUtil::loadFromDAX(workflow_file, &workflow); @@ -82,9 +82,9 @@ int main(int argc, char **argv) { * terminate it will be 2048 bytes. See the documentation to find out all available * configurable properties for each kind of service. */ - - wrench::ComputeService *batch_service = new wrench::BatchService(wms_host,hostname_list, - storage_service,true,true,{{wrench::BatchServiceProperty::STOP_DAEMON_MESSAGE_PAYLOAD, "2048"}}); + wrench::ComputeService *batch_service = new wrench::BatchService( + wms_host, hostname_list, storage_service, true, true, + {{wrench::BatchServiceProperty::STOP_DAEMON_MESSAGE_PAYLOAD, "2048"}}); /* Add the batch service to the simulation, catching a possible exception */ try { @@ -95,12 +95,6 @@ int main(int argc, char **argv) { std::exit(1); } - /* Construct a list of hosts (in the example only one host) on which the - * batch service will be able to run tasks - */ - std::string executor_host = hostname_list[(hostname_list.size() > 1) ? 1 : 0]; - std::vector execution_hosts = {executor_host}; - /* Instantiate a WMS, to be stated on some host (wms_host), which is responsible * for executing the workflow, and uses a scheduler (BatchScheduler). That scheduler * is instantiated with the batch service, the list of hosts available for running @@ -113,10 +107,7 @@ int main(int argc, char **argv) { std::unique_ptr( new wrench::SimpleWMS(&workflow, std::unique_ptr( - new wrench::BatchScheduler(batch_service, - execution_hosts, - &simulation)), - wms_host))); + new wrench::BatchScheduler(batch_service, &simulation)), wms_host))); /* Instantiate a file registry service to be started on some host. This service is * essentially a replica catalog that stores pairs so that diff --git a/examples/simple-wms/scheduler/BatchScheduler.cpp b/examples/simple-wms/scheduler/BatchScheduler.cpp index 23b87b06b7..eef801d999 100644 --- a/examples/simple-wms/scheduler/BatchScheduler.cpp +++ b/examples/simple-wms/scheduler/BatchScheduler.cpp @@ -23,17 +23,12 @@ namespace wrench { * * @throw std::runtime_error */ - BatchScheduler::BatchScheduler(ComputeService *batch_service, std::vector &execution_hosts, - Simulation *simulation) : simulation(simulation) { + BatchScheduler::BatchScheduler(ComputeService *batch_service, Simulation *simulation) : simulation(simulation) { - if (typeid(batch_service) == typeid(BatchService)) { - throw std::runtime_error("The provided batch service is not a BatchService object."); - } - if (execution_hosts.empty()) { - throw std::runtime_error("At least one execution host should be provided"); - } - this->execution_hosts = execution_hosts; - this->batch_service = batch_service; + if (typeid(batch_service) == typeid(BatchService)) { + throw std::runtime_error("The provided batch service is not a BatchService object."); + } + this->batch_service = batch_service; } /** @@ -49,26 +44,23 @@ namespace wrench { std::map> ready_tasks, const std::set &compute_services) { - if (compute_services.find(batch_service) == compute_services.end()) { - throw std::runtime_error("The default batch service is not listed as a compute service."); - } - auto *cs = (BatchService*)this->batch_service; + if (compute_services.find(batch_service) == compute_services.end()) { + throw std::runtime_error("The default batch service is not listed as a compute service."); + } + auto *cs = (BatchService *) this->batch_service; - WRENCH_INFO("There are %ld ready tasks to schedule", ready_tasks.size()); - long scheduled = 0; + WRENCH_INFO("There are %ld ready tasks to schedule", ready_tasks.size()); - for (auto itc : ready_tasks) { - //TODO add support to pilot jobs + for (auto itc : ready_tasks) { + //TODO add support to pilot jobs - WorkflowJob *job = (WorkflowJob *) job_manager->createStandardJob(itc.second, {}); - std::map batch_job_args; - batch_job_args["-N"] = "1"; - batch_job_args["-t"] = "10"; //time in minutes - batch_job_args["-c"] = "1"; //number of cores per node - job_manager->submitJob(job, cs, batch_job_args); - - scheduled++; - } - WRENCH_INFO("Done with scheduling tasks as standard jobs"); + WorkflowJob *job = (WorkflowJob *) job_manager->createStandardJob(itc.second, {}); + std::map batch_job_args; + batch_job_args["-N"] = "1"; + batch_job_args["-t"] = "2000000"; //time in minutes + batch_job_args["-c"] = "1"; //number of cores per node + job_manager->submitJob(job, cs, batch_job_args); + } + WRENCH_INFO("Done with scheduling tasks as standard jobs"); } } diff --git a/examples/simple-wms/scheduler/BatchScheduler.h b/examples/simple-wms/scheduler/BatchScheduler.h index dcd5478faf..d42f46cd3b 100644 --- a/examples/simple-wms/scheduler/BatchScheduler.h +++ b/examples/simple-wms/scheduler/BatchScheduler.h @@ -24,8 +24,7 @@ namespace wrench { class BatchScheduler : public Scheduler { public: - BatchScheduler(ComputeService *cloud_service, std::vector &execution_hosts, - Simulation *simulation); + BatchScheduler(ComputeService *cloud_service, Simulation *simulation); /***********************/ /** \cond DEVELOPER */ @@ -42,7 +41,6 @@ namespace wrench { private: ComputeService *batch_service; - std::vector execution_hosts; Simulation *simulation; }; } diff --git a/src/wrench/services/compute/standard_job_executor/ComputeThread.cpp b/src/wrench/services/compute/standard_job_executor/ComputeThread.cpp index af1bb444d8..e7c6678c42 100644 --- a/src/wrench/services/compute/standard_job_executor/ComputeThread.cpp +++ b/src/wrench/services/compute/standard_job_executor/ComputeThread.cpp @@ -40,7 +40,7 @@ namespace wrench { int ComputeThread::main() { try { - WRENCH_INFO("New compute threads beginnin %.2f-flop computation", this->flops); + WRENCH_INFO("New compute threads beginning %.2f-flop computation", this->flops); S4U_Simulation::compute(this->flops); } catch (std::exception &e) { WRENCH_INFO("Probably got killed while I was computing");