friend XBT_PUBLIC void intrusive_ptr_add_ref(simgrid::s4u::Io* i);
friend Storage; // Factory of IOs
+ enum class OpType { READ, WRITE };
~Io() = default;
Activity* start() override;
Activity* cancel() override;
double get_remaining() override;
+ IoPtr set_io_type(OpType type);
private:
sg_size_t size_ = 0;
sg_storage_t storage_ = nullptr;
+ std::string name_ = "";
+ OpType type_ = OpType::READ;
std::atomic_int_fast32_t refcount_{0};
}; // class
}
XBT_PUBLIC int simcall_sem_acquire_timeout(smx_sem_t sem, double max_duration);
/***************************** Storage **********************************/
-#ifdef __cplusplus
-XBT_PUBLIC smx_activity_t simcall_io_start(std::string name, sg_size_t size, sg_storage_t storage);
-#endif
XBT_PUBLIC sg_size_t simcall_storage_read(surf_storage_t st, sg_size_t size);
XBT_PUBLIC sg_size_t simcall_storage_write(surf_storage_t fd, sg_size_t size);
/************************** MC simcalls **********************************/
#include "simgrid/s4u/Io.hpp"
#include "simgrid/s4u/Storage.hpp"
#include "src/kernel/activity/IoImpl.hpp"
+#include "src/simix/smx_io_private.hpp"
#include "xbt/log.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_io, s4u_activity, "S4U asynchronous IOs");
Activity* Io::start()
{
- pimpl_ = simcall_io_start("", size_, storage_);
+ pimpl_ = simix::simcall([this] { return SIMIX_io_start(name_, size_, storage_, type_); });
state_ = State::STARTED;
return this;
}
[this]() { return boost::static_pointer_cast<simgrid::kernel::activity::IoImpl>(pimpl_)->get_remaining(); });
}
+IoPtr Io::set_io_type(OpType type)
+{
+ xbt_assert(state_ == State::INITED, "Cannot change the name of an exec after its start");
+ type_ = type;
+ return this;
+}
+
// double Io::get_remaining_ratio()
//{
// return simgrid::simix::simcall([this]() {
return simcall_BODY_sem_acquire_timeout(sem, timeout);
}
-smx_activity_t simcall_io_start(std::string name, sg_size_t size, simgrid::s4u::Storage* storage)
-{
- /* checking for infinite values */
- xbt_assert(std::isfinite(size), "size is not finite!");
-
- return simgrid::simix::simcall([name, size, storage] { return SIMIX_io_start(name, size, storage); });
-}
-
sg_size_t simcall_storage_read(surf_storage_t st, sg_size_t size)
{
return simcall_BODY_storage_read(st, size);
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "simgrid/s4u/Host.hpp"
+#include "simgrid/s4u/Io.hpp"
#include "xbt/ex.hpp"
#include "smx_private.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix, "Logging specific to SIMIX (io)");
-simgrid::kernel::activity::IoImplPtr SIMIX_io_start(std::string name, sg_size_t size, sg_storage_t storage)
+simgrid::kernel::activity::IoImplPtr SIMIX_io_start(std::string name, sg_size_t size, sg_storage_t storage,
+ simgrid::s4u::Io::OpType type)
{
/* set surf's action */
- // FIXME
- simgrid::kernel::resource::Action* surf_action =
- storage->get_impl()->io_start(size, (simgrid::surf::e_surf_action_storage_type_t)0);
+ simgrid::kernel::resource::Action* surf_action = storage->get_impl()->io_start(size, type);
simgrid::kernel::activity::IoImplPtr io =
simgrid::kernel::activity::IoImplPtr(new simgrid::kernel::activity::IoImpl(name, surf_action, storage));
#include <xbt/base.h>
#include "popping_private.hpp"
+#include "simgrid/s4u/Io.hpp"
#include "simgrid/simix.h"
-XBT_PRIVATE simgrid::kernel::activity::IoImplPtr SIMIX_io_start(std::string name, sg_size_t size, sg_storage_t storage);
+XBT_PRIVATE simgrid::kernel::activity::IoImplPtr SIMIX_io_start(std::string name, sg_size_t size, sg_storage_t storage,
+ simgrid::s4u::Io::OpType type);
XBT_PRIVATE smx_activity_t SIMIX_storage_read(surf_storage_t fd, sg_size_t size);
XBT_PRIVATE smx_activity_t SIMIX_storage_write(surf_storage_t fd, sg_size_t size);
#include "simgrid/kernel/resource/Action.hpp"
#include "simgrid/kernel/resource/Model.hpp"
#include "simgrid/kernel/resource/Resource.hpp"
+#include "simgrid/s4u/Io.hpp"
#include "simgrid/s4u/Storage.hpp"
#include "src/surf/PropertyHolder.hpp"
#include "src/surf/trace_mgr.hpp"
/** @ingroup SURF_storage_interface
* @brief The possible type of action for the storage component
*/
-enum e_surf_action_storage_type_t {
- READ = 0, /**< Read a file */
- WRITE /**< Write in a file */
-};
-
/*************
* Callbacks *
*************/
void turn_off() override;
void destroy(); // Must be called instead of the destructor
- virtual simgrid::kernel::resource::Action* io_start(sg_size_t size, e_surf_action_storage_type_t type) = 0;
+ virtual simgrid::kernel::resource::Action* io_start(sg_size_t size, s4u::Io::OpType type) = 0;
/**
* @brief Read a file
*
* @param storage The Storage associated to this StorageAction
* @param type [description]
*/
- StorageAction(kernel::resource::Model* model, double cost, bool failed, StorageImpl* storage,
- e_surf_action_storage_type_t type)
+ StorageAction(kernel::resource::Model* model, double cost, bool failed, StorageImpl* storage, s4u::Io::OpType type)
: Action(model, cost, failed), type_(type), storage_(storage){};
/**
* @param type [description]
*/
StorageAction(kernel::resource::Model* model, double cost, bool failed, kernel::lmm::Variable* var,
- StorageImpl* storage, e_surf_action_storage_type_t type)
+ StorageImpl* storage, s4u::Io::OpType type)
: Action(model, cost, failed, var), type_(type), storage_(storage){};
void set_state(simgrid::kernel::resource::Action::State state) override;
- e_surf_action_storage_type_t type_;
+ s4u::Io::OpType type_;
StorageImpl* storage_;
};
simgrid::s4u::Storage::on_creation(this->piface_);
}
-StorageAction* StorageN11::io_start(sg_size_t size, e_surf_action_storage_type_t type)
+StorageAction* StorageN11::io_start(sg_size_t size, s4u::Io::OpType type)
{
return new StorageN11Action(get_model(), size, is_off(), this, type);
}
StorageAction* StorageN11::read(sg_size_t size)
{
- return new StorageN11Action(get_model(), size, is_off(), this, READ);
+ return new StorageN11Action(get_model(), size, is_off(), this, s4u::Io::OpType::READ);
}
StorageAction* StorageN11::write(sg_size_t size)
{
- return new StorageN11Action(get_model(), size, is_off(), this, WRITE);
+ return new StorageN11Action(get_model(), size, is_off(), this, s4u::Io::OpType::WRITE);
}
/**********
**********/
StorageN11Action::StorageN11Action(kernel::resource::Model* model, double cost, bool failed, StorageImpl* storage,
- e_surf_action_storage_type_t type)
+ s4u::Io::OpType type)
: StorageAction(model, cost, failed, model->get_maxmin_system()->variable_new(this, 1.0, -1.0, 3), storage, type)
{
XBT_IN("(%s,%g", storage->get_cname(), cost);
// Must be less than the max bandwidth for all actions
model->get_maxmin_system()->expand(storage->get_constraint(), get_variable(), 1.0);
switch(type) {
- case READ:
- model->get_maxmin_system()->expand(storage->constraintRead_, get_variable(), 1.0);
- break;
- case WRITE:
- model->get_maxmin_system()->expand(storage->constraintWrite_, get_variable(), 1.0);
- break;
- default:
- THROW_UNIMPLEMENTED;
+ case s4u::Io::OpType::READ:
+ model->get_maxmin_system()->expand(storage->constraintRead_, get_variable(), 1.0);
+ break;
+ case s4u::Io::OpType::WRITE:
+ model->get_maxmin_system()->expand(storage->constraintWrite_, get_variable(), 1.0);
+ break;
+ default:
+ THROW_UNIMPLEMENTED;
}
XBT_OUT();
}
StorageN11(StorageModel* model, std::string name, kernel::lmm::System* maxminSystem, double bread, double bwrite,
std::string type_id, std::string content_name, sg_size_t size, std::string attach);
virtual ~StorageN11() = default;
- StorageAction* io_start(sg_size_t size, e_surf_action_storage_type_t type);
+ StorageAction* io_start(sg_size_t size, s4u::Io::OpType type);
StorageAction* read(sg_size_t size);
StorageAction* write(sg_size_t size);
};
class StorageN11Action : public StorageAction {
public:
StorageN11Action(kernel::resource::Model* model, double cost, bool failed, StorageImpl* storage,
- e_surf_action_storage_type_t type);
+ s4u::Io::OpType type);
void suspend() override;
void cancel() override;
void resume() override;