SimGrid (3.23) NOT RELEASED (Release Target: June 21. 2019, 15:54 UTC)
+XBT:
+ - Drop xbt_dict_dump.
+
----------------------------------------------------------------------------
SimGrid (3.22) April 1. 2019
std::string tracing_category_ = "";
std::atomic_int_fast32_t refcount_{0};
/* FIXME: expose these elements in the API */
- int detached_ = 0;
+ bool detached_ = false;
int (*match_fun_)(void*, void*, kernel::activity::CommImpl*) = nullptr;
void (*clean_fun_)(void*) = nullptr;
void (*copy_data_function_)(kernel::activity::CommImpl*, void*, size_t) = nullptr;
int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
void (*clean_fun)(void*),
void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
- void* data, int detached);
+ void* data, bool detached);
XBT_PUBLIC void simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size,
int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
XBT_PUBLIC void xbt_dict_remove(xbt_dict_t dict, const char* key);
XBT_PUBLIC void xbt_dict_reset(xbt_dict_t dict);
XBT_PUBLIC int xbt_dict_length(xbt_dict_t dict);
-XBT_PUBLIC void xbt_dict_dump(xbt_dict_t dict, void (*output)(void*));
XBT_PUBLIC int xbt_dict_is_empty(xbt_dict_t dict);
/** @} */
/** Config Globals */
XBT_PUBLIC_DATA int _sg_cfg_init_status;
-XBT_PUBLIC_DATA bool _sg_cfg_exit_asap;
XBT_PUBLIC void sg_config_init(int* argc, char** argv);
XBT_PUBLIC void sg_config_finalize();
tracing_file << stream_.str() << std::endl;
}
-StateEvent::~StateEvent(){
- delete extra_;
-}
-
void StateEvent::print()
{
if (trace_format == simgrid::instr::TraceFormat::Paje) {
std::string filename = "(null)";
int linenumber = -1;
#endif
- TIData* extra_;
+ std::unique_ptr<TIData> extra_;
public:
StateEvent(Container* container, Type* type, e_event_type event_type, EntityValue* value, TIData* extra);
- ~StateEvent();
void print() override;
};
size_t src_buff_size, int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
void (*clean_fun)(void*), // used to free the synchro in case of problem after a detached send
void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), // used to copy data if not default one
- void* data, int detached)
+ void* data, bool detached)
{
XBT_DEBUG("send from mailbox %p", mbox);
}
if (detached) {
- other_comm->detached = true;
+ other_comm->detached_ = true;
other_comm->clean_fun = clean_fun;
} else {
other_comm->clean_fun = nullptr;
{
XBT_DEBUG("Copy the data over");
memcpy(comm->dst_buff_, buff, buff_size);
- if (comm->detached) { // if this is a detached send, the source buffer was duplicated by SMPI sender to make the
+ if (comm->detached_) { // if this is a detached send, the source buffer was duplicated by SMPI sender to make the
// original buffer available to the application ASAP
xbt_free(buff);
comm->src_buff_ = nullptr;
CommImpl::~CommImpl()
{
- XBT_DEBUG("Really free communication %p in state %d (detached = %d)", this, static_cast<int>(state_),
- static_cast<int>(detached));
+ XBT_DEBUG("Really free communication %p in state %d (detached = %d)", this, static_cast<int>(state_), detached_);
cleanupSurf();
- if (detached && state_ != SIMIX_DONE) {
+ if (detached_ && state_ != SIMIX_DONE) {
/* the communication has failed and was detached:
* we have to free the buffer */
if (clean_fun)
{
/* if the synchro is a waiting state means that it is still in a mbox so remove from it and delete it */
if (state_ == SIMIX_WAITING) {
- if (not detached) {
+ if (not detached_) {
mbox->remove(this);
state_ = SIMIX_CANCELED;
}
state_ = SIMIX_DONE;
XBT_DEBUG("SIMIX_post_comm: comm %p, state %d, src_proc %p, dst_proc %p, detached: %d", this, (int)state_,
- src_actor_.get(), dst_actor_.get(), detached);
+ src_actor_.get(), dst_actor_.get(), detached_);
/* destroy the surf actions associated with the Simix communication */
cleanupSurf();
"detached:%d",
this, src_actor_ ? src_actor_->get_host()->get_cname() : nullptr,
dst_actor_ ? dst_actor_->get_host()->get_cname() : nullptr, simcall->issuer->get_cname(),
- simcall->issuer, detached);
+ simcall->issuer, detached_);
if (src_actor_ == simcall->issuer) {
XBT_DEBUG("I'm source");
} else if (dst_actor_ == simcall->issuer) {
simcall->issuer->waiting_synchro = nullptr;
simcall->issuer->comms.remove(this);
- if (detached) {
+ if (detached_) {
if (simcall->issuer == src_actor_) {
if (dst_actor_)
dst_actor_->comms.remove(this);
(comm.mbox set to nullptr when the communication is removed from the mailbox
(used as garbage collector)) */
#endif
- bool detached = false; /* If detached or not */
+ bool detached_ = false; /* If detached or not */
void (*clean_fun)(void*) = nullptr; /* Function to clean the detached src_buf if something goes wrong */
int (*match_fun)(void*, void*, CommImpl*) = nullptr; /* Filter function used by the other side. It is used when
return true;
}
/* On the other hand if it hasn't a timeout, check if the comm is ready.*/
- else if (act->detached && act->src_actor_ == nullptr &&
+ else if (act->detached_ && act->src_actor_ == nullptr &&
act->type_ == simgrid::kernel::activity::CommImpl::Type::READY)
return (act->dst_actor_ != nullptr);
return (act->src_actor_ && act->dst_actor_);
if (act->src_actor_.get() && act->dst_actor_.get())
state->transition.argument = 0;
else if (act->src_actor_.get() == nullptr && act->type_ == simgrid::kernel::activity::CommImpl::Type::READY &&
- act->detached == 1)
+ act->detached_)
state->transition.argument = 0;
else
state->transition.argument = -1;
{
xbt_assert(sd_global == nullptr, "SD_init() already called");
- sd_global = new simgrid::sd::Global();
-
surf_init(argc, argv);
+ sd_global = new simgrid::sd::Global();
+
simgrid::config::set_default<std::string>("host/model", "ptask_L07");
if (simgrid::config::get_value<bool>("clean-atexit"))
atexit(SD_exit);
- if (_sg_cfg_exit_asap) {
- exit(0);
- }
}
/** @brief set a configuration variable
*/
int _sg_cfg_init_status = 0;
-/* instruct the upper layer (simix or simdag) to exit as soon as possible */
-bool _sg_cfg_exit_asap = false;
-
-#define sg_cfg_exit_early() \
- do { \
- _sg_cfg_exit_asap = true; \
- return; \
- } while (0)
-
/* Parse the command line, looking for options */
static void sg_config_cmd_line(int *argc, char **argv)
{
printf("\n");
model_help("network", surf_network_model_description);
printf("\nLong description of all optimization levels accepted by the models of this simulator:\n");
- for (int k = 0; surf_optimization_mode_description[k].name; k++)
- printf(" %s: %s\n",
- surf_optimization_mode_description[k].name,
- surf_optimization_mode_description[k].description);
+ for (auto const& item : surf_optimization_mode_description)
+ printf(" %s: %s\n", item.name, item.description);
printf("Both network and CPU models have 'Lazy' as default optimization level\n\n");
shall_exit = true;
} else if (parse_args && not strcmp(argv[i], "--help-tracing")) {
*argc = j;
}
if (shall_exit)
- sg_cfg_exit_early();
+ exit(0);
}
/* callback of the plugin variable */
return;
if (value == "help") {
- model_help("plugin", surf_plugin_description);
- sg_cfg_exit_early();
+ model_help("plugin", *surf_plugin_description);
+ exit(0);
}
- int plugin_id = find_model_description(surf_plugin_description, value);
- surf_plugin_description[plugin_id].model_init_preparse();
+ int plugin_id = find_model_description(*surf_plugin_description, value);
+ (*surf_plugin_description)[plugin_id].model_init_preparse();
}
/* callback of the host/model variable */
if (value == "help") {
model_help("host", surf_host_model_description);
- sg_cfg_exit_early();
+ exit(0);
}
/* Make sure that the model exists */
if (value == "help") {
model_help("CPU", surf_cpu_model_description);
- sg_cfg_exit_early();
+ exit(0);
}
/* New Module missing */
if (value == "help") {
model_help("optimization", surf_optimization_mode_description);
- sg_cfg_exit_early();
+ exit(0);
}
/* New Module missing */
if (value == "help") {
model_help("storage", surf_storage_model_description);
- sg_cfg_exit_early();
+ exit(0);
}
find_model_description(surf_storage_model_description, value);
if (value == "help") {
model_help("network", surf_network_model_description);
- sg_cfg_exit_early();
+ exit(0);
}
/* New Module missing */
}
/* build description line with possible values */
-static void describe_model(char *result,int resultsize,
- const s_surf_model_description_t model_description[],
- const char *name,
- const char *description)
+static void declare_model_flag(const std::string& name, const std::string& value,
+ const std::function<void(std::string const&)>& callback,
+ const std::vector<surf_model_description_t>& model_description, const std::string& type,
+ const std::string& descr)
{
- result[0] = '\0';
- char *p = result;
- p += snprintf(result,resultsize-1, "%s. Possible values: %s", description,
- model_description[0].name ? model_description[0].name : "n/a");
- for (int i = 1; model_description[i].name; i++)
- p += snprintf(p,resultsize-(p-result)-1, ", %s", model_description[i].name);
- p += snprintf(p,resultsize-(p-result)-1, ".\n (use 'help' as a value to see the long description of each %s)", name);
-
- xbt_assert(p<result+resultsize-1,"Buffer too small to display the model description of %s",name);
+ std::string description = descr + ". Possible values: ";
+ std::string sep = "";
+ for (auto const& item : model_description) {
+ description += sep + item.name;
+ sep = ", ";
+ }
+ description += ".\n (use 'help' as a value to see the long description of each " + type + ")";
+ simgrid::config::declare_flag<std::string>(name, description, value, callback);
}
/* create the config set, register what should be and parse the command line*/
void sg_config_init(int *argc, char **argv)
{
- const int descsize = 1024;
- char description[descsize];
-
/* Create the configuration support */
if (_sg_cfg_init_status != 0) { /* Only create stuff if not already inited */
XBT_WARN("Call to sg_config_init() after initialization ignored");
}
/* Plugins configuration */
- describe_model(description, descsize, surf_plugin_description, "plugin", "The plugins");
- simgrid::config::declare_flag<std::string>("plugin", description, "", &_sg_cfg_cb__plugin);
+ declare_model_flag("plugin", "", &_sg_cfg_cb__plugin, *surf_plugin_description, "plugin", "The plugins");
- describe_model(description, descsize, surf_cpu_model_description, "model", "The model to use for the CPU");
- simgrid::config::declare_flag<std::string>("cpu/model", description, "Cas01", &_sg_cfg_cb__cpu_model);
+ declare_model_flag("cpu/model", "Cas01", &_sg_cfg_cb__cpu_model, surf_cpu_model_description, "model",
+ "The model to use for the CPU");
- describe_model(description, descsize, surf_storage_model_description, "model", "The model to use for the storage");
- simgrid::config::declare_flag<std::string>("storage/model", description, "default", &_sg_cfg_cb__storage_mode);
+ declare_model_flag("storage/model", "default", &_sg_cfg_cb__storage_mode, surf_storage_model_description, "model",
+ "The model to use for the storage");
- describe_model(description, descsize, surf_network_model_description, "model", "The model to use for the network");
- simgrid::config::declare_flag<std::string>("network/model", description, "LV08", &_sg_cfg_cb__network_model);
+ declare_model_flag("network/model", "LV08", &_sg_cfg_cb__network_model, surf_network_model_description, "model",
+ "The model to use for the network");
- describe_model(description, descsize, surf_optimization_mode_description, "optimization mode",
- "The optimization modes to use for the network");
- simgrid::config::declare_flag<std::string>("network/optim", description, "Lazy", &_sg_cfg_cb__optimization_mode);
+ declare_model_flag("network/optim", "Lazy", &_sg_cfg_cb__optimization_mode, surf_optimization_mode_description,
+ "optimization mode", "The optimization modes to use for the network");
- describe_model(description, descsize, surf_host_model_description, "model", "The model to use for the host");
- simgrid::config::declare_flag<std::string>("host/model", description, "default", &_sg_cfg_cb__host_model);
+ declare_model_flag("host/model", "default", &_sg_cfg_cb__host_model, surf_host_model_description, "model",
+ "The model to use for the host");
simgrid::config::bind_flag(sg_surf_precision, "surf/precision",
"Numerical precision used when updating simulation times (in seconds)");
void sg_config_finalize()
{
- if (not _sg_cfg_init_status)
- return; /* Not initialized yet. Nothing to do */
-
simgrid::config::finalize();
_sg_cfg_init_status = 0;
}
int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
void (*clean_fun)(void*),
void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
- void* data, int detached)
+ void* data, bool detached)
{
/* checking for infinite values */
xbt_assert(std::isfinite(task_size), "task_size is not finite!");
{
return simgrid::simix::unmarshal_raw<simgrid::kernel::activity::ExecImpl*>(simcall->args[0]);
}
-static inline void simcall_execution_wait__set__execution(smx_simcall_t simcall,
- simgrid::kernel::activity::ExecImpl* arg)
+static inline void simcall_execution_wait__set__execution(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* arg)
{
simgrid::simix::marshal<simgrid::kernel::activity::ExecImpl*>(simcall->args[0], arg);
}
{
return simgrid::simix::unmarshal_raw<simgrid::kernel::activity::ExecImpl*>(simcall->args[0]);
}
-static inline void simcall_execution_test__set__execution(smx_simcall_t simcall,
- simgrid::kernel::activity::ExecImpl* arg)
+static inline void simcall_execution_test__set__execution(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* arg)
{
simgrid::simix::marshal<simgrid::kernel::activity::ExecImpl*>(simcall->args[0], arg);
}
{
simgrid::simix::marshal<void*>(simcall->args[9], arg);
}
-static inline int simcall_comm_isend__get__detached(smx_simcall_t simcall)
+static inline bool simcall_comm_isend__get__detached(smx_simcall_t simcall)
{
- return simgrid::simix::unmarshal<int>(simcall->args[10]);
+ return simgrid::simix::unmarshal<bool>(simcall->args[10]);
}
-static inline int simcall_comm_isend__getraw__detached(smx_simcall_t simcall)
+static inline bool simcall_comm_isend__getraw__detached(smx_simcall_t simcall)
{
- return simgrid::simix::unmarshal_raw<int>(simcall->args[10]);
+ return simgrid::simix::unmarshal_raw<bool>(simcall->args[10]);
}
-static inline void simcall_comm_isend__set__detached(smx_simcall_t simcall, int arg)
+static inline void simcall_comm_isend__set__detached(smx_simcall_t simcall, bool arg)
{
- simgrid::simix::marshal<int>(simcall->args[10], arg);
+ simgrid::simix::marshal<bool>(simcall->args[10], arg);
}
static inline boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_comm_isend__get__result(smx_simcall_t simcall)
{
XBT_PRIVATE void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* execution);
XBT_PRIVATE void simcall_HANDLER_execution_test(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* execution);
XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout);
-XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, int detached);
+XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, bool detached);
XBT_PRIVATE void simcall_HANDLER_comm_recv(smx_simcall_t simcall, smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout, double rate);
XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_HANDLER_comm_irecv(smx_simcall_t simcall, smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double rate);
-XBT_PRIVATE void simcall_HANDLER_comm_waitany(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl** comms,
- size_t count, double timeout);
-XBT_PRIVATE void simcall_HANDLER_comm_wait(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl* comm,
- double timeout);
+XBT_PRIVATE void simcall_HANDLER_comm_waitany(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl** comms, size_t count, double timeout);
+XBT_PRIVATE void simcall_HANDLER_comm_wait(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl* comm, double timeout);
XBT_PRIVATE void simcall_HANDLER_comm_test(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl* comm);
-XBT_PRIVATE void simcall_HANDLER_comm_testany(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl** comms,
- size_t count);
+XBT_PRIVATE void simcall_HANDLER_comm_testany(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl** comms, size_t count);
XBT_PRIVATE void simcall_HANDLER_mutex_lock(smx_simcall_t simcall, smx_mutex_t mutex);
XBT_PRIVATE int simcall_HANDLER_mutex_trylock(smx_simcall_t simcall, smx_mutex_t mutex);
XBT_PRIVATE void simcall_HANDLER_mutex_unlock(smx_simcall_t simcall, smx_mutex_t mutex);
return simcall<void, smx_actor_t, smx_mailbox_t, double, double, void*, size_t, simix_match_func_t, simix_copy_data_func_t, void*, double>(SIMCALL_COMM_SEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, copy_data_fun, data, timeout);
}
-inline static boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_BODY_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, int detached)
+inline static boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_BODY_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, bool detached)
{
if (0) /* Go to that function to follow the code flow through the simcall barrier */
simcall_HANDLER_comm_isend(&SIMIX_process_self()->simcall, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached);
- return simcall<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>, smx_actor_t, smx_mailbox_t, double, double, void*, size_t, simix_match_func_t, simix_clean_func_t, simix_copy_data_func_t, void*, int>(SIMCALL_COMM_ISEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached);
+ return simcall<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>, smx_actor_t, smx_mailbox_t, double, double, void*, size_t, simix_match_func_t, simix_clean_func_t, simix_copy_data_func_t, void*, bool>(SIMCALL_COMM_ISEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached);
}
inline static void simcall_BODY_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout, double rate)
{
if (0) /* Go to that function to follow the code flow through the simcall barrier */
simcall_HANDLER_comm_waitany(&SIMIX_process_self()->simcall, comms, count, timeout);
- return simcall<int, simgrid::kernel::activity::CommImpl**, size_t, double>(SIMCALL_COMM_WAITANY, comms, count,
- timeout);
+ return simcall<int, simgrid::kernel::activity::CommImpl**, size_t, double>(SIMCALL_COMM_WAITANY, comms, count, timeout);
}
inline static void simcall_BODY_comm_wait(simgrid::kernel::activity::CommImpl* comm, double timeout)
break;
case SIMCALL_EXECUTION_WAIT:
- simcall_HANDLER_execution_wait(simcall,
- simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl*>(simcall->args[0]));
+ simcall_HANDLER_execution_wait(simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl*>(simcall->args[0]));
break;
case SIMCALL_EXECUTION_TEST:
- simcall_HANDLER_execution_test(simcall,
- simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl*>(simcall->args[0]));
+ simcall_HANDLER_execution_test(simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl*>(simcall->args[0]));
break;
case SIMCALL_COMM_SEND:
break;
case SIMCALL_COMM_ISEND:
- simgrid::simix::marshal<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>>(simcall->result, simcall_HANDLER_comm_isend(simcall, simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]), simgrid::simix::unmarshal<smx_mailbox_t>(simcall->args[1]), simgrid::simix::unmarshal<double>(simcall->args[2]), simgrid::simix::unmarshal<double>(simcall->args[3]), simgrid::simix::unmarshal<void*>(simcall->args[4]), simgrid::simix::unmarshal<size_t>(simcall->args[5]), simgrid::simix::unmarshal<simix_match_func_t>(simcall->args[6]), simgrid::simix::unmarshal<simix_clean_func_t>(simcall->args[7]), simgrid::simix::unmarshal<simix_copy_data_func_t>(simcall->args[8]), simgrid::simix::unmarshal<void*>(simcall->args[9]), simgrid::simix::unmarshal<int>(simcall->args[10])));
+ simgrid::simix::marshal<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>>(simcall->result, simcall_HANDLER_comm_isend(simcall, simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]), simgrid::simix::unmarshal<smx_mailbox_t>(simcall->args[1]), simgrid::simix::unmarshal<double>(simcall->args[2]), simgrid::simix::unmarshal<double>(simcall->args[3]), simgrid::simix::unmarshal<void*>(simcall->args[4]), simgrid::simix::unmarshal<size_t>(simcall->args[5]), simgrid::simix::unmarshal<simix_match_func_t>(simcall->args[6]), simgrid::simix::unmarshal<simix_clean_func_t>(simcall->args[7]), simgrid::simix::unmarshal<simix_copy_data_func_t>(simcall->args[8]), simgrid::simix::unmarshal<void*>(simcall->args[9]), simgrid::simix::unmarshal<bool>(simcall->args[10])));
SIMIX_simcall_answer(simcall);
break;
break;
case SIMCALL_COMM_WAITANY:
- simcall_HANDLER_comm_waitany(
- simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl**>(simcall->args[0]),
- simgrid::simix::unmarshal<size_t>(simcall->args[1]), simgrid::simix::unmarshal<double>(simcall->args[2]));
+ simcall_HANDLER_comm_waitany(simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl**>(simcall->args[0]), simgrid::simix::unmarshal<size_t>(simcall->args[1]), simgrid::simix::unmarshal<double>(simcall->args[2]));
break;
case SIMCALL_COMM_WAIT:
- simcall_HANDLER_comm_wait(simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl*>(simcall->args[0]),
- simgrid::simix::unmarshal<double>(simcall->args[1]));
+ simcall_HANDLER_comm_wait(simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl*>(simcall->args[0]), simgrid::simix::unmarshal<double>(simcall->args[1]));
break;
case SIMCALL_COMM_TEST:
break;
case SIMCALL_COMM_TESTANY:
- simcall_HANDLER_comm_testany(simcall,
- simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl**>(simcall->args[0]),
- simgrid::simix::unmarshal<size_t>(simcall->args[1]));
+ simcall_HANDLER_comm_testany(simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl**>(simcall->args[0]), simgrid::simix::unmarshal<size_t>(simcall->args[1]));
break;
case SIMCALL_MUTEX_LOCK:
/* Pack all possible scalar types in an union */
union u_smx_scalar {
+ bool b;
char c;
short s;
int i;
inline T unmarshal_raw(type<T>, u_smx_scalar const& simcall) \
{ /* Exactly same as unmarshal. It differs only for intrusive_ptr */ return simcall.field; }
+SIMIX_MARSHAL(bool, b);
SIMIX_MARSHAL(char, c);
SIMIX_MARSHAL(short, s);
SIMIX_MARSHAL(int, i);
int execution_test(simgrid::kernel::activity::ExecImpl* execution) [[block]];
void comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout) [[block]];
-boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, int detached);
+boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, bool detached);
void comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout, double rate) [[block]];
boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double rate);
int comm_waitany(simgrid::kernel::activity::CommImpl** comms, size_t count, double timeout) [[block]];
#endif
if (simix_global == nullptr) {
+ surf_init(argc, argv); /* Initialize SURF structures */
+
simix_global.reset(new simgrid::simix::Global());
simix_global->maestro_process = nullptr;
-
- surf_init(argc, argv); /* Initialize SURF structures */
SIMIX_context_mod_init();
// Either create a new context with maestro or create
if (simgrid::config::get_value<bool>("clean-atexit"))
atexit(SIMIX_clean);
-
- if (_sg_cfg_exit_asap)
- exit(0);
}
int smx_cleaned = 0;
#define SMPI_COMM_HPP_INCLUDED
#include <list>
+#include <string>
#include "smpi_keyvals.hpp"
#include "smpi_group.hpp"
#include "smpi_topo.hpp"
// We can't override src, tag, and size, because the request may be reused later
int real_src_;
int real_tag_;
- int truncated_;
+ bool truncated_;
size_t real_size_;
MPI_Comm comm_;
smx_activity_t action_;
unsigned flags_;
- int detached_;
+ bool detached_;
MPI_Request detached_sender_;
int refcount_;
MPI_Op op_;
- int cancelled_;
+ int cancelled_; // tri-state
smpi_mpi_generalized_request_funcs generalized_funcs;
MPI_Request* nbc_requests_;
int nbc_requests_size_;
int dst() { return dst_; }
int tag() { return tag_; }
int flags() { return flags_; }
- int detached() { return detached_; }
+ bool detached() { return detached_; }
MPI_Datatype type() { return old_type_; }
void print_request(const char* message);
void start();
XBT_DEBUG("Copying %zu bytes from %p to %p", buff_size, tmpbuff, comm->dst_buff_);
memcpy_private(comm->dst_buff_, tmpbuff, private_blocks);
- if (comm->detached) {
+ if (comm->detached_) {
// if this is a detached send, the source buffer was duplicated by SMPI
// sender to make the original buffer available to the application ASAP
xbt_free(buff);
if(op != MPI_REPLACE && op != MPI_OP_NULL)
op_->ref();
action_ = nullptr;
- detached_ = 0;
+ detached_ = false;
detached_sender_ = nullptr;
real_src_ = 0;
- truncated_ = 0;
+ truncated_ = false;
real_size_ = 0;
real_tag_ = 0;
if (flags & MPI_REQ_PERSISTENT)
if(ref->tag_ == MPI_ANY_TAG)
ref->real_tag_ = req->tag_;
if(ref->real_size_ < req->real_size_)
- ref->truncated_ = 1;
- if(req->detached_==1)
+ ref->truncated_ = true;
+ if (req->detached_)
ref->detached_sender_=req; //tie the sender to the receiver, as it is detached and has to be freed in the receiver
if(req->cancelled_==0)
req->cancelled_=-1;//mark as uncancellable
if(req->tag_ == MPI_ANY_TAG)
req->real_tag_ = ref->tag_;
if(req->real_size_ < ref->real_size_)
- req->truncated_ = 1;
- if(ref->detached_==1)
+ req->truncated_ = true;
+ if (ref->detached_)
req->detached_sender_=ref; //tie the sender to the receiver, as it is detached and has to be freed in the receiver
if(req->cancelled_==0)
req->cancelled_=-1;//mark as uncancellable
((flags_ & MPI_REQ_RMA) != 0 ||
static_cast<int>(size_) < simgrid::config::get_value<int>("smpi/send-is-detached-thresh"))) {
void *oldbuf = nullptr;
- detached_ = 1;
+ detached_ = true;
XBT_DEBUG("Send request %p is detached", this);
this->ref();
if (not(old_type_->flags() & DT_FLAG_DERIVED)) {
//if we are giving back the control to the user without waiting for completion, we have to inject timings
double sleeptime = 0.0;
- if (detached_ != 0 || ((flags_ & (MPI_REQ_ISEND | MPI_REQ_SSEND)) != 0)) { // issend should be treated as isend
+ if (detached_ || ((flags_ & (MPI_REQ_ISEND | MPI_REQ_SSEND)) != 0)) { // issend should be treated as isend
// isend and send timings may be different
sleeptime = ((flags_ & MPI_REQ_ISEND) != 0)
? simgrid::s4u::Actor::self()->get_host()->extension<simgrid::smpi::Host>()->oisend(size_)
return;
}
- if (not((req->detached_ != 0) && ((req->flags_ & MPI_REQ_SEND) != 0))
- && ((req->flags_ & MPI_REQ_PREPARED) == 0)
- && ((req->flags_ & MPI_REQ_GENERALIZED) == 0)) {
+ if (not(req->detached_ && ((req->flags_ & MPI_REQ_SEND) != 0)) && ((req->flags_ & MPI_REQ_PREPARED) == 0) &&
+ ((req->flags_ & MPI_REQ_GENERALIZED) == 0)) {
if(status != MPI_STATUS_IGNORE) {
int src = req->src_ == MPI_ANY_SOURCE ? req->real_src_ : req->src_;
status->MPI_SOURCE = req->comm_->group()->rank(src);
status->MPI_TAG = req->tag_ == MPI_ANY_TAG ? req->real_tag_ : req->tag_;
- status->MPI_ERROR = req->truncated_ != 0 ? MPI_ERR_TRUNCATE : MPI_SUCCESS;
+ status->MPI_ERROR = req->truncated_ ? MPI_ERR_TRUNCATE : MPI_SUCCESS;
// this handles the case were size in receive differs from size in send
status->count = req->real_size_;
}
indices[count] = index;
count++;
for (int i = 0; i < incount; i++) {
- if((requests[i] != MPI_REQUEST_NULL)) {
+ if (requests[i] != MPI_REQUEST_NULL) {
test(&requests[i], pstat,&flag);
if (flag==1){
indices[count] = i;
std::set<std::string> watched_hosts;
extern std::map<std::string, simgrid::kernel::resource::StorageType*> storage_types;
-s_surf_model_description_t* surf_plugin_description = nullptr;
-XBT_PUBLIC void simgrid_add_plugin_description(const char* name, const char* description, void_f_void_t init_fun)
-{
- static int plugin_amount = 0;
-
- /* no need to check for plugin name conflict: the compiler already ensures that the generated
- * simgrid_##id##_plugin_register() is unique */
+std::vector<surf_model_description_t>* surf_plugin_description = nullptr;
- plugin_amount++;
- surf_plugin_description = static_cast<s_surf_model_description_t*>(
- xbt_realloc(surf_plugin_description, sizeof(s_surf_model_description_t) * (plugin_amount + 2)));
+static void XBT_ATTRIB_DESTRUCTOR(800) simgrid_free_plugin_description()
+{
+ delete surf_plugin_description;
+ surf_plugin_description = nullptr;
+}
- surf_plugin_description[plugin_amount - 1] = {name, description, init_fun};
- surf_plugin_description[plugin_amount] = {nullptr, nullptr, nullptr}; // this array must be null terminated
+XBT_PUBLIC void simgrid_add_plugin_description(const char* name, const char* description, void_f_void_t init_fun)
+{
+ if (not surf_plugin_description)
+ surf_plugin_description = new std::vector<surf_model_description_t>;
+ surf_plugin_description->emplace_back(surf_model_description_t{name, description, init_fun});
}
/* Don't forget to update the option description in smx_config when you change this */
-s_surf_model_description_t surf_network_model_description[] = {
+const std::vector<surf_model_description_t> surf_network_model_description = {
{"LV08", "Realistic network analytic model (slow-start modeled by multiplying latency by 13.01, bandwidth by .97; "
"bottleneck sharing uses a payload of S=20537 for evaluating RTT). ",
&surf_network_model_init_LegrandVelho},
{"Vegas",
"Model from Steven H. Low using lagrange_solve instead of lmm_solve (experts only; check the code for more info).",
&surf_network_model_init_Vegas},
- {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
};
#if ! HAVE_SMPI
}
#endif
-s_surf_model_description_t surf_cpu_model_description[] = {
- {"Cas01", "Simplistic CPU model (time=size/power).", &surf_cpu_model_init_Cas01},
- {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
+const std::vector<surf_model_description_t> surf_cpu_model_description = {
+ {"Cas01", "Simplistic CPU model (time=size/power).", &surf_cpu_model_init_Cas01},
};
-s_surf_model_description_t surf_host_model_description[] = {
- {"default", "Default host model. Currently, CPU:Cas01 and network:LV08 (with cross traffic enabled)", &surf_host_model_init_current_default},
- {"compound", "Host model that is automatically chosen if you change the network and CPU models", &surf_host_model_init_compound},
- {"ptask_L07", "Host model somehow similar to Cas01+CM02 but allowing parallel tasks", &surf_host_model_init_ptask_L07},
- {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
+const std::vector<surf_model_description_t> surf_host_model_description = {
+ {"default", "Default host model. Currently, CPU:Cas01 and network:LV08 (with cross traffic enabled)",
+ &surf_host_model_init_current_default},
+ {"compound", "Host model that is automatically chosen if you change the network and CPU models",
+ &surf_host_model_init_compound},
+ {"ptask_L07", "Host model somehow similar to Cas01+CM02 but allowing parallel tasks",
+ &surf_host_model_init_ptask_L07},
};
-s_surf_model_description_t surf_optimization_mode_description[] = {
- {"Lazy", "Lazy action management (partial invalidation in lmm + heap in action remaining).", nullptr},
- {"TI", "Trace integration. Highly optimized mode when using availability traces (only available for the Cas01 CPU model for now).", nullptr},
- {"Full", "Full update of remaining and variables. Slow but may be useful when debugging.", nullptr},
- {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
+const std::vector<surf_model_description_t> surf_optimization_mode_description = {
+ {"Lazy", "Lazy action management (partial invalidation in lmm + heap in action remaining).", nullptr},
+ {"TI", "Trace integration. Highly optimized mode when using availability traces (only available for the Cas01 CPU "
+ "model for now).",
+ nullptr},
+ {"Full", "Full update of remaining and variables. Slow but may be useful when debugging.", nullptr},
};
-s_surf_model_description_t surf_storage_model_description[] = {
- {"default", "Simplistic storage model.", &surf_storage_model_init_default},
- {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
+const std::vector<surf_model_description_t> surf_storage_model_description = {
+ {"default", "Simplistic storage model.", &surf_storage_model_init_default},
};
double NOW = 0;
}
/** Displays the long description of all registered models, and quit */
-void model_help(const char *category, s_surf_model_description_t * table)
+void model_help(const char* category, const std::vector<surf_model_description_t>& table)
{
printf("Long description of the %s models accepted by this simulator:\n", category);
- for (int i = 0; table[i].name; i++)
- printf(" %s: %s\n", table[i].name, table[i].description);
+ for (auto const& item : table)
+ printf(" %s: %s\n", item.name, item.description);
}
-int find_model_description(s_surf_model_description_t* table, const std::string& name)
+int find_model_description(const std::vector<surf_model_description_t>& table, const std::string& name)
{
- for (int i = 0; table[i].name; i++)
- if (name == table[i].name)
- return i;
+ auto pos = std::find_if(table.begin(), table.end(),
+ [&name](const surf_model_description_t& item) { return item.name == name; });
+ if (pos != table.end())
+ return std::distance(table.begin(), pos);
- if (not table[0].name)
+ if (table.empty())
xbt_die("No model is valid! This is a bug.");
- std::string name_list = std::string(table[0].name);
- for (int i = 1; table[i].name; i++)
- name_list = name_list + ", " + table[i].name;
+ std::string sep;
+ std::string name_list;
+ for (auto const& item : table) {
+ name_list += sep + item.name;
+ sep = ", ";
+ }
xbt_die("Model '%s' is invalid! Valid models are: %s.", name.c_str(), name_list.c_str());
return -1;
for (auto const& model : all_existing_models)
delete model;
- xbt_free(surf_plugin_description);
-
tmgr_finalize();
sg_platf_exit();
* Model Descriptions
* -------------------- */
/** @brief Resource model description */
-struct surf_model_description {
+struct surf_model_description_t {
const char* name;
const char* description;
void_f_void_t model_init_preparse;
};
-typedef struct surf_model_description s_surf_model_description_t;
-XBT_PUBLIC int find_model_description(s_surf_model_description_t* table, const std::string& name);
-XBT_PUBLIC void model_help(const char* category, s_surf_model_description_t* table);
+XBT_PUBLIC int find_model_description(const std::vector<surf_model_description_t>& table, const std::string& name);
+XBT_PUBLIC void model_help(const char* category, const std::vector<surf_model_description_t>& table);
-#define SIMGRID_REGISTER_PLUGIN(id, desc, init) \
- void simgrid_##id##_plugin_register(); \
- void XBT_ATTRIB_CONSTRUCTOR(800) simgrid_##id##_plugin_register() { \
- simgrid_add_plugin_description(#id, desc, init); \
+#define SIMGRID_REGISTER_PLUGIN(id, desc, init) \
+ static void XBT_ATTRIB_CONSTRUCTOR(800) simgrid_##id##_plugin_register() \
+ { \
+ simgrid_add_plugin_description(#id, desc, init); \
}
XBT_PUBLIC void simgrid_add_plugin_description(const char* name, const char* description, void_f_void_t init_fun);
/** @brief The list of all available plugins */
-XBT_PUBLIC_DATA s_surf_model_description_t* surf_plugin_description;
+XBT_PUBLIC_DATA std::vector<surf_model_description_t>* surf_plugin_description;
/** @brief The list of all available optimization modes (both for cpu and networks).
* These optimization modes can be set using --cfg=cpu/optim:... and --cfg=network/optim:... */
-XBT_PUBLIC_DATA s_surf_model_description_t surf_optimization_mode_description[];
+XBT_PUBLIC_DATA const std::vector<surf_model_description_t> surf_optimization_mode_description;
/** @brief The list of all cpu models (pick one with --cfg=cpu/model) */
-XBT_PUBLIC_DATA s_surf_model_description_t surf_cpu_model_description[];
+XBT_PUBLIC_DATA const std::vector<surf_model_description_t> surf_cpu_model_description;
/** @brief The list of all network models (pick one with --cfg=network/model) */
-XBT_PUBLIC_DATA s_surf_model_description_t surf_network_model_description[];
+XBT_PUBLIC_DATA const std::vector<surf_model_description_t> surf_network_model_description;
/** @brief The list of all storage models (pick one with --cfg=storage/model) */
-XBT_PUBLIC_DATA s_surf_model_description_t surf_storage_model_description[];
+XBT_PUBLIC_DATA const std::vector<surf_model_description_t> surf_storage_model_description;
/** @brief The list of all host models (pick one with --cfg=host/model:) */
-XBT_PUBLIC_DATA s_surf_model_description_t surf_host_model_description[];
+XBT_PUBLIC_DATA const std::vector<surf_model_description_t> surf_host_model_description;
/**********
* Action *
return not dict || (xbt_dict_length(dict) == 0);
}
-/**
- * @brief Outputs the content of the structure (debugging purpose)
- *
- * @param dict the exibitionist
- * @param output a function to dump each data in the tree
- *
- * Outputs the content of the structure. (for debugging purpose).
- * @a output is a function to output the data. If nullptr, data won't be displayed.
- */
-void xbt_dict_dump(xbt_dict_t dict, void_f_pvoid_t output)
-{
- xbt_dictelm_t element;
- printf("Dict %p:\n", dict);
- if (dict != nullptr) {
- for (int i = 0; i < dict->table_size; i++) {
- element = dict->table[i];
- if (element) {
- printf("[\n");
- while (element != nullptr) {
- printf(" %s -> '", element->key);
- if (output != nullptr) {
- output(element->content);
- }
- printf("'\n");
- element = element->next;
- }
- printf("]\n");
- } else {
- printf("[]\n");
- }
- }
- }
-}
-
/**
* Create the dict mallocators.
* This is an internal XBT function called during the lib initialization.
endforeach()
# test for code coverage
-foreach(x version help help-logs help-log-categories help-aliases help-models help-tracing)
- ADD_TEST(test-${x} ${CMAKE_BINARY_DIR}/teshsuite/simdag/basic-parsing-test/basic-parsing-test --${x})
-endforeach()
+ADD_TEST(test-help-version ${TESH_WRAPPER_UNBOXED} ${CMAKE_BINARY_DIR}/teshsuite/simdag/basic-parsing-test/basic-parsing-test
+ --version --help --help-aliases --help-models --help-tracing)
+ADD_TEST(test-help-logs ${TESH_WRAPPER_UNBOXED} ${CMAKE_BINARY_DIR}/teshsuite/simdag/basic-parsing-test/basic-parsing-test
+ --help-logs --help-log-categories)
ADD_TESH(tesh-simdag-parser-bypass --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simdag/basic-parsing-test --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/basic-parsing-test --setenv srcdir=${CMAKE_HOME_DIRECTORY} basic-parsing-test-bypass.tesh)
ADD_TESH(tesh-simdag-parser-sym-full --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simdag/basic-parsing-test --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/basic-parsing-test basic-parsing-test-sym-full.tesh)
> [ 0.000000] [0:maestro@] false alarm!
$ rm -f ${bindir:=.}/log_usage.log ${bindir:=.}/log_usage_0.log ${bindir:=.}/log_usage_1.log
-
-# Would be nice for code coverage, but the early exit leads to lots of memory leaks
-#! output ignore
-#$ $SG_TEST_EXENV ${bindir:=.}/log_usage --help-logs --help-log-categories
message(STATUS "Error: Command valgrind not found --> enable_memcheck autoset to false.")
endif()
ENDIF()
+SET(TESH_WRAPPER_UNBOXED "${TESH_WRAPPER}")
+SEPARATE_ARGUMENTS(TESH_WRAPPER_UNBOXED)
#some tests may take forever on non futexes systems, using busy_wait with n cores < n workers
# default to posix for these tests if futexes are not supported