Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed Oct 16, 2024
1 parent 32d0b43 commit 07246f7
Show file tree
Hide file tree
Showing 87 changed files with 395 additions and 427 deletions.
6 changes: 3 additions & 3 deletions include/wrench/action/FileReadAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ namespace wrench {
std::shared_ptr<DataFile> getFile() const;
std::vector<std::shared_ptr<FileLocation>> getFileLocations() const;
std::shared_ptr<FileLocation> getUsedFileLocation() const;
double getNumBytesToRead() const;
sg_size_t getNumBytesToRead() const;
bool usesScratch() const override;

protected:
friend class CompoundJob;

FileReadAction(const std::string &name,
std::vector<std::shared_ptr<FileLocation>> file_locations,
double num_bytes_to_read);
sg_size_t num_bytes_to_read);


void execute(const std::shared_ptr<ActionExecutor> &action_executor) override;
Expand All @@ -52,7 +52,7 @@ namespace wrench {
std::shared_ptr<DataFile> file;
std::vector<std::shared_ptr<FileLocation>> file_locations;
std::shared_ptr<FileLocation> used_location;
double num_bytes_to_read;
sg_size_t num_bytes_to_read;
};


Expand Down
20 changes: 10 additions & 10 deletions include/wrench/execution_controller/ExecutionController.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,20 @@ namespace wrench {
void waitForAndProcessNextEvent();
bool waitForAndProcessNextEvent(double timeout);

virtual void processEventCompoundJobFailure(std::shared_ptr<CompoundJobFailedEvent>);
virtual void processEventCompoundJobCompletion(std::shared_ptr<CompoundJobCompletedEvent>);
virtual void processEventCompoundJobFailure(const std::shared_ptr<CompoundJobFailedEvent> &event);
virtual void processEventCompoundJobCompletion(const std::shared_ptr<CompoundJobCompletedEvent> &event);

virtual void processEventStandardJobCompletion(std::shared_ptr<StandardJobCompletedEvent>);
virtual void processEventStandardJobFailure(std::shared_ptr<StandardJobFailedEvent>);
virtual void processEventStandardJobCompletion(const std::shared_ptr<StandardJobCompletedEvent> &event);
virtual void processEventStandardJobFailure(const std::shared_ptr<StandardJobFailedEvent> &event);


virtual void processEventPilotJobStart(std::shared_ptr<PilotJobStartedEvent>);
virtual void processEventPilotJobExpiration(std::shared_ptr<PilotJobExpiredEvent>);
virtual void processEventPilotJobStart(const std::shared_ptr<PilotJobStartedEvent> &event);
virtual void processEventPilotJobExpiration(const std::shared_ptr<PilotJobExpiredEvent> &event);

virtual void processEventFileCopyCompletion(std::shared_ptr<FileCopyCompletedEvent>);
virtual void processEventFileCopyFailure(std::shared_ptr<FileCopyFailedEvent>);
virtual void processEventFileCopyCompletion(const std::shared_ptr<FileCopyCompletedEvent> &event);
virtual void processEventFileCopyFailure(const std::shared_ptr<FileCopyFailedEvent> &event);

virtual void processEventTimer(std::shared_ptr<TimerEvent>);
virtual void processEventTimer(const std::shared_ptr<TimerEvent> &event);

void setDaemonized(bool daemonized);

Expand All @@ -90,7 +90,7 @@ namespace wrench {
friend class DataMovementManager;
friend class JobManager;

bool daemonized = false;
bool daemonized_ = false;

private:
virtual int main() = 0;
Expand Down
12 changes: 6 additions & 6 deletions include/wrench/job/CompoundJob.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace wrench {
std::shared_ptr<FileReadAction> addFileReadAction(const std::string &name,
const std::shared_ptr<DataFile> &file,
const std::shared_ptr<StorageService> &storageService,
double num_bytes_to_read);
sg_size_t num_bytes_to_read);

std::shared_ptr<FileReadAction> addFileReadAction(const std::string &name,
const std::shared_ptr<FileLocation> &file_location);
Expand All @@ -93,11 +93,11 @@ namespace wrench {

std::shared_ptr<FileReadAction> addFileReadAction(const std::string &name,
const std::shared_ptr<FileLocation> &file_location,
double num_bytes_to_read);
sg_size_t num_bytes_to_read);

std::shared_ptr<FileReadAction> addFileReadAction(const std::string &name,
const std::vector<std::shared_ptr<FileLocation>> &file_locations,
double num_bytes_to_read);
sg_size_t num_bytes_to_read);

std::shared_ptr<FileWriteAction> addFileWriteAction(const std::string &name,
const std::shared_ptr<DataFile> &file,
Expand Down Expand Up @@ -132,13 +132,13 @@ namespace wrench {

std::shared_ptr<ComputeAction> addComputeAction(const std::string &name,
double flops,
double ram,
sg_size_t ram,
unsigned long min_num_cores,
unsigned long max_num_cores,
const std::shared_ptr<ParallelModel> &parallel_model);

std::shared_ptr<CustomAction> addCustomAction(const std::string &name,
double ram,
sg_size_t ram,
unsigned long num_cores,
const std::function<void(std::shared_ptr<ActionExecutor> action_executor)> &lambda_execute,
const std::function<void(std::shared_ptr<ActionExecutor> action_executor)> &lambda_terminate);
Expand Down Expand Up @@ -170,7 +170,7 @@ namespace wrench {

unsigned long getMinimumRequiredNumCores();

double getMinimumRequiredMemory();
sg_size_t getMinimumRequiredMemory();


/***********************/
Expand Down
8 changes: 4 additions & 4 deletions include/wrench/simgrid_S4U_util/S4U_CommPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ namespace wrench {
#ifndef NDEBUG
this->templateWaitingLogUpdate(get_type_name<TMessageType>(), id);
#endif
message.release();
message.release(); // NOLINT(bugprone-unused-return-value)
return std::unique_ptr<TMessageType>(msg);
} else {
std::cerr << "message = " << message.get() << "\n";
throw std::runtime_error(error_prefix + " Unexpected [" + ((message.get() != nullptr) ? message->getName() : "null-message") + "] message while waiting for " +
throw std::runtime_error(error_prefix + " Unexpected [" + ((message != nullptr) ? message->getName() : "null-message") + "] message while waiting for " +
get_type_name<TMessageType>() + ". Request ID: " + std::to_string(id));
}
}
Expand All @@ -98,7 +98,7 @@ namespace wrench {
auto message = this->getMessage(timeout, false);

if (auto msg = dynamic_cast<TMessageType *>(message.get())) {
message.release();
message.release(); // NOLINT(bugprone-unused-return-value)
#ifndef NDEBUG
this->templateWaitingLogUpdate(tn, id);
#endif
Expand Down Expand Up @@ -163,7 +163,7 @@ namespace wrench {
* @brief Return the commport's name (as a C++ string)
* @return the commport's name
*/
[[nodiscard]] const std::string get_name() const {
[[nodiscard]] std::string get_name() const {
return this->name;
}

Expand Down
12 changes: 6 additions & 6 deletions include/wrench/simgrid_S4U_util/S4U_Daemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace wrench {

virtual ~S4U_Daemon();

void startDaemon(bool _daemonized, bool _auto_restart);
void startDaemon(bool daemonized, bool auto_restart);

void createLifeSaver(std::shared_ptr<S4U_Daemon> reference);
void deleteLifeSaver();
Expand Down Expand Up @@ -133,7 +133,7 @@ namespace wrench {

protected:
/** @brief a pointer to the simulation object */
Simulation *simulation;
Simulation *simulation_;

/** @brief The service's state */
State state;
Expand Down Expand Up @@ -169,10 +169,10 @@ namespace wrench {
simgrid::s4u::MutexPtr daemon_lock;


bool has_returned_from_main = false;// Set to true after main returns
int return_value = 0; // Set to the value returned by main
bool daemonized{}; // Set to true if daemon is daemonized
bool auto_restart{}; // Set to true if daemon is supposed to auto-restart
bool has_returned_from_main_ = false;// Set to true after main returns
int return_value_ = 0; // Set to the value returned by main
bool daemonized_=true; // Whether the daemon is daemonized (will be overwritten by start())
bool auto_restart_=false; // Whether the daemon is supposed to auto-restart (will be overwritten by start())

static int num_non_daemonized_actors_running;

Expand Down
1 change: 1 addition & 0 deletions include/wrench/simgrid_S4U_util/S4U_Simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define WRENCH_S4U_SIMULATION_H

#include <set>
#include <climits>
#include <simgrid/s4u.hpp>
#include <simgrid/kernel/routing/ClusterZone.hpp>

Expand Down
27 changes: 3 additions & 24 deletions include/wrench/simulation/Simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,31 +124,11 @@ namespace wrench {
// double getEnergyTimestamp(const std::string &hostname, bool can_record = false);

// pstate related calls
static int getNumberofPstates(const std::string &hostname);
static int getNumberOfPstates(const std::string &hostname);
static double getMinPowerConsumption(const std::string &hostname);
static double getMaxPowerConsumption(const std::string &hostname);
static std::vector<int> getListOfPstates(const std::string &hostname);

// /**
// * @brief Creates a file copy on a storage service before the simulation begins
// * @param file: a file
// * @param storage_service: a storage service
// */
// void stageFile(const std::shared_ptr<DataFile> file, const std::shared_ptr<StorageService> &storage_service) {
// this->stageFile(wrench::FileLocation::LOCATION(storage_service, file));
// }
// /**
// * @brief Creates a file copy on a storage service before the simulation begins
// * @param file: a file
// * @param storage_service: a storage service
// * @param path: a path
// */
// void stageFile(const std::shared_ptr<DataFile> file, const std::shared_ptr<StorageService> &storage_service, const std::string &path) {
// this->stageFile(wrench::FileLocation::LOCATION(storage_service, path, file));
// }
//
// void stageFile(const std::shared_ptr<FileLocation> &location);

/***********************/
/** \cond DEVELOPER */
/***********************/
Expand Down Expand Up @@ -216,7 +196,7 @@ namespace wrench {
MemoryManager *getMemoryManagerByHost(const std::string &hostname);
#endif

static double getMemoryCapacity();
static sg_size_t getMemoryCapacity();
static unsigned long getNumCores();
static double getFlopRate();
static std::string getHostName();
Expand Down Expand Up @@ -253,8 +233,7 @@ namespace wrench {
std::set<std::shared_ptr<MemoryManager>> memory_managers;
#endif

static int unique_disk_sequence_number;

// static int unique_disk_sequence_number;

void platformSanityCheck();
void checkSimulationSetup();
Expand Down
12 changes: 6 additions & 6 deletions include/wrench/simulation/SimulationOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,21 @@ namespace wrench {
std::shared_ptr<FileLocation> dst);

int
addTimestampDiskReadStart(double date, std::string hostname, std::string mount, double bytes);
addTimestampDiskReadStart(double date, std::string hostname, std::string mount, sg_size_t bytes);

void
addTimestampDiskReadFailure(double date, const std::string &hostname, const std::string &mount, double bytes, int unique_sequence_number);
addTimestampDiskReadFailure(double date, const std::string &hostname, const std::string &mount, sg_size_t bytes, int unique_sequence_number);

void addTimestampDiskReadCompletion(double date, const std::string &hostname, const std::string &mount, double bytes,
void addTimestampDiskReadCompletion(double date, const std::string &hostname, const std::string &mount, sg_size_t bytes,
int unique_sequence_number);

int
addTimestampDiskWriteStart(double date, std::string hostname, std::string mount, double bytes);
addTimestampDiskWriteStart(double date, std::string hostname, std::string mount, sg_size_t bytes);

void
addTimestampDiskWriteFailure(double date, const std::string &hostname, const std::string &mount, double bytes, int unique_sequence_number);
addTimestampDiskWriteFailure(double date, const std::string &hostname, const std::string &mount, sg_size_t bytes, int unique_sequence_number);

void addTimestampDiskWriteCompletion(double date, const std::string &hostname, const std::string &mount, double bytes,
void addTimestampDiskWriteCompletion(double date, const std::string &hostname, const std::string &mount, sg_size_t bytes,
int unique_sequence_number);

void addTimestampPstateSet(double date, const std::string &hostname, int pstate);
Expand Down
6 changes: 3 additions & 3 deletions include/wrench/workflow/parallel_model/AmdahlParallelModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace wrench {
class AmdahlParallelModel : public ParallelModel {

public:
double getAlpha() const;
[[nodiscard]] double getAlpha() const;
void setAlpha(double alpha);

/***********************/
Expand All @@ -41,8 +41,8 @@ namespace wrench {
private:
friend class ParallelModel;

AmdahlParallelModel(double alpha);
double alpha;// Fraction of the work that's parallelizable
explicit AmdahlParallelModel(double alpha);
double alpha_;// Fraction of the work that's parallelizable
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace wrench {
friend class ParallelModel;

ConstantEfficiencyParallelModel(double efficiency);
double efficiency;// Parallel efficiency
double efficiency_;// Parallel efficiency
};


Expand Down
8 changes: 4 additions & 4 deletions src/wrench/action/FileReadAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ namespace wrench {
* @brief Constructor
* @param name: the action's name (if empty, a unique name will be picked for you)
* @param file_locations: the locations to read from (will be tried in order until one succeeds)
* @param num_bytes_to_read: the number of bytes to read (if < 0: read the whole file)
* @param num_bytes_to_read: the number of bytes to read (if == 0: read the whole file)
*/
FileReadAction::FileReadAction(const std::string &name,
std::vector<std::shared_ptr<FileLocation>> file_locations,
double num_bytes_to_read) : Action(name, "file_read_"),
sg_size_t num_bytes_to_read) : Action(name, "file_read_"),
file_locations(file_locations) {

this->file = file_locations.at(0)->getFile();
Expand All @@ -42,7 +42,7 @@ namespace wrench {
}
}

if (num_bytes_to_read < 0.0) {
if (num_bytes_to_read == 0) {
this->num_bytes_to_read = this->file->getSize();
} else if (num_bytes_to_read <= this->file->getSize()) {
this->num_bytes_to_read = num_bytes_to_read;
Expand Down Expand Up @@ -119,7 +119,7 @@ namespace wrench {
* @brief Return the number of bytes to read by this action
* @return A number of bytes
*/
double FileReadAction::getNumBytesToRead() const {
sg_size_t FileReadAction::getNumBytesToRead() const {
return this->num_bytes_to_read;
}

Expand Down
Loading

0 comments on commit 07246f7

Please sign in to comment.