Skip to content

Commit

Permalink
comestic changes and fixing batch example
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfsilva committed Dec 1, 2017
1 parent de6e9d4 commit 34ce2ab
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 47 deletions.
2 changes: 1 addition & 1 deletion doc/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ one of the following commands:
wrench-simple-wms-cloud <PATH-TO-WRENCH-SRC-FOLDER>/examples/cloud_hosts.xml <PATH-TO-WRENCH-SRC-FOLDER>/examples/genome.dax
# running the batch-based implementation
wrench-simple-wms-batch <PATH-TO-WRENCH-SRC-FOLDER>/examples/two_hosts.xml <PATH-TO-WRENCH-SRC-FOLDER>/examples/genome.dax
wrench-simple-wms-batch <PATH-TO-WRENCH-SRC-FOLDER>/examples/batch_hosts.xml <PATH-TO-WRENCH-SRC-FOLDER>/examples/genome.dax
~~~~~~~~~~~~~

## Understanding the Simple-WMS Examples {#getting-started-example-simplewms}
Expand Down
20 changes: 20 additions & 0 deletions examples/batch_hosts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version='1.0'?>
<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
<platform version="4">
<AS id="AS0" routing="Full">
<host id="Host1" speed="1f" core="10"/>
<host id="Host2" speed="1f" core="10"/>
<host id="Host3" speed="1f" core="10"/>
<host id="Host4" speed="1f" core="10"/>
<link id="1" bandwidth="5000GBps" latency="0us"/>
<route src="Host1" dst="Host2">
<link_ctn id="1"/>
</route>
<route src="Host1" dst="Host3">
<link_ctn id="1"/>
</route>
<route src="Host1" dst="Host4">
<link_ctn id="1"/>
</route>
</AS>
</platform>
19 changes: 5 additions & 14 deletions examples/simple-wms/SimpleWMSBatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand All @@ -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<std::string> 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
Expand All @@ -113,10 +107,7 @@ int main(int argc, char **argv) {
std::unique_ptr<wrench::WMS>(
new wrench::SimpleWMS(&workflow,
std::unique_ptr<wrench::Scheduler>(
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 <file , storage service> pairs so that
Expand Down
48 changes: 20 additions & 28 deletions examples/simple-wms/scheduler/BatchScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,12 @@ namespace wrench {
*
* @throw std::runtime_error
*/
BatchScheduler::BatchScheduler(ComputeService *batch_service, std::vector<std::string> &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;
}

/**
Expand All @@ -49,26 +44,23 @@ namespace wrench {
std::map<std::string, std::vector<WorkflowTask *>> ready_tasks,
const std::set<ComputeService *> &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<std::string, std::string> 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<std::string, std::string> 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");
}
}
4 changes: 1 addition & 3 deletions examples/simple-wms/scheduler/BatchScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ namespace wrench {
class BatchScheduler : public Scheduler {

public:
BatchScheduler(ComputeService *cloud_service, std::vector<std::string> &execution_hosts,
Simulation *simulation);
BatchScheduler(ComputeService *cloud_service, Simulation *simulation);

/***********************/
/** \cond DEVELOPER */
Expand All @@ -42,7 +41,6 @@ namespace wrench {
private:

ComputeService *batch_service;
std::vector<std::string> execution_hosts;
Simulation *simulation;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 34ce2ab

Please sign in to comment.