auto jupiter = e.host_by_name("Jupiter");
// Create operations
- auto exec1 = simgrid::plugins::ExecOp::create("exec1", 1e9, tremblay);
- auto exec2 = simgrid::plugins::ExecOp::create("exec2", 1e9, jupiter);
- auto comm = simgrid::plugins::CommOp::create("comm", 1e7, tremblay, jupiter);
+ auto exec1 = simgrid::plugins::ExecOp::init("exec1", 1e9, tremblay);
+ auto exec2 = simgrid::plugins::ExecOp::init("exec2", 1e9, jupiter);
+ auto comm = simgrid::plugins::CommOp::init("comm", 1e7, tremblay, jupiter);
// Create the graph by defining dependencies between operations
exec1->add_successor(comm);
auto fafard = e.host_by_name("Fafard");
// Create operations
- auto comm0 = simgrid::plugins::CommOp::create("comm0", 1e7, tremblay, jupiter);
- auto exec1 = simgrid::plugins::ExecOp::create("exec1", 1e9, jupiter);
- auto exec2 = simgrid::plugins::ExecOp::create("exec2", 1e9, fafard);
- auto comm1 = simgrid::plugins::CommOp::create("comm1", 1e7, jupiter, tremblay);
- auto comm2 = simgrid::plugins::CommOp::create("comm2", 1e7, fafard, tremblay);
+ auto comm0 = simgrid::plugins::CommOp::init("comm0");
+ comm0->set_bytes(1e7);
+ comm0->set_source(tremblay);
+ auto exec1 = simgrid::plugins::ExecOp::init("exec1", 1e9, jupiter);
+ auto exec2 = simgrid::plugins::ExecOp::init("exec2", 1e9, fafard);
+ auto comm1 = simgrid::plugins::CommOp::init("comm1", 1e7, jupiter, tremblay);
+ auto comm2 = simgrid::plugins::CommOp::init("comm2", 1e7, fafard, tremblay);
// Create the initial graph by defining dependencies between operations
comm0->add_successor(exec2);
auto jupiter = e.host_by_name("Jupiter");
// Create operations
- auto comm = simgrid::plugins::CommOp::create("comm", 1e7, tremblay, jupiter);
- auto exec = simgrid::plugins::ExecOp::create("exec", 1e9, jupiter);
+ auto comm = simgrid::plugins::CommOp::init("comm", 1e7, tremblay, jupiter);
+ auto exec = simgrid::plugins::ExecOp::init("exec", 1e9, jupiter);
// Create the graph by defining dependencies between operations
comm->add_successor(exec);
simgrid::s4u::ActivityPtr current_activity_;
std::function<void(Operation*)> end_func_ = [](Operation*) {};
std::function<void(Operation*)> start_func_ = [](Operation*) {};
- Operation(const std::string& name, double amount);
+ Operation(const std::string& name);
virtual ~Operation() = default;
virtual void execute() = 0;
private:
simgrid::s4u::Host* host_;
- ExecOp(const std::string& name, double flops, simgrid::s4u::Host* host);
+ ExecOp(const std::string& name);
void execute();
public:
- static ExecOpPtr create(const std::string& name, double flops, simgrid::s4u::Host* host);
+ static ExecOpPtr init(const std::string& name);
+ static ExecOpPtr init(const std::string& name, double flops, simgrid::s4u::Host* host);
void set_host(simgrid::s4u::Host* host);
+ void set_flops(double flops);
};
class CommOp : public Operation {
simgrid::s4u::Host* source_;
simgrid::s4u::Host* destination_;
- CommOp(const std::string& name, double bytes, simgrid::s4u::Host* source, simgrid::s4u::Host* destination);
+ CommOp(const std::string& name);
void execute();
public:
- static CommOpPtr create(const std::string& name, double bytes, simgrid::s4u::Host* source,
- simgrid::s4u::Host* destination);
+ static CommOpPtr init(const std::string& name);
+ static CommOpPtr init(const std::string& name, double bytes, simgrid::s4u::Host* source,
+ simgrid::s4u::Host* destination);
void set_source(simgrid::s4u::Host* source);
void set_destination(simgrid::s4u::Host* destination);
+ void set_bytes(double bytes);
};
} // namespace simgrid::plugins
#endif
\ No newline at end of file
Operations are designed to represent workflows, i.e, graphs of Operations.
Operations can only be instancied using either
-:cpp:func:`simgrid::plugins::ExecOp::create` or :cpp:func:`simgrid::plugins::CommOp::create`
+:cpp:func:`simgrid::plugins::ExecOp::init` or :cpp:func:`simgrid::plugins::CommOp::init`
An ExecOp is an Execution Operation. Its underlying Activity is an :ref:`Exec <API_s4u_Exec>`.
A CommOp is a Communication Operation. Its underlying Activity is a :ref:`Comm <API_s4u_Comm>`.
xbt::signal<void(Operation*)> Operation::on_start;
xbt::signal<void(Operation*)> Operation::on_end;
-Operation::Operation(const std::string& name, double amount) : name_(name), amount_(amount) {}
+Operation::Operation(const std::string& name) : name_(name) {}
std::string Operation::get_name()
{
/**
* @brief Default constructor.
*/
-ExecOp::ExecOp(const std::string& name, double flops, simgrid::s4u::Host* host) : Operation(name, flops), host_(host) {}
+ExecOp::ExecOp(const std::string& name) : Operation(name) {}
/** @ingroup plugin_operation
* @brief Smart Constructor.
*/
-ExecOpPtr ExecOp::create(const std::string& name, double flops, simgrid::s4u::Host* host)
+ExecOpPtr ExecOp::init(const std::string& name)
{
- auto op = ExecOpPtr(new ExecOp(name, flops, host));
+ auto op = ExecOpPtr(new ExecOp(name));
+ return op;
+}
+
+/** @ingroup plugin_operation
+ * @brief Smart Constructor.
+ */
+ExecOpPtr ExecOp::init(const std::string& name, double flops, simgrid::s4u::Host* host)
+{
+ auto op = ExecOpPtr(new ExecOp(name));
+ op->set_flops(flops);
+ op->set_host(host);
return op;
}
/**
* @brief Do one execution of the Operation.
* @note Call the on_this_start() func. Set its working status as true.
- * Create and start the underlying Activity.
+ * Init and start the underlying Activity.
*/
void ExecOp::execute()
{
simgrid::kernel::actor::simcall_answered([this, host] { host_ = host; });
}
+/** @ingroup plugin_operation
+ * @param flops The amount of flops to set.
+ */
+void ExecOp::set_flops(double flops)
+{
+ simgrid::kernel::actor::simcall_answered([this, flops] { amount_ = flops; });
+}
+
/**
* @brief Default constructor.
*/
-CommOp::CommOp(const std::string& name, double bytes, simgrid::s4u::Host* source, simgrid::s4u::Host* destination)
- : Operation(name, bytes), source_(source), destination_(destination)
+CommOp::CommOp(const std::string& name) : Operation(name) {}
+
+/** @ingroup plugin_operation
+ * @brief Smart constructor.
+ */
+CommOpPtr CommOp::init(const std::string& name)
{
+ auto op = CommOpPtr(new CommOp(name));
+ return op;
}
/** @ingroup plugin_operation
* @brief Smart constructor.
*/
-CommOpPtr CommOp::create(const std::string& name, double bytes, simgrid::s4u::Host* source,
- simgrid::s4u::Host* destination)
+CommOpPtr CommOp::init(const std::string& name, double bytes, simgrid::s4u::Host* source,
+ simgrid::s4u::Host* destination)
{
- auto op = CommOpPtr(new CommOp(name, bytes, source, destination));
+ auto op = CommOpPtr(new CommOp(name));
+ op->set_bytes(bytes);
+ op->set_source(source);
+ op->set_destination(destination);
return op;
}
/**
* @brief Do one execution of the Operation.
* @note Call the on_this_start() func. Set its working status as true.
- * Create and start the underlying Activity.
+ * Init and start the underlying Activity.
*/
void CommOp::execute()
{
simgrid::kernel::actor::simcall_answered([this, destination] { destination_ = destination; });
}
+/** @ingroup plugin_operation
+ * @param bytes The amount of bytes to set.
+ */
+void CommOp::set_bytes(double bytes)
+{
+ simgrid::kernel::actor::simcall_answered([this, bytes] { amount_ = bytes; });
+}
+
} // namespace simgrid::plugins
simgrid::xbt::Extension<simgrid::s4u::Activity, simgrid::plugins::ExtendedAttributeActivity>