namespace simgrid {
namespace kernel {
namespace activity {
-class ActivityImpl;
- }
- namespace routing {
- class NetPoint;
- }
- }
- namespace simix {
- class Host;
- }
- namespace surf {
- class Resource;
- class Cpu;
- class LinkImpl;
- class HostImpl;
- class StorageImpl;
- }
- namespace trace_mgr {
- class trace;
- class future_evt_set;
- }
+ class ActivityImpl;
+ XBT_PUBLIC(void) intrusive_ptr_add_ref(ActivityImpl* activity);
+ XBT_PUBLIC(void) intrusive_ptr_release(ActivityImpl* activity);
+}
+namespace routing {
+ class NetPoint;
+}
+}
+namespace simix {
+ class Host;
+}
+namespace surf {
+ class Resource;
+ class Cpu;
+ class LinkImpl;
+ class HostImpl;
+ class StorageImpl;
+}
+namespace trace_mgr {
+ class trace;
+ class future_evt_set;
+}
}
typedef simgrid::s4u::Actor s4u_Actor;
typedef simgrid::s4u::Host s4u_Host;
typedef simgrid::s4u::Link s4u_Link;
typedef simgrid::s4u::NetZone s4u_NetZone;
-typedef simgrid::kernel::activity::ActivityImpl kernel_Activity;
+typedef simgrid::kernel::activity::ActivityImpl* smx_activity_t;
typedef simgrid::kernel::routing::NetPoint routing_NetPoint;
typedef simgrid::surf::Resource surf_Resource;
typedef simgrid::trace_mgr::trace tmgr_Trace;
typedef struct s4u_Host s4u_Host;
typedef struct s4u_Link s4u_Link;
typedef struct s4u_NetZone s4u_NetZone;
-typedef struct kernel_Activity kernel_Activity;
+typedef struct kernel_Activity* smx_activity_t;
typedef struct routing_NetPoint routing_NetPoint;
typedef struct surf_Resource surf_Resource;
typedef struct Trace tmgr_Trace;
typedef s4u_Host* sg_host_t;
typedef s4u_Link* sg_link_t;
-typedef kernel_Activity *smx_activity_t;
typedef routing_NetPoint* sg_netpoint_t;
typedef surf_Resource *sg_resource_t;
-/* Copyright (c) 2007-2016. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/kernel/activity/ActivityImpl.hpp"
-simgrid::kernel::activity::ActivityImpl::ActivityImpl() = default;
-simgrid::kernel::activity::ActivityImpl::~ActivityImpl() = default;
+namespace simgrid {
+namespace kernel {
+namespace activity {
-void simgrid::kernel::activity::ActivityImpl::ref()
+ActivityImpl::ActivityImpl() = default;
+ActivityImpl::~ActivityImpl() = default;
+
+void ActivityImpl::ref()
{
// Atomic operation! Do not split in two instructions!
xbt_assert(refcount_ != 0);
refcount_++;
}
-void simgrid::kernel::activity::ActivityImpl::unref()
+void ActivityImpl::unref()
{
xbt_assert(refcount_ > 0,
"This activity has a negative refcount! You can only call test() or wait() once per activity.");
if (refcount_ == 0)
delete this;
}
+
+// boost::intrusive_ptr<Activity> support:
+void intrusive_ptr_add_ref(simgrid::kernel::activity::ActivityImpl* activity)
+{
+ activity->ref();
+}
+
+void intrusive_ptr_release(simgrid::kernel::activity::ActivityImpl* activity)
+{
+ activity->unref();
+}
+}
+}
+} // namespace simgrid::kernel::activity::
-/* Copyright (c) 2007-2016. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
virtual void resume()=0;
virtual void post() =0; // What to do when a simcall terminates
- // boost::intrusive_ptr<Activity> support:
- friend void intrusive_ptr_add_ref(ActivityImpl * activity)
- {
- activity->ref();
- }
-
- friend void intrusive_ptr_release(ActivityImpl * activity)
- {
- activity->unref();
- }
-
/** @brief Increases the refcount */
void ref();
/** @brief Reduces the refcount */
void unref();
+
+ // boost::intrusive_ptr<Activity> support:
+ friend void intrusive_ptr_add_ref(ActivityImpl * activity);
+ friend void intrusive_ptr_release(ActivityImpl * activity);
+
private:
std::atomic_int_fast32_t refcount_{1};
};
/* Get an enabled actor and insert it in the interleave set of the initial state */
for (auto& actor : mc_model_checker->process().actors())
if (simgrid::mc::actor_is_enabled(actor.copy.getBuffer()))
- initial_state->interleave(actor.copy.getBuffer());
+ initial_state->addInterleavingSet(actor.copy.getBuffer());
stack_.push_back(std::move(initial_state));
}
/* Get enabled actors and insert them in the interleave set of the next state */
for (auto& actor : mc_model_checker->process().actors())
if (simgrid::mc::actor_is_enabled(actor.copy.getBuffer()))
- next_state->interleave(actor.copy.getBuffer());
+ next_state->addInterleavingSet(actor.copy.getBuffer());
if (dot_output != nullptr)
fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n",
/* Get enabled actors and insert them in the interleave set of the next graph_state */
for (auto& actor : mc_model_checker->process().actors())
if (simgrid::mc::actor_is_enabled(actor.copy.getBuffer()))
- next_pair->graph_state->interleave(actor.copy.getBuffer());
+ next_pair->graph_state->addInterleavingSet(actor.copy.getBuffer());
next_pair->requests = next_pair->graph_state->interleaveSize();
/* FIXME : get search_cycle value for each accepting state */
if (next_pair->automaton_state->type == 1 || (current_pair && current_pair->search_cycle))
if (visitedState_ == nullptr) {
/* Get an enabled process and insert it in the interleave set of the next state */
- for (auto& actor : mc_model_checker->process().actors())
- if (simgrid::mc::actor_is_enabled(actor.copy.getBuffer())) {
- next_state->interleave(actor.copy.getBuffer());
+ for (auto& remoteActor : mc_model_checker->process().actors()) {
+ auto actor = remoteActor.copy.getBuffer();
+ if (simgrid::mc::actor_is_enabled(actor)) {
+ next_state->addInterleavingSet(actor);
if (reductionMode_ == simgrid::mc::ReductionMode::dpor)
- break;
+ break; // With DPOR, we take the first enabled transition
}
+ }
if (dot_output != nullptr)
std::fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n",
}
if (not prev_state->actorStates[issuer->pid].isDone())
- prev_state->interleave(issuer);
+ prev_state->addInterleavingSet(issuer);
else
XBT_DEBUG("Process %p is in done set", req->issuer);
/* Get an enabled actor and insert it in the interleave set of the initial state */
for (auto& actor : mc_model_checker->process().actors())
if (simgrid::mc::actor_is_enabled(actor.copy.getBuffer())) {
- initial_state->interleave(actor.copy.getBuffer());
+ initial_state->addInterleavingSet(actor.copy.getBuffer());
if (reductionMode_ != simgrid::mc::ReductionMode::none)
break;
}
State(unsigned long state_number);
std::size_t interleaveSize() const;
- void interleave(smx_actor_t actor) {
- this->actorStates[actor->pid].consider();
- }
+ void addInterleavingSet(smx_actor_t actor) { this->actorStates[actor->pid].consider(); }
Transition getTransition() const;
};
char description[descsize];
/* Create the configuration support */
- if (_sg_cfg_init_status == 0) { /* Only create stuff if not already inited */
+ if (_sg_cfg_init_status != 0) { /* Only create stuff if not already inited */
+ XBT_WARN("Call to sg_config_init() after initialization ignored");
+ return;
+ }
- /* Plugins configuration */
- describe_model(description,descsize, surf_plugin_description, "plugin", "The plugins");
- xbt_cfg_register_string("plugin", nullptr, &_sg_cfg_cb__plugin, description);
+ /* Plugins configuration */
+ describe_model(description, descsize, surf_plugin_description, "plugin", "The plugins");
+ xbt_cfg_register_string("plugin", nullptr, &_sg_cfg_cb__plugin, description);
- describe_model(description,descsize, surf_cpu_model_description, "model", "The model to use for the CPU");
- xbt_cfg_register_string("cpu/model", "Cas01", &_sg_cfg_cb__cpu_model, description);
+ describe_model(description, descsize, surf_cpu_model_description, "model", "The model to use for the CPU");
+ xbt_cfg_register_string("cpu/model", "Cas01", &_sg_cfg_cb__cpu_model, description);
- describe_model(description,descsize, surf_optimization_mode_description, "optimization mode", "The optimization modes to use for the CPU");
- xbt_cfg_register_string("cpu/optim", "Lazy", &_sg_cfg_cb__optimization_mode, description);
+ describe_model(description, descsize, surf_optimization_mode_description, "optimization mode",
+ "The optimization modes to use for the CPU");
+ xbt_cfg_register_string("cpu/optim", "Lazy", &_sg_cfg_cb__optimization_mode, description);
- describe_model(description,descsize, surf_storage_model_description, "model", "The model to use for the storage");
- xbt_cfg_register_string("storage/model", "default", &_sg_cfg_cb__storage_mode, description);
+ describe_model(description, descsize, surf_storage_model_description, "model", "The model to use for the storage");
+ xbt_cfg_register_string("storage/model", "default", &_sg_cfg_cb__storage_mode, description);
- describe_model(description,descsize, surf_network_model_description, "model", "The model to use for the network");
- xbt_cfg_register_string("network/model", "LV08", &_sg_cfg_cb__network_model, description);
+ describe_model(description, descsize, surf_network_model_description, "model", "The model to use for the network");
+ xbt_cfg_register_string("network/model", "LV08", &_sg_cfg_cb__network_model, description);
- describe_model(description,descsize, surf_optimization_mode_description, "optimization mode", "The optimization modes to use for the network");
- xbt_cfg_register_string("network/optim", "Lazy", &_sg_cfg_cb__optimization_mode, description);
+ describe_model(description, descsize, surf_optimization_mode_description, "optimization mode",
+ "The optimization modes to use for the network");
+ xbt_cfg_register_string("network/optim", "Lazy", &_sg_cfg_cb__optimization_mode, description);
- describe_model(description,descsize, surf_host_model_description, "model", "The model to use for the host");
- xbt_cfg_register_string("host/model", "default", &_sg_cfg_cb__host_model, description);
+ describe_model(description, descsize, surf_host_model_description, "model", "The model to use for the host");
+ xbt_cfg_register_string("host/model", "default", &_sg_cfg_cb__host_model, description);
- sg_tcp_gamma = 4194304.0;
- simgrid::config::bindFlag(sg_tcp_gamma, { "network/TCP-gamma", "network/TCP_gamma" },
- "Size of the biggest TCP window (cat /proc/sys/net/ipv4/tcp_[rw]mem for recv/send window; Use the last given value, which is the max window size)");
+ sg_tcp_gamma = 4194304.0;
+ simgrid::config::bindFlag(sg_tcp_gamma, {"network/TCP-gamma", "network/TCP_gamma"},
+ "Size of the biggest TCP window (cat /proc/sys/net/ipv4/tcp_[rw]mem for recv/send window; "
+ "Use the last given value, which is the max window size)");
- simgrid::config::bindFlag(sg_surf_precision, "surf/precision",
- "Numerical precision used when updating simulation times (in seconds)");
+ simgrid::config::bindFlag(sg_surf_precision, "surf/precision",
+ "Numerical precision used when updating simulation times (in seconds)");
- simgrid::config::bindFlag(sg_maxmin_precision, "maxmin/precision",
- "Numerical precision used when computing resource sharing (in flops/sec or bytes/sec)");
+ simgrid::config::bindFlag(sg_maxmin_precision, "maxmin/precision",
+ "Numerical precision used when computing resource sharing (in flops/sec or bytes/sec)");
- simgrid::config::bindFlag(sg_concurrency_limit, "maxmin/concurrency-limit",
- "Maximum number of concurrent variables in the maxmim system. Also limits the number of "
- "processes on each host, at higher level. (default: -1 means no such limitation)");
- xbt_cfg_register_alias("maxmin/concurrency-limit", "maxmin/concurrency_limit");
+ simgrid::config::bindFlag(sg_concurrency_limit, "maxmin/concurrency-limit",
+ "Maximum number of concurrent variables in the maxmim system. Also limits the number of "
+ "processes on each host, at higher level. (default: -1 means no such limitation)");
+ xbt_cfg_register_alias("maxmin/concurrency-limit", "maxmin/concurrency_limit");
- /* The parameters of network models */
+ /* The parameters of network models */
- // real default for "network/sender-gap" is set in network_smpi.cpp:
- sg_sender_gap = NAN;
- simgrid::config::bindFlag(sg_sender_gap, { "network/sender-gap", "network/sender_gap" },
- "Minimum gap between two overlapping sends");
+ // real default for "network/sender-gap" is set in network_smpi.cpp:
+ sg_sender_gap = NAN;
+ simgrid::config::bindFlag(sg_sender_gap, {"network/sender-gap", "network/sender_gap"},
+ "Minimum gap between two overlapping sends");
- sg_latency_factor = 1.0;
- simgrid::config::bindFlag(sg_latency_factor, { "network/latency-factor", "network/latency_factor" },
- "Correction factor to apply to the provided latency (default value set by network model)");
+ sg_latency_factor = 1.0;
+ simgrid::config::bindFlag(sg_latency_factor, {"network/latency-factor", "network/latency_factor"},
+ "Correction factor to apply to the provided latency (default value set by network model)");
- sg_bandwidth_factor = 1.0;
- simgrid::config::bindFlag(sg_bandwidth_factor, { "network/bandwidth-factor", "network/bandwidth_factor" },
+ sg_bandwidth_factor = 1.0;
+ simgrid::config::bindFlag(
+ sg_bandwidth_factor, {"network/bandwidth-factor", "network/bandwidth_factor"},
"Correction factor to apply to the provided bandwidth (default value set by network model)");
- // real default for "network/weight-S" is set in network_*.cpp:
- sg_weight_S_parameter = NAN;
- simgrid::config::bindFlag(sg_weight_S_parameter, { "network/weight-S", "network/weight_S" },
+ // real default for "network/weight-S" is set in network_*.cpp:
+ sg_weight_S_parameter = NAN;
+ simgrid::config::bindFlag(
+ sg_weight_S_parameter, {"network/weight-S", "network/weight_S"},
"Correction factor to apply to the weight of competing streams (default value set by network model)");
- /* Inclusion path */
- simgrid::config::declareFlag<std::string>("path",
- "Lookup path for inclusions in platform and deployment XML files",
- "",
- [](std::string const& path) {
- if (path[0] != '\0') {
- surf_path.push_back(path);
- }
- });
-
- xbt_cfg_register_boolean("cpu/maxmin-selective-update", "no", nullptr,
- "Update the constraint set propagating recursively to others constraints (off by default when optim is set to lazy)");
- xbt_cfg_register_alias("cpu/maxmin-selective-update","cpu/maxmin_selective_update");
- xbt_cfg_register_boolean("network/maxmin-selective-update", "no", nullptr,
- "Update the constraint set propagating recursively to others constraints (off by default when optim is set to lazy)");
- xbt_cfg_register_alias("network/maxmin-selective-update","network/maxmin_selective_update");
- /* Replay (this part is enabled even if MC it disabled) */
- xbt_cfg_register_string("model-check/replay", nullptr, _sg_cfg_cb_model_check_replay,
- "Model-check path to replay (as reported by SimGrid when a violation is reported)");
+ /* Inclusion path */
+ simgrid::config::declareFlag<std::string>("path", "Lookup path for inclusions in platform and deployment XML files",
+ "", [](std::string const& path) {
+ if (path[0] != '\0') {
+ surf_path.push_back(path);
+ }
+ });
+
+ xbt_cfg_register_boolean("cpu/maxmin-selective-update", "no", nullptr, "Update the constraint set propagating "
+ "recursively to others constraints (off by "
+ "default when optim is set to lazy)");
+ xbt_cfg_register_alias("cpu/maxmin-selective-update", "cpu/maxmin_selective_update");
+ xbt_cfg_register_boolean("network/maxmin-selective-update", "no", nullptr, "Update the constraint set propagating "
+ "recursively to others constraints (off "
+ "by default when optim is set to lazy)");
+ xbt_cfg_register_alias("network/maxmin-selective-update", "network/maxmin_selective_update");
+ /* Replay (this part is enabled even if MC it disabled) */
+ xbt_cfg_register_string("model-check/replay", nullptr, _sg_cfg_cb_model_check_replay,
+ "Model-check path to replay (as reported by SimGrid when a violation is reported)");
#if SIMGRID_HAVE_MC
/* do model-checking-record */
sg_config_cmd_line(argc, argv);
xbt_mallocator_initialization_is_done(SIMIX_context_is_parallel());
- } else {
- XBT_WARN("Call to sg_config_init() after initialization ignored");
- }
}
void sg_config_finalize()
#include <xbt/base.h>
#include <simgrid/simix.h>
+#include <src/kernel/activity/ActivityImpl.hpp>
+#include <src/kernel/activity/CommImpl.hpp>
+
+#include <boost/intrusive_ptr.hpp>
+
SG_BEGIN_DECL()
/********************************* Simcalls *********************************/
return static_cast<T*>(simcall.dp);
}
+template <class T>
+inline void marshal(type<boost::intrusive_ptr<T>>, u_smx_scalar& simcall, boost::intrusive_ptr<T> value)
+{
+ intrusive_ptr_add_ref(&*value);
+ simcall.dp = static_cast<void*>(&*value);
+}
+template <class T> inline boost::intrusive_ptr<T> unmarshal(type<boost::intrusive_ptr<T>>, u_smx_scalar const& simcall)
+{
+ boost::intrusive_ptr<T> res = boost::intrusive_ptr<T>(static_cast<T*>(simcall.dp), false);
+ intrusive_ptr_release(&*res);
+ return res;
+}
+
template<class R, class... T> inline
void marshal(type<R(*)(T...)>, u_smx_scalar& simcall, R(*value)(T...))
{
int Datatype::copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype){
- int count;
// FIXME Handle the case of a partial shared malloc.
if (recvcount > 0 && recvbuf != sendbuf) {
sendcount *= sendtype->size();
recvcount *= recvtype->size();
- count = sendcount < recvcount ? sendcount : recvcount;
+ int count = sendcount < recvcount ? sendcount : recvcount;
if (not(sendtype->flags() & DT_FLAG_DERIVED) && not(recvtype->flags() & DT_FLAG_DERIVED)) {
if (not smpi_process()->replaying())
}
}
-void sg_instr_new_host(simgrid::s4u::Host& host)
+static void sg_instr_new_host(simgrid::s4u::Host& host)
{
container_t father = currentContainer.back();
container_t container = PJ_container_new(host.cname(), INSTR_HOST, father);
return;
simgrid::s4u::Link::onCreation.connect(instr_routing_parse_start_link);
simgrid::s4u::onPlatformCreated.connect(instr_routing_parse_end_platform);
+ simgrid::s4u::Host::onCreation.connect(sg_instr_new_host);
}
/*
host->pimpl_cpu->setPState(args->pstate);
if (args->coord && strcmp(args->coord, ""))
new simgrid::kernel::routing::vivaldi::Coords(host->pimpl_netpoint, args->coord);
-
- if (TRACE_is_enabled() && TRACE_needs_platform())
- sg_instr_new_host(*host);
+
}
/** @brief Add a "router" to the network element list */
/********** Instr. **********/
XBT_PRIVATE void sg_instr_AS_begin(sg_platf_AS_cbarg_t AS);
XBT_PRIVATE void sg_instr_new_router(const char* name);
-XBT_PRIVATE void sg_instr_new_host(simgrid::s4u::Host& host);
XBT_PRIVATE void sg_instr_AS_end();
SG_END_DECL()
char maps_buff[512];
long int offset = 0;
char* p;
- char* p2;
int found = 0;
/* let's look for the offset of this library in our addressing space */
free(p);
snprintf(line_func,3, "??");
} else {
- p2 = strrchr(p, '(');
+ char* p2 = strrchr(p, '(');
if (p2)
*p2 = '\0';
p2 = strrchr(p, ' ');
*/
extern "C" void xbt_dynar_remove_at(xbt_dynar_t const dynar, const int idx, void* const object)
{
- unsigned long nb_shift;
- unsigned long offset;
-
_sanity_check_dynar(dynar);
_check_inbound_idx(dynar, idx);
dynar->free_f(_xbt_dynar_elm(dynar, idx));
}
- nb_shift = dynar->used - 1 - idx;
+ unsigned long nb_shift = dynar->used - 1 - idx;
if (nb_shift) {
- offset = nb_shift * dynar->elmsize;
+ unsigned long offset = nb_shift * dynar->elmsize;
memmove(_xbt_dynar_elm(dynar, idx), _xbt_dynar_elm(dynar, idx + 1), offset);
}
{
unsigned long nb_shift;
unsigned long offset;
- unsigned long cur;
if (not n)
return;
_check_inbound_idx(dynar, idx + n - 1);
if (dynar->free_f) {
- for (cur = idx; cur < idx + n; cur++) {
+ for (unsigned long cur = idx; cur < idx + n; cur++) {
dynar->free_f(_xbt_dynar_elm(dynar, cur));
}
}
/* Vars_decl [doxygen cruft] */
int i;
unsigned int cursor;
- int *iptr;
xbt_test_add("==== Traverse the empty dynar");
xbt_dynar_t d = xbt_dynar_new(sizeof(int), nullptr);
/* 2. Traverse manually the dynar */
for (cursor = 0; cursor < NB_ELEM; cursor++) {
- iptr = (int*) xbt_dynar_get_ptr(d, cursor);
+ int* iptr = (int*)xbt_dynar_get_ptr(d, cursor);
xbt_test_assert(cursor == (unsigned int)*iptr, "The retrieved value is not the same than the injected one (%u!=%d)",
cursor, *iptr);
}
xbt_parmap_set_mode(parmap, mode);
/* Create the pool of worker threads */
- xbt_parmap_thread_data_t data;
parmap->workers[0] = nullptr;
#if HAVE_PTHREAD_SETAFFINITY
int core_bind = 0;
#endif
for (unsigned int i = 1; i < num_workers; i++) {
- data = xbt_new0(s_xbt_parmap_thread_data_t, 1);
+ xbt_parmap_thread_data_t data = xbt_new0(s_xbt_parmap_thread_data_t, 1);
data->parmap = parmap;
data->worker_id = i;
parmap->workers[i] = xbt_os_thread_create(nullptr, xbt_parmap_worker_main, data, nullptr);
lmm_constraint_t cnst[nb_cnst];
lmm_variable_t var[nb_var];
int used[nb_cnst];
- int concurrency_share;
lmm_system_t Sys = lmm_system_new(1);
for (int i = 0; i < nb_var; i++) {
var[i] = lmm_variable_new(Sys, NULL, 1.0, -1.0, nb_elem);
//Have a few variables with a concurrency share of two (e.g. cross-traffic in some cases)
- concurrency_share=1+int_random(max_share);
+ int concurrency_share = 1 + int_random(max_share);
lmm_variable_concurrency_share_set(var[i],concurrency_share);
for (int j = 0; j < nb_cnst; j++)
int main(int argc, char **argv)
{
- double now = -1.0;
surf_init(&argc, argv); /* Initialize some common structures */
xbt_cfg_set_parse("cpu/model:Cas01");
xbt_cfg_set_parse("network/model:CM02");
surf_solve(-1.0);
do {
simgrid::surf::ActionList *action_list = nullptr;
- now = surf_get_clock();
- XBT_INFO("Next Event : %g", now);
+ XBT_INFO("Next Event : %g", surf_get_clock());
XBT_DEBUG("\t CPU actions");
action_list = surf_cpu_model_pm->getFailedActionSet();