the lambda or closure passed as a parameter will run in kernel mode.
Every callbacks should be rewritten to that interface at some point.
+ MC
+ * BC breaks:
+ - The option "model-check/sparse-checkpoint" was renamed to
+ "model-check/sparse_checkpoint" as we attempt to unify our naming
+ schemes.
+
Surf
* Reorganizing and cleaning the internals all around the place.
artifacts:
- path: simgrid.jar
name: jarfile
+- path: C:/mingw64/bin/libwinpthread-1.dll
+ name: libwinpthread-1.dll
# notifications:
# - irc: "irc.debian.org#simgrid" # Not implemented by AppVeyor yet :(
change much between different snapshots and taking a complete copy of each
snapshot is a waste of memory.
-The \b model-check/sparse-checkpoint option item can be set to \b yes in order
+The \b model-check/sparse_checkpoint option item can be set to \b yes in order
to avoid making a complete copy of each snapshot: instead, each snapshot will be
decomposed in blocks which will be stored separately.
If multiple snapshots share the same block (or if the same block
consumption of the snapshots to be \f$ \mbox{number of processes}
\times \mbox{stack size} \times \mbox{number of states} \f$.
-The \b model-check/sparse-checkpoint can be used to reduce the memory
+The \b model-check/sparse_checkpoint can be used to reduce the memory
consumption by trying to share memory between the different snapshots.
When compiled against the model checker, the stacks are not
- \c model-check/reduction: \ref options_modelchecking_reduction
- \c model-check/replay: \ref options_modelchecking_recordreplay
- \c model-check/send_determinism: \ref options_modelchecking_sparse_checkpoint
-- \c model-check/sparse-checkpoint: \ref options_modelchecking_sparse_checkpoint
+- \c model-check/sparse_checkpoint: \ref options_modelchecking_sparse_checkpoint
- \c model-check/termination: \ref options_modelchecking_termination
- \c model-check/timeout: \ref options_modelchecking_timeout
- \c model-check/visited: \ref options_modelchecking_visited
! expect return 2
! timeout 10
-$ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/bugged1_liveness ${srcdir:=.}/../../platforms/platform.xml ${srcdir:=.}/deploy_bugged1_liveness.xml --log=xbt_cfg.thresh:warning "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:ucontext --cfg=contexts/stack_size:256 --cfg=model-check/sparse-checkpoint:yes --cfg=model-check/property:promela_bugged1_liveness
+$ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/bugged1_liveness ${srcdir:=.}/../../platforms/platform.xml ${srcdir:=.}/deploy_bugged1_liveness.xml --log=xbt_cfg.thresh:warning "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:ucontext --cfg=contexts/stack_size:256 --cfg=model-check/sparse_checkpoint:yes --cfg=model-check/property:promela_bugged1_liveness
> [ 0.000000] (0:maestro@) Check the liveness property promela_bugged1_liveness
> [ 0.000000] (2:client@Boivin) Ask the request
> [ 0.000000] (3:client@Fafard) Ask the request
! expect return 2
! timeout 10
-$ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/bugged1_liveness ${srcdir:=.}/../../platforms/platform.xml ${srcdir:=.}/deploy_bugged1_liveness_visited.xml --log=xbt_cfg.thresh:warning "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:ucontext --cfg=model-check/visited:100 --cfg=contexts/stack_size:256 --cfg=model-check/sparse-checkpoint:yes --cfg=model-check/property:promela_bugged1_liveness
+$ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/bugged1_liveness ${srcdir:=.}/../../platforms/platform.xml ${srcdir:=.}/deploy_bugged1_liveness_visited.xml --log=xbt_cfg.thresh:warning "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:ucontext --cfg=model-check/visited:100 --cfg=contexts/stack_size:256 --cfg=model-check/sparse_checkpoint:yes --cfg=model-check/property:promela_bugged1_liveness
> [ 0.000000] (0:maestro@) Check the liveness property promela_bugged1_liveness
> [ 0.000000] (2:client@Boivin) Ask the request
> [ 0.000000] (3:client@Fafard) Ask the request
##-------------------------------- DEFAULT APPLICATION --------------------------------------
-APPLICATIONTMP=$(echo ${PROC_ARGS}|cut -d' ' -f2)
+APPLICATIONTMP=$(echo ${PROC_ARGS}|cut -d' ' -f2 -s)
cat > ${APPLICATIONTMP} <<APPLICATIONHEAD
<?xml version='1.0'?>
p Test the replay with multiple instances
p first generate the deployment file
-$ ${srcdir:=.}/generate_multiple_deployment.sh -platform ${srcdir:=.}/../../platforms/small_platform_with_routers.xml -hostfile ${srcdir:=.}/../hostfile ${srcdir:=.}/description_file deployment.xml
+$ ${srcdir:=.}/generate_multiple_deployment.sh -platform ${srcdir:=.}/../../platforms/small_platform_with_routers.xml -hostfile ${srcdir:=.}/../hostfile ${srcdir:=.}/description_file ${srcdir:=.}/deployment.xml
! timeout 120
$ ./replay_multiple description_file ${srcdir:=.}/../../platforms/small_platform_with_routers.xml deployment.xml --log=smpi.:info
class Host;
}
namespace surf {
+ class Resource;
class Cpu;
class NetCard;
class As;
}
typedef simgrid::s4u::Host simgrid_Host;
+typedef simgrid::surf::As surf_As;
typedef simgrid::surf::Cpu surf_Cpu;
typedef simgrid::surf::NetCard surf_NetCard;
-typedef simgrid::surf::As surf_As;
typedef simgrid::surf::Link Link;
+typedef simgrid::surf::Resource surf_Resource;
typedef simgrid::trace_mgr::future_evt_set sg_future_evt_set;
#else
typedef struct simgrid_Host simgrid_Host;
+typedef struct surf_As surf_As;
typedef struct surf_Cpu surf_Cpu;
typedef struct surf_NetCard surf_NetCard;
-typedef struct surf_As surf_As;
+typedef struct surf_Resource surf_Resource;
typedef struct Link Link;
typedef struct future_evt_set sg_future_evt_set;
#endif
typedef simgrid_Host* sg_host_t;
+typedef surf_As *AS_t;
typedef surf_Cpu *surf_cpu_t;
typedef surf_NetCard *sg_netcard_t;
-typedef surf_As *AS_t;
+typedef surf_Resource *sg_resource_t;
typedef sg_future_evt_set *sg_future_evt_set_t;
// Types which are in fact dictelmt:
public static void nativeInit() {
if (isNativeInited)
return;
-
+
+ if (System.getProperty("os.name").toLowerCase().startsWith("win"))
+ NativeLib.nativeInit("winpthread-1");
+
NativeLib.nativeInit("simgrid");
NativeLib.nativeInit("simgrid-java");
isNativeInited = true;
XBT_ERROR("Attribute 'speed' must be specified for host and must either be a string (in the correct format; check documentation) or a number.");
}
host.speed_peak = xbt_dynar_new(sizeof(double), NULL);
- xbt_dynar_push_as(host.speed_peak, double, get_cpu_speed(lua_tostring(L, -1)));
+ xbt_dynar_push_as(host.speed_peak, double, parse_cpu_speed(lua_tostring(L, -1)));
lua_pop(L, 1);
// get core
/* For the trace and trace:connect tag (store their content till the end of the parsing) */
XBT_PUBLIC_DATA(xbt_dict_t) traces_set_list;
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_host_avail;
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_power;
+XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_host_speed;
XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_avail;
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_bandwidth;
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_latency;
+XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_bw;
+XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_lat;
-
-XBT_PUBLIC(double) get_cpu_speed(const char *power);
+XBT_PUBLIC(double) parse_cpu_speed(const char *str_speed);
XBT_PUBLIC(xbt_dict_t) get_as_router_properties(const char* name);
-int surf_get_nthreads(void);
-void surf_set_nthreads(int nthreads);
-
/*
* Returns the initial path. On Windows the initial path is
* the current directory for the current process in the other
{
return remote_ptr<T>(address_ - n * sizeof(T));
}
- remote_ptr<T>& operator+=(std::uint64_t n) const
+ remote_ptr<T>& operator+=(std::uint64_t n)
{
address_ += n * sizeof(T);
return *this;
}
- remote_ptr<T>& operator-=(std::uint64_t n) const
+ remote_ptr<T>& operator-=(std::uint64_t n)
{
address_ -= n * sizeof(T);
return *this;
current_var1 = &stack1->local_variables[cursor];
current_var2 = &stack1->local_variables[cursor];
if (current_var1->name != current_var2->name
- || current_var1->subprogram != current_var1->subprogram
+ || current_var1->subprogram != current_var2->subprogram
|| current_var1->ip != current_var2->ip) {
// TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
XBT_VERB
mc_snapshot_stack_t stack1, stack2;
while (cursor < s1->stacks.size()) {
stack1 = &s1->stacks[cursor];
- stack2 = &s1->stacks[cursor];
+ stack2 = &s2->stacks[cursor];
if (stack1->process_index != stack2->process_index) {
diff_local = 1;
if (!sd_global->watch_point_reached && how_long<0){
if (!xbt_dynar_is_empty(sd_global->initial_task_set)) {
- XBT_WARN("Simulation is finished but %zu tasks are still not done",
+ XBT_WARN("Simulation is finished but %lu tasks are still not done",
xbt_dynar_length(sd_global->initial_task_set));
static const char* state_names[] =
{ "SD_NOT_SCHEDULED", "SD_SCHEDULABLE", "SD_SCHEDULED", "SD_RUNNABLE", "SD_RUNNING", "SD_DONE","SD_FAILED" };
xbt_cfg_setdefault_int(_sg_cfg_set, "model-check/checkpoint", 0);
/* do stateful model-checking */
- xbt_cfg_register(&_sg_cfg_set, "model-check/sparse-checkpoint",
+ xbt_cfg_register(&_sg_cfg_set, "model-check/sparse_checkpoint",
"Use sparse per-page snapshots.",
xbt_cfgelm_boolean, 1, 1, _mc_cfg_cb_sparse_checkpoint, NULL);
- xbt_cfg_setdefault_boolean(_sg_cfg_set, "model-check/sparse-checkpoint", "no");
+ xbt_cfg_setdefault_boolean(_sg_cfg_set, "model-check/sparse_checkpoint", "no");
/* do stateful model-checking */
xbt_cfg_register(&_sg_cfg_set, "model-check/soft-dirty",
return;
called = 1;
- /* connect all traces relative to hosts */
- xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
+ /* connect host speed traces */
+ xbt_dict_foreach(trace_connect_list_host_speed, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
- CpuCas01 *host = static_cast<CpuCas01*>(sg_host_by_name(elm)->pimpl_cpu);
+ Cpu *cpu = sg_host_by_name(elm)->pimpl_cpu;
- xbt_assert(host, "Host %s undefined", elm);
+ xbt_assert(cpu, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
- host->p_stateEvent = future_evt_set->add_trace(trace, 0.0, host);
- }
-
- xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
- tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
- CpuCas01 *host = static_cast<CpuCas01*>(sg_host_by_name(elm)->pimpl_cpu);
-
- xbt_assert(host, "Host %s undefined", elm);
- xbt_assert(trace, "Trace %s undefined", trace_name);
-
- host->p_speedEvent = future_evt_set->add_trace(trace, 0.0, host);
+ cpu->set_speed_trace(trace);
}
}
************/
class CpuCas01 : public Cpu {
- friend CpuCas01Model;
public:
CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeak,
int pstate, double speedScale, tmgr_trace_t speedTrace, int core,
protected:
void onSpeedChange() override;
-
-private:
-
- tmgr_trace_iterator_t p_stateEvent = nullptr;
- tmgr_trace_iterator_t p_speedEvent = nullptr;
};
/**********
return m_core;
}
+void Cpu::set_state_trace(tmgr_trace_t trace)
+{
+ xbt_assert(p_stateEvent==NULL,"Cannot set a second state trace to Host %s", m_host->name().c_str());
+
+ p_stateEvent = future_evt_set->add_trace(trace, 0.0, this);
+}
+void Cpu::set_speed_trace(tmgr_trace_t trace)
+{
+ xbt_assert(p_speedEvent==NULL,"Cannot set a second speed trace to Host %s", m_host->name().c_str());
+
+ p_speedEvent = future_evt_set->add_trace(trace, 0.0, this);
+}
+
+
/**********
* Action *
**********/
virtual void setPState(int pstate_index);
virtual int getPState();
- void addTraces(void);
simgrid::s4u::Host* getHost() { return m_host; }
public:
lmm_constraint_t *p_constraintCore=NULL;
void **p_constraintCoreId=NULL;
+public:
+ void set_state_trace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF) */
+ void set_speed_trace(tmgr_trace_t trace); /*< setup the trace file with availability events (peak speed changes due to external load) */
+protected:
+ tmgr_trace_iterator_t p_stateEvent = nullptr;
+ tmgr_trace_iterator_t p_speedEvent = nullptr;
};
/**********
}
}
-/*************
- * CallBacks *
- *************/
-
-static void cpu_ti_define_callbacks()
-{
- simgrid::surf::on_postparse.connect([]() {
- surf_cpu_model_pm->addTraces();
- });
-}
-
/*********
* Model *
*********/
xbt_assert(!surf_cpu_model_vm,"CPU model already initialized. This should not happen.");
surf_cpu_model_pm = new simgrid::surf::CpuTiModel();
+ xbt_dynar_push(all_existing_models, &surf_cpu_model_pm);
+
surf_cpu_model_vm = new simgrid::surf::CpuTiModel();
+ xbt_dynar_push(all_existing_models, &surf_cpu_model_vm);
- cpu_ti_define_callbacks();
- simgrid::surf::Model *model_pm = static_cast<simgrid::surf::Model*>(surf_cpu_model_pm);
- simgrid::surf::Model *model_vm = static_cast<simgrid::surf::Model*>(surf_cpu_model_vm);
- xbt_dynar_push(all_existing_models, &model_pm);
- xbt_dynar_push(all_existing_models, &model_vm);
+ simgrid::surf::on_postparse.connect([]() {
+ surf_cpu_model_pm->addTraces();
+ });
}
namespace simgrid {
called = 1;
/* connect all traces relative to hosts */
- xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
- tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
- CpuTi *cpu = static_cast<CpuTi*>(sg_host_by_name(elm)->pimpl_cpu);
-
- xbt_assert(cpu, "Host %s undefined", elm);
- xbt_assert(trace, "Trace %s undefined", trace_name);
-
- if (cpu->p_stateEvent) {
- XBT_DEBUG("Trace already configured for this CPU(%s), ignoring it",
- elm);
- continue;
- }
- XBT_DEBUG("Add state trace: %s to CPU(%s)", trace_name, elm);
- cpu->p_stateEvent = future_evt_set->add_trace(trace, 0.0, cpu);
- }
-
- xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
+ xbt_dict_foreach(trace_connect_list_host_speed, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
CpuTi *cpu = static_cast<CpuTi*>(sg_host_by_name(elm)->pimpl_cpu);
xbt_dynar_get_cpy(trace->s_list.event_list,
xbt_dynar_length(trace->s_list.event_list) - 1, &val);
if (val.delta == 0) {
- cpu->p_speedEvent =
- future_evt_set->add_trace(tmgr_empty_trace_new(), cpu->p_availTrace->m_lastTime, cpu);
+ cpu->set_speed_trace(tmgr_empty_trace_new());
}
}
}
void modified(bool modified);
CpuTiTgmr *p_availTrace; /*< Structure with data needed to integrate trace file */
- tmgr_trace_iterator_t p_stateEvent = NULL; /*< trace file with states events (ON or OFF) */
- tmgr_trace_iterator_t p_speedEvent = NULL; /*< trace file with availability events */
ActionTiList *p_actionSet; /*< set with all actions running on cpu */
double m_sumPriority; /*< the sum of actions' priority that are running on cpu */
double m_lastUpdate = 0; /*< last update of actions' remaining amount done */
int nb_used_host = 0; /* Only the hosts with something to compute (>0 flops) are counted) */
double latency = 0.0;
- xbt_dict_t ptask_parallel_task_link_set = xbt_dict_new_homogeneous(NULL);
this->p_netcardList->reserve(host_nb);
for (int i = 0; i<host_nb; i++)
/* Compute the number of affected resources... */
if(bytes_amount != NULL) {
+ xbt_dict_t ptask_parallel_task_link_set = xbt_dict_new_homogeneous(NULL);
+
for (int i = 0; i < host_nb; i++) {
for (int j = 0; j < host_nb; j++) {
xbt_dynar_t route=NULL;
}
}
}
- }
- nb_link = xbt_dict_length(ptask_parallel_task_link_set);
- xbt_dict_free(&ptask_parallel_task_link_set);
+ nb_link = xbt_dict_length(ptask_parallel_task_link_set);
+ xbt_dict_free(&ptask_parallel_task_link_set);
+ }
for (int i = 0; i < host_nb; i++)
if (flops_amount[i] > 0)
nb_used_host++;
- XBT_DEBUG("Creating a parallel task (%p) with %d cpus and %d links.",
- this, host_nb, nb_link);
+ XBT_DEBUG("Creating a parallel task (%p) with %d hosts and %d unique links.", this, host_nb, nb_link);
this->p_computationAmount = flops_amount;
this->p_communicationAmount = bytes_amount;
this->m_latency = latency;
this->m_rate = rate;
this->p_variable = lmm_variable_new(model->getMaxminSystem(), this, 1.0,
- (rate > 0 ? rate : -1.0),
- host_nb + nb_link);
+ (rate > 0 ? rate : -1.0),
+ host_nb + nb_link);
if (this->m_latency > 0)
lmm_update_variable_weight(model->getMaxminSystem(), this->getVariable(), 0.0);
for (int i = 0; i < host_nb; i++)
- lmm_expand(model->getMaxminSystem(),
- host_list[i]->pimpl_cpu->getConstraint(),
- this->getVariable(), flops_amount[i]);
+ lmm_expand(model->getMaxminSystem(), host_list[i]->pimpl_cpu->getConstraint(),
+ this->getVariable(), flops_amount[i]);
if(bytes_amount != NULL) {
for (int i = 0; i < host_nb; i++) {
host_list[1] = sg_host_by_name(dst->getName());
bytes_amount[1] = size;
- res = p_hostModel->executeParallelTask(2, host_list,
- flops_amount,
- bytes_amount, rate);
+ res = p_hostModel->executeParallelTask(2, host_list, flops_amount, bytes_amount, rate);
return res;
}
xbt_dict_cursor_t cursor = NULL;
char *trace_name, *elm;
- if (!trace_connect_list_host_avail)
+ if (!trace_connect_list_host_speed)
return;
/* Connect traces relative to cpu */
- xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
- tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
- CpuL07 *host = static_cast<CpuL07*>(sg_host_by_name(elm)->pimpl_cpu);
-
- xbt_assert(host, "Host %s undefined", elm);
- xbt_assert(trace, "Trace %s undefined", trace_name);
-
- host->p_stateEvent = future_evt_set->add_trace(trace, 0.0, host);
- }
-
- xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
+ xbt_dict_foreach(trace_connect_list_host_speed, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
- CpuL07 *host = static_cast<CpuL07*>(sg_host_by_name(elm)->pimpl_cpu);
+ Cpu *cpu = sg_host_by_name(elm)->pimpl_cpu;
- xbt_assert(host, "Host %s undefined", elm);
+ xbt_assert(cpu, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
- host->p_speedEvent = future_evt_set->add_trace(trace, 0.0, host);
+ cpu->set_speed_trace(trace);
}
/* Connect traces relative to network */
link->p_stateEvent = future_evt_set->add_trace(trace, 0.0, link);
}
- xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
+ xbt_dict_foreach(trace_connect_list_link_bw, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
LinkL07 *link = static_cast<LinkL07*>(Link::byName(elm));
link->p_bwEvent = future_evt_set->add_trace(trace, 0.0, link);
}
- xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
+ xbt_dict_foreach(trace_connect_list_link_lat, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
LinkL07 *link = static_cast<LinkL07*>(Link::byName(elm));
{
sg_host_t*host_list = xbt_new0(sg_host_t, 1);
double *flops_amount = xbt_new0(double, 1);
- double *bytes_amount = xbt_new0(double, 1);
host_list[0] = getHost();
flops_amount[0] = size;
return static_cast<CpuL07Model*>(getModel())->p_hostModel
- ->executeParallelTask( 1, host_list, flops_amount, bytes_amount, -1);
+ ->executeParallelTask( 1, host_list, flops_amount, NULL, -1);
}
Action *CpuL07::sleep(double duration)
return 0;
}
-void L07Action::suspend()
-{
- XBT_IN("(%p))", this);
- if (m_suspended != 2) {
- m_suspended = 1;
- lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), 0.0);
- }
- XBT_OUT();
-}
-
-void L07Action::resume()
-{
- XBT_IN("(%p)", this);
- if (m_suspended != 2) {
- lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), 1.0);
- m_suspended = 0;
- }
- XBT_OUT();
-}
-
-double L07Action::getRemains()
-{
- XBT_IN("(%p)", this);
- XBT_OUT();
- return m_remains;
-}
-
}
}
************/
class CpuL07 : public Cpu {
- friend void HostL07Model::addTraces();
- tmgr_trace_iterator_t p_stateEvent = nullptr;
- tmgr_trace_iterator_t p_speedEvent = nullptr;
public:
CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeakList, int pstate,
double power_scale, tmgr_trace_t power_trace,
void updateBound();
int unref() override;
- void suspend() override;
- void resume() override;
- double getRemains() override;
std::vector<NetCard*> * p_netcardList = new std::vector<NetCard*>();
double *p_computationAmount;
link->p_stateEvent = future_evt_set->add_trace(trace, 0.0, link);
}
- xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
+ xbt_dict_foreach(trace_connect_list_link_bw, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
NetworkCm02Link *link = static_cast<NetworkCm02Link*>( Link::byName(elm) );
link->p_speed.event = future_evt_set->add_trace(trace, 0.0, link);
}
- xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
+ xbt_dict_foreach(trace_connect_list_link_lat, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
NetworkCm02Link *link = static_cast<NetworkCm02Link*>(Link::byName(elm));;
simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onCreation;
simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onDestruction;
-simgrid::xbt::signal<void(simgrid::surf::Link*, int, int)> Link::onStateChange; // signature: wasOn, currentlyOn
+simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onStateChange;
simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, e_surf_action_state_t, e_surf_action_state_t)> networkActionStateChangedCallbacks;
simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst, double size, double rate)> networkCommunicateCallbacks;
void Link::turnOn(){
if (isOff()) {
Resource::turnOn();
- onStateChange(this, 0, 1);
+ onStateChange(this);
}
}
void Link::turnOff(){
if (isOn()) {
Resource::turnOff();
- onStateChange(this, 1, 0);
+ onStateChange(this);
}
}
* Signature: void(Link*) */
static simgrid::xbt::signal<void(simgrid::surf::Link*)> onDestruction;
- /** @brief Callback signal fired when the state of a Link changes
- * Signature: `void(LinkAction *action, int previouslyOn, int currentlyOn)` */
- static simgrid::xbt::signal<void(simgrid::surf::Link*, int, int)> onStateChange;
+ /** @brief Callback signal fired when the state of a Link changes (when it is turned on or off)
+ * Signature: `void(Link*)` */
+ static simgrid::xbt::signal<void(simgrid::surf::Link*)> onStateChange;
/** @brief Get the bandwidth in bytes per second of current Link */
while ((next_event_date = future_evt_set->next_date()) != -1.0) {
if (next_event_date > NOW)
break;
- while ((event = future_evt_set->pop_leq(next_event_date,
- &value,
- (void **) &resource))) {
+
+ while ((event = future_evt_set->pop_leq(next_event_date, &value, &resource))) {
if (value >= 0){
resource->updateState(event, value, NOW);
}
surf_min = next_event_virt;
}
- XBT_DEBUG("Min for resources (remember that NS3 don't update that value) : %f", surf_min);
+ XBT_DEBUG("Min for resources (remember that NS3 don't update that value): %f", surf_min);
XBT_DEBUG("Looking for next trace event");
- do {
- XBT_DEBUG("Next TRACE event : %f", next_event_date);
-
+ while (1) { // Handle next occurring events until none remains
next_event_date = future_evt_set->next_date();
+ XBT_DEBUG("Next TRACE event: %f", next_event_date);
if(! surf_network_model->shareResourcesIsIdempotent()){ // NS3, I see you
- if(next_event_date!=-1.0 && surf_min!=-1.0) {
+ if (next_event_date!=-1.0 && surf_min!=-1.0) {
surf_min = MIN(next_event_date - NOW, surf_min);
} else{
surf_min = MAX(next_event_date - NOW, surf_min);
}
- XBT_DEBUG("Run for network at most %f", surf_min);
+ XBT_DEBUG("Run the NS3 network at most %fs", surf_min);
// run until min or next flow
model_next_action_end = surf_network_model->shareResources(surf_min);
break;
}
- if ((surf_min == -1.0) || (next_event_date > NOW + surf_min)) break;
+ if ((surf_min == -1.0) || (next_event_date > NOW + surf_min))
+ break; // next event occurs after the next resource change, bail out
XBT_DEBUG("Updating models (min = %g, NOW = %g, next_event_date = %g)", surf_min, NOW, next_event_date);
- while ((event = future_evt_set->pop_leq(next_event_date,
- &value,
- (void **) &resource))) {
+
+ while ((event = future_evt_set->pop_leq(next_event_date, &value, &resource))) {
if (resource->isUsed() || xbt_dict_get_or_null(watched_hosts_lib, resource->getName())) {
surf_min = next_event_date - NOW;
- XBT_DEBUG
- ("This event will modify model state. Next event set to %f",
- surf_min);
+ XBT_DEBUG("This event will modify model state. Next event set to %f", surf_min);
}
- /* update state of model_obj according to new value. Does not touch lmm.
+ /* update state of the corresponding resource to the new value. Does not touch lmm.
It will be modified if needed when updating actions */
- XBT_DEBUG("Calling update_resource_state for resource %s with min %f",
- resource->getName(), surf_min);
+ XBT_DEBUG("Calling update_resource_state for resource %s with min %f", resource->getName(), surf_min);
resource->updateState(event, value, next_event_date);
}
- } while (1);
+ }
/* FIXME: Moved this test to here to avoid stopping simulation if there are actions running on cpus and all cpus are with availability = 0.
* This may cause an infinite loop if one cpu has a trace with periodicity = 0 and the other a trace with periodicity > 0.
* The options are: all traces with same periodicity(0 or >0) or we need to change the way how the events are managed */
if (surf_min == -1.0) {
- XBT_DEBUG("No next event at all. Bail out now.");
+ XBT_DEBUG("No next event at all. Bail out now.");
return -1.0;
}
XBT_DEBUG("Duration set to %f", surf_min);
+ // Bump the time: jump into the future
NOW = NOW + surf_min;
- /* FIXME: model_list or model_list_invoke? revisit here later */
- /* sequential version */
+
+ // Inform the models of the date change
xbt_dynar_foreach(all_existing_models, iter, model) {
model->updateActionsState(NOW, surf_min);
}
/* For the trace and trace:connect tag (store their content till the end of the parsing) */
XBT_PUBLIC_DATA(xbt_dict_t) traces_set_list;
XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_host_avail;
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_power;
+XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_host_speed;
XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_avail;
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_bandwidth;
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_latency;
+XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_bw;
+XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_lat;
/**********
* Action *
xbt_strdup(trace_connect->element), NULL);
break;
case SURF_TRACE_CONNECT_KIND_POWER:
- xbt_dict_set(trace_connect_list_power, trace_connect->trace,
+ xbt_dict_set(trace_connect_list_host_speed, trace_connect->trace,
xbt_strdup(trace_connect->element), NULL);
break;
case SURF_TRACE_CONNECT_KIND_LINK_AVAIL:
xbt_strdup(trace_connect->element), NULL);
break;
case SURF_TRACE_CONNECT_KIND_BANDWIDTH:
- xbt_dict_set(trace_connect_list_bandwidth,
+ xbt_dict_set(trace_connect_list_link_bw,
trace_connect->trace,
xbt_strdup(trace_connect->element), NULL);
break;
case SURF_TRACE_CONNECT_KIND_LATENCY:
- xbt_dict_set(trace_connect_list_latency, trace_connect->trace,
+ xbt_dict_set(trace_connect_list_link_lat, trace_connect->trace,
xbt_strdup(trace_connect->element), NULL);
break;
default:
XBT_DEBUG("Buffer: %s", buf);
host.speed_peak = xbt_dynar_new(sizeof(double), NULL);
if (strchr(buf, ',') == NULL){
- double speed = get_cpu_speed(A_surfxml_host_power);
+ double speed = parse_cpu_speed(A_surfxml_host_power);
xbt_dynar_push_as(host.speed_peak,double, speed);
}
else {
xbt_dynar_get_cpy(pstate_list, i, &speed_str);
xbt_str_trim(speed_str, NULL);
- speed = get_cpu_speed(speed_str);
+ speed = parse_cpu_speed(speed_str);
xbt_dynar_push_as(host.speed_peak, double, speed);
XBT_DEBUG("Speed value: %f", speed);
}
* With XML parser
*/
-double get_cpu_speed(const char *str_speed)
+double parse_cpu_speed(const char *str_speed)
{
double speed = 0.0;
const char *p, *q;
#include "xbt/dict.h"
#include "simgrid/platf.h"
#include "surf/surfxml_parse.h"
+#include "src/surf/cpu_interface.hpp"
#include "src/surf/surf_private.h"
#ifdef HAVE_LUA
XBT_IMPORT_NO_EXPORT(unsigned int) surfxml_buffer_stack_stack_ptr;
XBT_IMPORT_NO_EXPORT(unsigned int) surfxml_buffer_stack_stack[1024];
-void surfxml_bufferstack_push(int new)
+void surfxml_bufferstack_push(int new_one)
{
- if (!new)
+ if (!new_one)
old_buff = surfxml_bufferstack;
else {
xbt_dynar_push(surfxml_bufferstack_stack, &surfxml_bufferstack);
}
}
-void surfxml_bufferstack_pop(int new)
+void surfxml_bufferstack_pop(int new_one)
{
- if (!new)
+ if (!new_one)
surfxml_bufferstack = old_buff;
else {
free(surfxml_bufferstack);
xbt_dict_t traces_set_list = NULL;
xbt_dict_t trace_connect_list_host_avail = NULL;
-xbt_dict_t trace_connect_list_power = NULL;
+xbt_dict_t trace_connect_list_host_speed = NULL;
xbt_dict_t trace_connect_list_link_avail = NULL;
-xbt_dict_t trace_connect_list_bandwidth = NULL;
-xbt_dict_t trace_connect_list_latency = NULL;
+xbt_dict_t trace_connect_list_link_bw = NULL;
+xbt_dict_t trace_connect_list_link_lat = NULL;
/* ***************************************** */
traces_set_list = xbt_dict_new_homogeneous(NULL);
trace_connect_list_host_avail = xbt_dict_new_homogeneous(free);
- trace_connect_list_power = xbt_dict_new_homogeneous(free);
+ trace_connect_list_host_speed = xbt_dict_new_homogeneous(free);
trace_connect_list_link_avail = xbt_dict_new_homogeneous(free);
- trace_connect_list_bandwidth = xbt_dict_new_homogeneous(free);
- trace_connect_list_latency = xbt_dict_new_homogeneous(free);
+ trace_connect_list_link_bw = xbt_dict_new_homogeneous(free);
+ trace_connect_list_link_lat = xbt_dict_new_homogeneous(free);
/* Init my data */
if (!surfxml_bufferstack_stack)
/* Do the actual parsing */
parse_status = surf_parse();
+ /* connect all traces relative to hosts */
+ xbt_dict_cursor_t cursor = NULL;
+ char *trace_name, *elm;
+
+ xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
+ tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
+ xbt_assert(trace, "Trace %s undefined", trace_name);
+
+ simgrid::s4u::Host *host = sg_host_by_name(elm);
+ xbt_assert(host, "Host %s undefined", elm);
+ simgrid::surf::Cpu *cpu = host->pimpl_cpu;
+
+ cpu->set_state_trace(trace);
+ }
+
/* Free my data */
xbt_dict_free(&trace_connect_list_host_avail);
- xbt_dict_free(&trace_connect_list_power);
+ xbt_dict_free(&trace_connect_list_host_speed);
xbt_dict_free(&trace_connect_list_link_avail);
- xbt_dict_free(&trace_connect_list_bandwidth);
- xbt_dict_free(&trace_connect_list_latency);
+ xbt_dict_free(&trace_connect_list_link_bw);
+ xbt_dict_free(&trace_connect_list_link_lat);
xbt_dict_free(&traces_set_list);
xbt_dict_free(&random_data_list);
xbt_dynar_free(&surfxml_bufferstack_stack);
free(trace);
}
-/** Register a new trace into the future event set, and get an iterator over the integrated trace */
+/** @brief Registers a new trace into the future event set, and get an iterator over the integrated trace */
tmgr_trace_iterator_t simgrid::trace_mgr::future_evt_set::add_trace(
- tmgr_trace_t trace,
- double start_time,
- void *resource)
+ tmgr_trace_t trace, double start_time, surf::Resource *resource)
{
tmgr_trace_iterator_t trace_iterator = NULL;
return trace_iterator;
}
-double simgrid::trace_mgr::future_evt_set::next_date()
+/** @brief returns the date of the next occurring event (pure function) */
+double simgrid::trace_mgr::future_evt_set::next_date() const
{
if (xbt_heap_size(p_heap))
return (xbt_heap_maxkey(p_heap));
return -1.0;
}
+/** @brief Retrieves the next occurring event, or NULL if none happens before #date */
tmgr_trace_iterator_t simgrid::trace_mgr::future_evt_set::pop_leq(
- double date,
- double *value,
- void** resource)
+ double date, double *value, simgrid::surf::Resource **resource)
{
double event_date = next_date();
- tmgr_trace_iterator_t trace_iterator = NULL;
- tmgr_event_t event = NULL;
- tmgr_trace_t trace = NULL;
- double event_delta;
-
if (event_date > date)
return NULL;
- if (!(trace_iterator = (tmgr_trace_iterator_t)xbt_heap_pop(p_heap)))
+ tmgr_trace_iterator_t trace_iterator = (tmgr_trace_iterator_t)xbt_heap_pop(p_heap);
+ if (trace_iterator == NULL)
return NULL;
- trace = trace_iterator->trace;
+ tmgr_trace_t trace = trace_iterator->trace;
*resource = trace_iterator->resource;
- switch(trace->type) {
- case e_trace_list:
+ if (trace->type == e_trace_list) {
- event = (tmgr_event_t)xbt_dynar_get_ptr(trace->s_list.event_list, trace_iterator->idx);
+ tmgr_event_t event = (tmgr_event_t)xbt_dynar_get_ptr(trace->s_list.event_list, trace_iterator->idx);
*value = event->value;
} else { /* We don't need this trace_event anymore */
trace_iterator->free_me = 1;
}
- break;
-
- case e_trace_probabilist:
- //FIXME : not tested yet
+ } else if (trace->type == e_trace_probabilist) { //FIXME : not tested yet
+ double event_delta;
if(trace->s_probabilist.is_state_trace) {
*value = (double) trace->s_probabilist.next_event;
if(trace->s_probabilist.next_event == 0) {
xbt_heap_push(p_heap, trace_iterator, event_date + event_delta);
XBT_DEBUG("Generating a new event at date %f, with value %f", event_date + event_delta, *value);
- break;
- }
+ } else
+ THROW_IMPOSSIBLE;
return trace_iterator;
}
typedef struct tmgr_trace_iterator {
tmgr_trace_t trace;
unsigned int idx;
- void *resource;
+ sg_resource_t resource;
int free_me;
} s_tmgr_trace_event_t;
public:
future_evt_set();
virtual ~future_evt_set();
- double next_date();
- tmgr_trace_iterator_t pop_leq(double date, double *value, void** resource);
- tmgr_trace_iterator_t add_trace(
- tmgr_trace_t trace,
- double start_time,
- void *model);
+ double next_date() const;
+ tmgr_trace_iterator_t pop_leq(double date, double *value, simgrid::surf::Resource** resource);
+ tmgr_trace_iterator_t add_trace(tmgr_trace_t trace, double start_time, simgrid::surf::Resource *resource);
private:
// TODO: use a boost type for the heap (or a ladder queue)
#bsendalign 2
#bsendpending 2
isendself 1
-issendselfcancel 1
+#issendselfcancel 1
#needs MPI_Buffer_attach, MPI_Bsend, MPI_Buffer_detach
#bsendfrag 2
#needs MPI_Intercomm_create
for(j=0; j<2;j++ )
for(i=0; i<3;i++ )
- printf("%d ", tab[j][i]);
+ printf("%d ", tab[j][i]);
- printf("\n");
+ printf("\n");
/* Clean up the type */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include "src/surf/network_cm02.hpp"
#include "src/surf/trace_mgr.hpp"
XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,
"Messages specific for surf example");
+class DummyTestResource
+ : public simgrid::surf::Resource {
+public:
+ DummyTestResource(const char *name) : Resource(nullptr,name) {}
+ bool isUsed() override {return false;}
+ void updateState(tmgr_trace_iterator_t it, double date, double value) override {}
+};
+
static void test(void)
{
simgrid::trace_mgr::future_evt_set *fes = new simgrid::trace_mgr::future_evt_set();
tmgr_trace_t trace_B = tmgr_trace_new_from_file("trace_B.txt");
double next_event_date = -1.0;
double value = -1.0;
- char *resource = NULL;
- char *host_A = strdup("Host A");
- char *host_B = strdup("Host B");
+ simgrid::surf::Resource *resource = NULL;
+ simgrid::surf::Resource *hostA = new DummyTestResource("Host A");
+ simgrid::surf::Resource *hostB = new DummyTestResource("Host B");
- fes->add_trace(trace_A, 1.0, host_A);
- fes->add_trace(trace_B, 0.0, host_B);
+ fes->add_trace(trace_A, 1.0, hostA);
+ fes->add_trace(trace_B, 0.0, hostB);
while ((next_event_date = fes->next_date()) != -1.0) {
XBT_DEBUG("%g" " : \n", next_event_date);
- while (fes->pop_leq(next_event_date, &value, (void **) &resource)) {
- XBT_DEBUG("\t %s : " "%g" "\n", resource, value);
+ while (fes->pop_leq(next_event_date, &value, &resource)) {
+ XBT_DEBUG("\t %s : " "%g" "\n", resource->getName(), value);
}
if (next_event_date > 1000)
break;
}
delete fes;
- free(host_B);
- free(host_A);
+ delete hostA;
+ delete hostB;
}
int main(int argc, char **argv)
src/surf/surf_routing_none.cpp
src/surf/surf_routing_vivaldi.cpp
src/surf/surfxml_parse.c
- src/surf/surfxml_parseplatf.c
+ src/surf/surfxml_parseplatf.cpp
src/surf/trace_mgr.hpp
src/surf/trace_mgr.cpp
src/surf/vm_hl13.cpp
#COMMAND ${STRIP_COMMAND} ${JAVA_NATIVE_PATH}/${LIBSIMGRID_JAVA_SO} || true
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_SO} ${JAVA_NATIVE_PATH}
- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_JAVA_SO} ${JAVA_NATIVE_PATH}
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_JAVA_SO} ${JAVA_NATIVE_PATH}
+ # There is no way to disable the dependency of mingw-64 on that lib, unfortunately
+ # nor to script cmake -E properly, so let's be brutal
+ COMMAND ${CMAKE_COMMAND} -E copy C:/mingw64/bin/libwinpthread-1.dll ${JAVA_NATIVE_PATH} || true
COMMAND ${JAVA_ARCHIVE} -uvf ${SIMGRID_JAR} ${JAVA_NATIVE_PATH}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${JAVA_NATIVE_PATH}
COMMAND ${CMAKE_COMMAND} -E echo "-- Cmake put the native code in ${JAVA_NATIVE_PATH}"
COMMAND "${Java_JAVA_EXECUTABLE}" -classpath "${SIMGRID_JAR}" org.simgrid.NativeLib
- )
+ )
endif(enable_lib_in_jar)