* - SEEK_END: end of the file
* @return MSG_OK if successful, otherwise MSG_TASK_CANCELED
*/
-XBT_PUBLIC(int) surf_host_file_seek(sg_host_t host,
- surf_file_t fd, sg_offset_t offset,
- int origin);
+XBT_PUBLIC(int) surf_host_file_seek(sg_host_t host, surf_file_t fd, sg_offset_t offset, int origin);
/**
* @brief Get the content of a storage
*/
XBT_PUBLIC_DATA(s_surf_model_description_t) surf_vm_model_description[];
-/** \ingroup SURF_models
- * \brief List of initialized models
- */
-XBT_PUBLIC_DATA(xbt_dynar_t) all_existing_models;
-
/** \ingroup SURF_simulation
* \brief List of hosts that have just restarted and whose autorestart process should be restarted.
*/
double total_time = 0.0;
/* main loop */
while (elapsed_time >= 0 && (how_long < 0 || 0.00001 < (how_long -total_time)) && !sd_global->watch_point_reached) {
- surf_model_t model = nullptr;
XBT_DEBUG("Total time: %f", total_time);
total_time += elapsed_time;
/* let's see which tasks are done */
- unsigned int iter;
- xbt_dynar_foreach(all_existing_models, iter, model) {
+ for (auto model : *all_existing_models) {
surf_action_t action = surf_model_extract_done_action_set(model);
while (action != nullptr) {
SD_task_t task = static_cast<SD_task_t>(action->getData());
/** Wake up all processes waiting for a Surf action to finish */
static void SIMIX_wake_processes()
{
- unsigned int iter;
- surf_model_t model;
surf_action_t action;
- xbt_dynar_foreach(all_existing_models, iter, model) {
+ for(auto model : *all_existing_models) {
XBT_DEBUG("Handling the processes whose action failed (if any)");
while ((action = surf_model_extract_failed_action_set(model))) {
XBT_DEBUG(" Handling Action %p",action);
#include "network_interface.hpp"
#include "virtual_machine.hpp"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_host, surf,
- "Logging specific to the SURF host module");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_host, surf, "Logging specific to the SURF host module");
simgrid::surf::HostModel *surf_host_model = nullptr;
}
}
if (nb == 1) {
- action = surf_network_model->communicate(host_list[0]->pimpl_netcard,
- host_list[1]->pimpl_netcard,
- value, rate);
+ action = surf_network_model->communicate(host_list[0]->pimpl_netcard, host_list[1]->pimpl_netcard, value, rate);
} else if (nb == 0) {
xbt_die("Cannot have a communication with no flop to exchange in this model. You should consider using the ptask model");
} else {
unsigned int cursor;
XBT_DEBUG("Search for storage name '%s' on '%s'", mount, getName());
- xbt_dynar_foreach(p_storage,cursor,mnt)
- {
+ xbt_dynar_foreach(p_storage,cursor,mnt){
XBT_DEBUG("See '%s'",mnt.name);
if(!strcmp(mount,mnt.name)){
st = static_cast<simgrid::surf::Storage*>(mnt.storage);
break;
}
}
- if(!st) xbt_die("Can't find mount '%s' for '%s'", mount, getName());
+ if(!st)
+ xbt_die("Can't find mount '%s' for '%s'", mount, getName());
return st;
}
}
surf_cpu_model_pm = new simgrid::surf::CpuCas01Model();
- xbt_dynar_push(all_existing_models, &surf_cpu_model_pm);
+ all_existing_models->push_back(surf_cpu_model_pm);
surf_cpu_model_vm = new simgrid::surf::CpuCas01Model();
- xbt_dynar_push(all_existing_models, &surf_cpu_model_vm);
+ all_existing_models->push_back(surf_cpu_model_vm);
}
namespace simgrid {
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);
+ all_existing_models->push_back(surf_cpu_model_pm);
surf_cpu_model_vm = new simgrid::surf::CpuTiModel();
- xbt_dynar_push(all_existing_models, &surf_cpu_model_vm);
+ all_existing_models->push_back(surf_cpu_model_vm);
}
namespace simgrid {
surf_cpu_model_init_Cas01();
surf_network_model_init_LegrandVelho();
- xbt_dynar_push(all_existing_models, &surf_host_model);
+ all_existing_models->push_back(surf_host_model);
}
void surf_host_model_init_compound()
xbt_assert(surf_network_model, "No network model defined yet!");
surf_host_model = new simgrid::surf::HostCLM03Model();
- xbt_dynar_push(all_existing_models, &surf_host_model);
+ all_existing_models->push_back(surf_host_model);
}
namespace simgrid {
return;
surf_network_model = new simgrid::surf::NetworkCm02Model();
- xbt_dynar_push(all_existing_models, &surf_network_model);
+ all_existing_models->push_back(surf_network_model);
xbt_cfg_setdefault_double("network/latency-factor", 13.01);
xbt_cfg_setdefault_double("network/bandwidth-factor", 0.97);
return;
surf_network_model = new simgrid::surf::NetworkCm02Model();
- xbt_dynar_push(all_existing_models, &surf_network_model);
+ all_existing_models->push_back(surf_network_model);
xbt_cfg_setdefault_double("network/latency-factor", 1.0);
xbt_cfg_setdefault_double("network/bandwidth-factor", 1.0);
return;
surf_network_model = new simgrid::surf::NetworkCm02Model();
- xbt_dynar_push(all_existing_models, &surf_network_model);
+ all_existing_models->push_back(surf_network_model);
lmm_set_default_protocol_function(func_reno_f, func_reno_fp, func_reno_fpi);
surf_network_model->f_networkSolve = lagrange_solve;
return;
surf_network_model = new simgrid::surf::NetworkCm02Model();
- xbt_dynar_push(all_existing_models, &surf_network_model);
+ all_existing_models->push_back(surf_network_model);
lmm_set_default_protocol_function(func_reno2_f, func_reno2_fp, func_reno2_fpi);
surf_network_model->f_networkSolve = lagrange_solve;
return;
surf_network_model = new simgrid::surf::NetworkCm02Model();
- xbt_dynar_push(all_existing_models, &surf_network_model);
+ all_existing_models->push_back(surf_network_model);
lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp, func_vegas_fpi);
surf_network_model->f_networkSolve = lagrange_solve;
{
xbt_assert(surf_network_model == nullptr);
surf_network_model = new simgrid::surf::NetworkConstantModel();
- xbt_dynar_push(all_existing_models, &surf_network_model);
+ all_existing_models->push_back(surf_network_model);
routing_model_create(nullptr);
}
return;
surf_network_model = new simgrid::surf::NetworkIBModel();
- xbt_dynar_push(all_existing_models, &surf_network_model);
+ all_existing_models->push_back(surf_network_model);
networkActionStateChangedCallbacks.connect(IB_action_state_changed_callback);
Link::onCommunicate.connect(IB_action_init_callback);
simgrid::s4u::Host::onCreation.connect(IB_create_host_callback);
if (surf_network_model)
return;
surf_network_model = new simgrid::surf::NetworkSmpiModel();
- xbt_dynar_push(all_existing_models, &surf_network_model);
+ all_existing_models->push_back(surf_network_model);
xbt_cfg_setdefault_double("network/sender-gap", 10e-6);
xbt_cfg_setdefault_double("network/weight-S", 8775);
xbt_assert(!surf_network_model, "network model type already defined");
surf_host_model = new simgrid::surf::HostL07Model();
- xbt_dynar_push(all_existing_models, &surf_host_model);
+ all_existing_models->push_back(surf_host_model);
}
#include "surf_private.h"
#include "xbt/file.h" /* xbt_getline */
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf,
- "Logging specific to the SURF storage module");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf, "Logging specific to the SURF storage module");
xbt_lib_t file_lib;
xbt_lib_t storage_lib;
void surf_storage_model_init_default()
{
surf_storage_model = new simgrid::surf::StorageN11Model();
- xbt_dynar_push(all_existing_models, &surf_storage_model);
+ all_existing_models->push_back(surf_storage_model);
}
namespace simgrid {
tmgr_trace_iterator_t event = nullptr;
double value = -1.0;
simgrid::surf::Resource *resource = nullptr;
- simgrid::surf::Model *model = nullptr;
- unsigned int iter;
XBT_DEBUG ("Consume all trace events occurring before the starting time.");
while ((next_event_date = future_evt_set->next_date()) != -1.0) {
}
XBT_DEBUG ("Set every models in the right state by updating them to 0.");
- xbt_dynar_foreach(all_existing_models, iter, model)
+ for (auto model : *all_existing_models)
model->updateActionsState(NOW, 0.0);
}
double model_next_action_end = -1.0;
double value = -1.0;
simgrid::surf::Resource *resource = nullptr;
- simgrid::surf::Model *model = nullptr;
tmgr_trace_iterator_t event = nullptr;
- unsigned int iter;
if (max_date > 0.0) {
xbt_assert(max_date > NOW,"You asked to simulate up to %f, but that's in the past already", max_date);
NOW = NOW + time_delta;
// Inform the models of the date change
- xbt_dynar_foreach(all_existing_models, iter, model) {
+ for (auto model : *all_existing_models) {
model->updateActionsState(NOW, time_delta);
}
/* model_list_invoke contains only surf_host and surf_vm.
* The callback functions of cpu_model and network_model will be called from those of these host models. */
-xbt_dynar_t all_existing_models = nullptr; /* to destroy models correctly */
+std::vector<surf_model_t> * all_existing_models = nullptr; /* to destroy models correctly */
xbt_dynar_t model_list_invoke = nullptr; /* to invoke callbacks */
simgrid::trace_mgr::future_evt_set *future_evt_set = nullptr;
xbt_init(argc, argv);
if (!all_existing_models)
- all_existing_models = xbt_dynar_new(sizeof(simgrid::surf::Model*), nullptr);
+ all_existing_models = new std::vector<simgrid::surf::Model*>();
if (!model_list_invoke)
model_list_invoke = xbt_dynar_new(sizeof(simgrid::surf::Model*), nullptr);
if (!future_evt_set)
void surf_exit()
{
- unsigned int iter;
- simgrid::surf::Model *model = nullptr;
-
- TRACE_end(); /* Just in case it was not called by the upper
- * layer (or there is no upper layer) */
+ TRACE_end(); /* Just in case it was not called by the upper layer (or there is no upper layer) */
sg_config_finalize();
xbt_lib_free(&file_lib);
xbt_dict_free(&watched_hosts_lib);
- xbt_dynar_foreach(all_existing_models, iter, model)
+ for (auto model : *all_existing_models)
delete model;
- xbt_dynar_free(&all_existing_models);
+ delete all_existing_models;
xbt_dynar_free(&model_list_invoke);
routing_exit();
XBT_PRIVATE void surf_action_lmm_update_index_heap(void *action, int i);
-XBT_PUBLIC_DATA(xbt_dynar_t) all_existing_models;
+/** \ingroup SURF_models
+ * \brief List of initialized models
+ */
+XBT_PUBLIC_DATA(std::vector<surf_model_t>*) all_existing_models;
namespace simgrid {
namespace surf {
void surf_vm_model_init_HL13(){
if (surf_cpu_model_vm) {
surf_vm_model = new simgrid::surf::VMHL13Model();
- simgrid::surf::Model *model = surf_vm_model;
- xbt_dynar_push(all_existing_models, &model);
+ all_existing_models->push_back(surf_vm_model);
}
}
surf_solve(-1.0); /* Takes traces into account. Returns 0.0 */
do {
surf_action_t action = nullptr;
- unsigned int iter;
- surf_model_t model = nullptr;
running = 0;
now = surf_get_clock();
XBT_INFO("Next Event : %g", now);
- xbt_dynar_foreach(all_existing_models, iter, model) {
+ for (auto model: *all_existing_models) {
if (surf_model_running_action_set_size((surf_model_t)model)) {
XBT_DEBUG("\t Running that model");
running = 1;