change injected costs for MPI_Recv, MPI_Send and MPI_Isend operations.
Alternative for smpi/or, smpi/os and smpi/ois configuration options.
+XBT:
+ - Function xbt::Extendable::get_data() is now templated with the type of the
+ pointee. Untyped function is deprecated. Use get_data<void>() if you still
+ want to retrieve void*.
+
Documentation:
- New section: "SimGrid MPI calibration of a Grid5000 cluster"
presenting how to properly calibrate MPI communications in SimGrid.
static double sg_host_get_available_at(const simgrid::s4u::Host* host)
{
- return static_cast<HostAttribute*>(host->get_data())->available_at;
+ return host->get_data<HostAttribute>()->available_at;
}
static void sg_host_set_available_at(const simgrid::s4u::Host* host, double time)
{
- auto* attr = static_cast<HostAttribute*>(host->get_data());
- attr->available_at = time;
+ host->get_data<HostAttribute>()->available_at = time;
}
static simgrid::s4u::Exec* sg_host_get_last_scheduled_task(const simgrid::s4u::Host* host)
{
- return static_cast<HostAttribute*>(host->get_data())->last_scheduled_task;
+ return host->get_data<HostAttribute>()->last_scheduled_task;
}
static void sg_host_set_last_scheduled_task(const simgrid::s4u::Host* host, simgrid::s4u::ExecPtr task)
{
- auto* attr = static_cast<HostAttribute*>(host->get_data());
- attr->last_scheduled_task = task.get();
+ host->get_data<HostAttribute>()->last_scheduled_task = task.get();
}
static bool dependency_exists(const simgrid::s4u::Exec* src, simgrid::s4u::Exec* dst)
}
// We use the user data field to store the finish time of the predecessor of the comm, i.e., its potential start
// time
- data_available = *(static_cast<double*>(comm->get_data())) + redist_time;
+ data_available = *comm->get_data<double>() + redist_time;
}
const auto* exec = dynamic_cast<simgrid::s4u::Exec*>(parent.get());
auto* comm = dynamic_cast<simgrid::s4u::Comm*>(pred.get());
if (comm != nullptr) {
comm->set_destination(host);
- delete static_cast<double*>(comm->get_data());
+ delete comm->get_data<double>();
}
}
// we can also set the source of all the output comms of this exec
/* - Attach some user data to disk1 */
XBT_INFO("*** Get/set data for storage element: Disk1 ***");
- const auto* data = static_cast<std::string*>(disk->get_data());
+ const auto* data = disk->get_data<std::string>();
XBT_INFO("Get storage data: '%s'", data ? data->c_str() : "No user data");
disk->set_data(new std::string("Some user data"));
- data = static_cast<std::string*>(disk->get_data());
+ data = disk->get_data<std::string>();
XBT_INFO("Set and get data: '%s'", data->c_str());
delete data;
}
// Test attaching some user data to the file
file->set_data(new std::string("777"));
- const auto* file_data = static_cast<std::string*>(file->get_data());
+ const auto* file_data = file->get_data<std::string>();
XBT_INFO("User data attached to the file: %s", file_data->c_str());
delete file_data;
#ifndef SIMGRID_XBT_LIB_HPP
#define SIMGRID_XBT_LIB_HPP
+#include "xbt/base.h" // XBT_ATTRIB_DEPRECATED_v334
#include <cstddef>
#include <limits>
#include <vector>
void set_data(void* data){
extensions_[0]=data;
}
- void* get_data() const { return extensions_[0]; }
+ template <typename D> D* get_data() const { return static_cast<D*>(extensions_[0]); }
+ XBT_ATTRIB_DEPRECATED_v334("Please use typed template Extendable::get_data<>()") void* get_data() const
+ {
+ return get_data<void>();
+ }
// Convenience extension access when the type has an associated EXTENSION ID:
template <class U> U* extension() const { return extension<U>(U::EXTENSION_ID); }
template<class U> void extension_set(U* p) { extension_set<U>(U::EXTENSION_ID, p); }
explicit ProcessArg(s4u::Host* host, ActorImpl* actor)
: name(actor->get_name())
, code(actor->code_)
- , data(actor->get_ciface()->get_data())
+ , data(actor->get_ciface()->get_data<void>())
, host(host)
, kill_time(actor->get_kill_time())
, auto_restart(actor->has_to_auto_restart())
/** @brief Return the user data of the given task */
void* MSG_task_get_data(const_msg_task_t task)
{
- return task->get_data();
+ return task->get_data<void>();
}
/** @brief Sets the user data of a given task */
*/
void* sg_file_get_data(const_sg_file_t fd)
{
- return fd->get_data();
+ return fd->get_data<void>();
}
/** Changes the user data associated with the file
void* sg_actor_self_get_data()
{
- return simgrid::s4u::Actor::self()->get_data();
+ return simgrid::s4u::Actor::self()->get_data<void>();
}
void sg_actor_self_set_data(void* userdata)
/** @brief Return the user data of a #sg_actor_t */
void* sg_actor_get_data(const_sg_actor_t actor)
{
- return actor->get_data();
+ return actor->get_data<void>();
}
/** @brief Set the user data of a #sg_actor_t */
void* sg_disk_get_data(const_sg_disk_t disk)
{
- return disk->get_data();
+ return disk->get_data<void>();
}
void sg_disk_set_data(sg_disk_t disk, void* data)
// ========== User data Layer ==========
void* sg_host_get_data(const_sg_host_t host)
{
- return host->get_data();
+ return host->get_data<void>();
}
void sg_host_set_data(sg_host_t host, void* userdata)
{
void* sg_link_get_data(const_sg_link_t link)
{
- return link->get_data();
+ return link->get_data<void>();
}
void sg_link_set_data(sg_link_t link, void* data)
}
void * smpi_process_get_user_data(){
- return simgrid::s4u::Actor::self()->get_data();
+ return simgrid::s4u::Actor::self()->get_data<void>();
}
void smpi_process_set_user_data(void *data){
for (const auto& l : links) {
XBT_INFO("%s: latency = %.5f, bandwidth = %f", l->get_cname(), l->get_latency(), l->get_bandwidth());
l->set_data(&user_data);
- xbt_assert(user_data == *static_cast<const std::string*>(l->get_data()), "User data was corrupted.");
+ xbt_assert(user_data == *l->get_data<std::string>(), "User data was corrupted.");
}
return 0;
{
XBT_INFO("*** GET/SET DATA for disk: %s ***", disk->get_cname());
- const std::string* data = static_cast<std::string*>(disk->get_data());
+ const std::string* data = disk->get_data<std::string>();
XBT_INFO("Get data: '%s'", data ? data->c_str() : "No User Data");
disk->set_data(new std::string("Some data"));
- data = static_cast<std::string*>(disk->get_data());
+ data = disk->get_data<std::string>();
XBT_INFO(" Set and get data: '%s'", data->c_str());
delete data;
}