Skip to content

Commit

Permalink
Some renaming/refctoring of stuff
Browse files Browse the repository at this point in the history
Added one multi-host test for the StandardJobExecutor
  • Loading branch information
henricasanova committed Aug 29, 2017
1 parent 672b605 commit efe1150
Show file tree
Hide file tree
Showing 20 changed files with 417 additions and 48 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Expand Up @@ -15,10 +15,10 @@ set(SOURCE_FILES
src/wrench/simulation/SimulationMessage.h
src/wrench/workflow_execution_events/WorkflowExecutionEvent.cpp
src/wrench/workflow_execution_events/WorkflowExecutionEvent.h
src/wrench/simgrid_S4U_util/S4U_DaemonWithMailbox.cpp
src/wrench/simgrid_S4U_util/S4U_DaemonWithMailbox.h
src/wrench/simgrid_S4U_util/S4U_DaemonWithMailboxActor.cpp
src/wrench/simgrid_S4U_util/S4U_DaemonWithMailboxActor.h
src/wrench/simgrid_S4U_util/S4U_Daemon.cpp
src/wrench/simgrid_S4U_util/S4U_Daemon.h
src/wrench/simgrid_S4U_util/S4U_DaemonActor.cpp
src/wrench/simgrid_S4U_util/S4U_DaemonActor.h
src/wrench/simgrid_S4U_util/S4U_Simulation.cpp
src/wrench/simgrid_S4U_util/S4U_Simulation.h
src/wrench/simgrid_S4U_util/S4U_Mailbox.cpp
Expand Down
Expand Up @@ -29,7 +29,7 @@ namespace wrench {
* @param workflow: the workflow whose data (files) are to be managed
*/
DataMovementManager::DataMovementManager(Workflow *workflow) :
S4U_DaemonWithMailbox("data_movement_manager", "data_movement_manager") {
S4U_Daemon("data_movement_manager", "data_movement_manager") {

this->workflow = workflow;

Expand Down
Expand Up @@ -12,7 +12,7 @@
#define WRENCH_DATAMOVEMENTMANAGER_H


#include <simgrid_S4U_util/S4U_DaemonWithMailbox.h>
#include <simgrid_S4U_util/S4U_Daemon.h>

namespace wrench {

Expand All @@ -27,7 +27,7 @@ namespace wrench {
/**
* @brief A helper daemon (co-located with a WMS) that handles data movement operations
*/
class DataMovementManager : public S4U_DaemonWithMailbox {
class DataMovementManager : public S4U_Daemon {

public:

Expand Down
2 changes: 1 addition & 1 deletion src/wrench/managers/job_manager/JobManager.cpp
Expand Up @@ -32,7 +32,7 @@ namespace wrench {
* @param workflow: the workflow whose jobs are to be managed
*/
JobManager::JobManager(Workflow *workflow) :
S4U_DaemonWithMailbox("job_manager", "job_manager") {
S4U_Daemon("job_manager", "job_manager") {

this->workflow = workflow;

Expand Down
4 changes: 2 additions & 2 deletions src/wrench/managers/job_manager/JobManager.h
Expand Up @@ -14,7 +14,7 @@
#include <vector>
#include <set>

#include "simgrid_S4U_util/S4U_DaemonWithMailbox.h"
#include "simgrid_S4U_util/S4U_Daemon.h"

namespace wrench {

Expand All @@ -35,7 +35,7 @@ namespace wrench {
/**
* @brief A helper daemon (co-located with the WMS) to handle job executions
*/
class JobManager : public S4U_DaemonWithMailbox {
class JobManager : public S4U_Daemon {

public:

Expand Down
2 changes: 1 addition & 1 deletion src/wrench/services/Service.cpp
Expand Up @@ -25,7 +25,7 @@ namespace wrench {
* @param mailbox_name_prefix: the prefix for the mailbox name
*/
Service::Service(std::string process_name_prefix, std::string mailbox_name_prefix) :
S4U_DaemonWithMailbox(process_name_prefix, mailbox_name_prefix) {
S4U_Daemon(process_name_prefix, mailbox_name_prefix) {
this->name = process_name_prefix;
this->state = Service::UP;
}
Expand Down
4 changes: 2 additions & 2 deletions src/wrench/services/Service.h
Expand Up @@ -15,7 +15,7 @@
#include <string>
#include <map>

#include <simgrid_S4U_util/S4U_DaemonWithMailbox.h>
#include <simgrid_S4U_util/S4U_Daemon.h>

namespace wrench {

Expand All @@ -24,7 +24,7 @@ namespace wrench {
/**
* @brief A top-level class that defines a service
*/
class Service : public S4U_DaemonWithMailbox {
class Service : public S4U_Daemon {

public:

Expand Down
Expand Up @@ -48,7 +48,7 @@ namespace wrench {
std::set<std::pair<std::string, unsigned long>> compute_resources,
StorageService *default_storage_service,
std::map<std::string, std::string> plist) :
S4U_DaemonWithMailbox("standard_job_executor", "standard_job_executor") {
S4U_Daemon("standard_job_executor", "standard_job_executor") {

if ((job == nullptr) || (compute_resources.size() <= 0)) {
throw std::invalid_argument("StandardJobExecutor::StandardJobExecutor(): invalid arguments");
Expand Down
Expand Up @@ -36,7 +36,7 @@ namespace wrench {
/** @brief A base abstraction that knows how to execute a standard job
* on a multi-node multi-core platform.
*/
class StandardJobExecutor : public S4U_DaemonWithMailbox {
class StandardJobExecutor : public S4U_Daemon {

public:

Expand Down
Expand Up @@ -48,7 +48,7 @@ namespace wrench {
std::shared_ptr<Workunit> workunit,
StorageService *default_storage_service,
double thread_startup_overhead) :
S4U_DaemonWithMailbox("workunit_multicore_executor", "workunit_multicore_executor") {
S4U_Daemon("workunit_multicore_executor_" + std::to_string(S4U_Mailbox::generateUniqueSequenceNumber())) {

if (thread_startup_overhead < 0) {
throw std::invalid_argument("WorkunitMulticoreExecutor::WorkunitMulticoreExecutor(): thread_startup_overhead must be >= 0");
Expand Down Expand Up @@ -178,7 +178,7 @@ namespace wrench {
for (auto task : work->tasks) {

// Read all input files
WRENCH_INFO("Reading the %ld input files for task %s", task->getInputFiles().size(), task->getId().c_str());
// WRENCH_INFO("Reading the %ld input files for task %s", task->getInputFiles().size(), task->getId().c_str());
try {
StorageService::readFiles(task->getInputFiles(),
work->file_locations,
Expand All @@ -195,7 +195,7 @@ namespace wrench {
runMulticoreComputation(task->getFlops(), task->getParallelEfficiency());


WRENCH_INFO("Writing the %ld output files for task %s", task->getOutputFiles().size(), task->getId().c_str());
// WRENCH_INFO("Writing the %ld output files for task %s", task->getOutputFiles().size(), task->getId().c_str());

// Write all output files
try {
Expand Down
Expand Up @@ -12,7 +12,7 @@
#define WRENCH_WORKUNITMULTICOREEXECUTOR_H


#include <simgrid_S4U_util/S4U_DaemonWithMailbox.h>
#include <simgrid_S4U_util/S4U_Daemon.h>

namespace wrench {

Expand All @@ -32,7 +32,7 @@ namespace wrench {
/**
* @brief An actor that knows how to perform a work unit
*/
class WorkunitMulticoreExecutor : public S4U_DaemonWithMailbox {
class WorkunitMulticoreExecutor : public S4U_Daemon {

public:

Expand Down
Expand Up @@ -110,7 +110,6 @@ namespace wrench {
}

// Wait for a message
WRENCH_INFO("Waiting for next message...");
unsigned long target = S4U_PendingCommunication::waitForSomethingToHappen(&(this->pending_communications));

// Extract the pending comm
Expand Down
Expand Up @@ -8,30 +8,42 @@
*
*/

#include "simgrid_S4U_util/S4U_DaemonWithMailbox.h"
#include "simgrid_S4U_util/S4U_DaemonWithMailboxActor.h"
#include "simgrid_S4U_util/S4U_Daemon.h"
#include "simgrid_S4U_util/S4U_DaemonActor.h"
#include "simgrid_S4U_util/S4U_Mailbox.h"

namespace wrench {

/**
* @brief Constructor
* @brief Constructor (daemon with a mailbox)
*
* @param process_name: the name of the simulated process/actor
* @param mailbox_prefix: the prefix of the mailbox (to which a unique integer is appended)
*/
S4U_DaemonWithMailbox::S4U_DaemonWithMailbox(std::string process_name, std::string mailbox_prefix)
S4U_Daemon::S4U_Daemon(std::string process_name, std::string mailbox_prefix)
: process_name(process_name),
mailbox_name(S4U_Mailbox::generateUniqueMailboxName(mailbox_prefix)) {
this->terminated = false;
}

/**
* @brief Constructor (daemon without a mailbox)
*
* @param process_name: the name of the simulated process/actor
*/
S4U_Daemon::S4U_Daemon(std::string process_name)
: process_name(process_name),
mailbox_name("") {
this->terminated = false;
}


/**
* @brief Start the daemon
*
* @param hostname: the name of the host on which to start the daemon
*/
void S4U_DaemonWithMailbox::start(std::string hostname) {
void S4U_Daemon::start(std::string hostname) {

// Check that the host exists, and if not throw an exceptions
if (simgrid::s4u::Host::by_name_or_null(hostname) == nullptr) {
Expand All @@ -42,7 +54,7 @@ namespace wrench {
try {
this->s4u_actor = simgrid::s4u::Actor::createActor(this->process_name.c_str(),
simgrid::s4u::Host::by_name(hostname),
S4U_DaemonWithMailboxActor(this));
S4U_DaemonActor(this));
} catch (std::exception &e) {
// Some internal SimGrid exceptions...
std::abort();
Expand All @@ -58,7 +70,7 @@ namespace wrench {
/**
* @brief Kill the daemon/actor.
*/
void S4U_DaemonWithMailbox::kill_actor() {
void S4U_Daemon::kill_actor() {
if (not this->terminated) {
this->s4u_actor->kill();
this->terminated = true;
Expand All @@ -68,7 +80,7 @@ namespace wrench {
/**
* @brief Set the terminated status of the daemon/actor
*/
void S4U_DaemonWithMailbox::setTerminated() {
void S4U_Daemon::setTerminated() {
this->terminated = true;
}

Expand All @@ -77,7 +89,7 @@ namespace wrench {
*
* @return the name
*/
std::string S4U_DaemonWithMailbox::getName() {
std::string S4U_Daemon::getName() {
return this->process_name;
}

Expand Down
Expand Up @@ -7,8 +7,8 @@
* (at your option) any later version.
*/

#ifndef WRENCH_SIM4U_DAEMONWITHMAILBOX_H
#define WRENCH_SIM4U_DAEMONWITHMAILBOX_H
#ifndef WRENCH_SIM4U_DAEMON_H
#define WRENCH_SIM4U_DAEMON_H

#include <string>

Expand All @@ -23,7 +23,7 @@ namespace wrench {
/**
* @brief A generic "running daemon that listens on a mailbox" abstraction
*/
class S4U_DaemonWithMailbox {
class S4U_Daemon {

public:
/** @brief The name of the daemon */
Expand All @@ -33,7 +33,9 @@ namespace wrench {
/** @brief The name of the host on which the daemon is running */
std::string hostname;

S4U_DaemonWithMailbox(std::string process_name, std::string mailbox_prefix);
S4U_Daemon(std::string process_name, std::string mailbox_prefix);
S4U_Daemon(std::string process_name);

void start(std::string hostname);
/** @brief The daemon's main routine
* @return 0 on success, !=0 otherwise
Expand Down
Expand Up @@ -9,10 +9,10 @@
*
*/

#ifndef WRENCH_SIM4U_DAEMONWITHMAILBOXACTOR_H
#define WRENCH_SIM4U_DAEMONWITHMAILBOXACTOR_H
#ifndef WRENCH_SIM4U_DAEMONACTOR_H
#define WRENCH_SIM4U_DAEMONACTOR_H

XBT_LOG_NEW_DEFAULT_CATEGORY(S4U_DaemonWithMailboxActor, "S4U_DaemonWithMailboxActor");
XBT_LOG_NEW_DEFAULT_CATEGORY(S4U_DaemonWithMailboxActor, "S4U_DaemonActor");

#include <xbt.h>
#include <string>
Expand All @@ -27,20 +27,20 @@ namespace wrench {
/** \cond INTERNAL */
/***********************/

class S4U_DaemonWithMailbox;
class S4U_Daemon;

/**
* @brief The actor for the S4U_DaemonWithMailbox abstraction
*/
class S4U_DaemonWithMailboxActor {
class S4U_DaemonActor {

public:

/**
* @brief Constructor
* @param d: a "daemon with mailbox" instance
*/
explicit S4U_DaemonWithMailboxActor(S4U_DaemonWithMailbox *d) {
explicit S4U_DaemonActor(S4U_Daemon *d) {
this->daemon = d;
}

Expand All @@ -50,16 +50,15 @@ namespace wrench {
void operator()() {
try {
this->daemon->main();
WRENCH_INFO("Daemon's main() function has returned");
// S4U_Mailbox::clear_dputs();
// WRENCH_INFO("Daemon's main() function has returned");
} catch (std::exception &e) {
throw;
}
this->daemon->setTerminated();
}

private:
S4U_DaemonWithMailbox *daemon;
S4U_Daemon *daemon;

};

Expand Down
2 changes: 1 addition & 1 deletion src/wrench/simgrid_S4U_util/S4U_Mailbox.h
Expand Up @@ -42,9 +42,9 @@ namespace wrench {
// static void clear_dputs();

static std::string generateUniqueMailboxName(std::string);
static unsigned long generateUniqueSequenceNumber();

private:
static unsigned long generateUniqueSequenceNumber();

// static std::map<simgrid::s4u::ActorPtr , std::set<simgrid::s4u::CommPtr>> dputs;

Expand Down
2 changes: 1 addition & 1 deletion src/wrench/wms/WMS.cpp
Expand Up @@ -30,7 +30,7 @@ namespace wrench {
std::unique_ptr<Scheduler> scheduler,
std::string hostname,
std::string suffix) :
S4U_DaemonWithMailbox("wms_" + suffix, "wms_" + suffix),
S4U_Daemon("wms_" + suffix, "wms_" + suffix),
workflow(workflow),
scheduler(std::move(scheduler)) {

Expand Down
4 changes: 2 additions & 2 deletions src/wrench/wms/WMS.h
Expand Up @@ -10,7 +10,7 @@
#ifndef WRENCH_WMS_H
#define WRENCH_WMS_H

#include "simgrid_S4U_util/S4U_DaemonWithMailbox.h"
#include "simgrid_S4U_util/S4U_Daemon.h"
#include "wms/scheduler/Scheduler.h"
#include "wms/optimizations/dynamic/DynamicOptimization.h"
#include "wms/optimizations/static/StaticOptimization.h"
Expand All @@ -25,7 +25,7 @@ namespace wrench {
/**
* @brief A top-level class that defines a workflow management system
*/
class WMS : public S4U_DaemonWithMailbox {
class WMS : public S4U_Daemon {

public:
void addStaticOptimization(std::unique_ptr<StaticOptimization>);
Expand Down

0 comments on commit efe1150

Please sign in to comment.