X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/689067191e467d095a7c7ee340b100469bf6173b..0ba0b5da8a4948ab678226c4456f97b9b85a71c6:/src/msg/msg_vm.cpp diff --git a/src/msg/msg_vm.cpp b/src/msg/msg_vm.cpp index 8772432cc8..7cf836a767 100644 --- a/src/msg/msg_vm.cpp +++ b/src/msg/msg_vm.cpp @@ -32,6 +32,10 @@ typedef struct dirty_page* dirty_page_t; XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_vm, msg, "Cloud-oriented parts of the MSG API"); /* **** ******** GENERAL ********* **** */ +const char* MSG_vm_get_name(msg_vm_t vm) +{ + return vm->getCname(); +} /** \ingroup m_vm_management * \brief Set the parameters of a given host @@ -211,8 +215,8 @@ void MSG_vm_start(msg_vm_t vm) if (TRACE_msg_vm_is_enabled()) { container_t vm_container = PJ_container_get(vm->getCname()); type_t type = PJ_type_get("MSG_VM_STATE", vm_container->type); - val_t value = PJ_value_get_or_new("start", "0 0 1", type); // start is blue - new PushStateEvent(MSG_get_clock(), vm_container, type, value); + value* val = value::get_or_new("start", "0 0 1", type); // start is blue + new PushStateEvent(MSG_get_clock(), vm_container, type, val); } } @@ -361,18 +365,15 @@ static int migration_rx_fun(int argc, char *argv[]) static void start_dirty_page_tracking(msg_vm_t vm) { vm->pimpl_vm_->dp_enabled = 1; - if (not vm->pimpl_vm_->dp_objs) + if (vm->pimpl_vm_->dp_objs.empty()) return; - char *key = nullptr; - xbt_dict_cursor_t cursor = nullptr; - dirty_page_t dp = nullptr; - xbt_dict_foreach (vm->pimpl_vm_->dp_objs, cursor, key, dp) { + for (auto elm : vm->pimpl_vm_->dp_objs) { + dirty_page_t dp = elm.second; double remaining = MSG_task_get_flops_amount(dp->task); dp->prev_clock = MSG_get_clock(); dp->prev_remaining = remaining; - - // XBT_INFO("%s@%s remaining %f", key, sg_host_name(vm), remaining); + XBT_DEBUG("%s@%s remaining %f", elm.first.c_str(), vm->getCname(), remaining); } } @@ -381,7 +382,7 @@ static void stop_dirty_page_tracking(msg_vm_t vm) vm->pimpl_vm_->dp_enabled = 0; } -static double get_computed(char *key, msg_vm_t vm, dirty_page_t dp, double remaining, double clock) +static double get_computed(const char* key, msg_vm_t vm, dirty_page_t dp, double remaining, double clock) { double computed = dp->prev_remaining - remaining; double duration = clock - dp->prev_clock; @@ -396,10 +397,9 @@ static double lookup_computed_flop_counts(msg_vm_t vm, int stage_for_fancy_debug { double total = 0; - char *key = nullptr; - xbt_dict_cursor_t cursor = nullptr; - dirty_page_t dp = nullptr; - xbt_dict_foreach (vm->pimpl_vm_->dp_objs, cursor, key, dp) { + for (auto elm : vm->pimpl_vm_->dp_objs) { + const char* key = elm.first.c_str(); + dirty_page_t dp = elm.second; double remaining = MSG_task_get_flops_amount(dp->task); double clock = MSG_get_clock(); @@ -439,10 +439,7 @@ void MSG_host_add_task(msg_host_t host, msg_task_t task) dp->prev_clock = MSG_get_clock(); dp->prev_remaining = remaining; } - if (not vm->pimpl_vm_->dp_objs) - vm->pimpl_vm_->dp_objs = xbt_dict_new_homogeneous(nullptr); - xbt_assert(xbt_dict_get_or_null(vm->pimpl_vm_->dp_objs, key) == nullptr); - xbt_dict_set(vm->pimpl_vm_->dp_objs, key, dp, nullptr); + vm->pimpl_vm_->dp_objs.insert({key, dp}); XBT_DEBUG("add %s on %s (remaining %f, dp_enabled %d)", key, host->getCname(), remaining, vm->pimpl_vm_->dp_enabled); xbt_free(key); @@ -455,8 +452,10 @@ void MSG_host_del_task(msg_host_t host, msg_task_t task) return; char *key = bprintf("%s-%p", task->name, task); - dirty_page_t dp = (dirty_page_t)(vm->pimpl_vm_->dp_objs ? xbt_dict_get_or_null(vm->pimpl_vm_->dp_objs, key) : NULL); - xbt_assert(dp->task == task); + dirty_page_t dp = nullptr; + if (vm->pimpl_vm_->dp_objs.find(key) != vm->pimpl_vm_->dp_objs.end()) + dp = vm->pimpl_vm_->dp_objs.at(key); + xbt_assert(dp && dp->task == task); /* If we are in the middle of dirty page tracking, we record how much computation has been done until now, and keep * the information for the lookup_() function that will called soon. */ @@ -468,8 +467,8 @@ void MSG_host_del_task(msg_host_t host, msg_task_t task) vm->pimpl_vm_->dp_updated_by_deleted_tasks += updated; } - if (vm->pimpl_vm_->dp_objs) - xbt_dict_remove(vm->pimpl_vm_->dp_objs, key); + + vm->pimpl_vm_->dp_objs.erase(key); xbt_free(dp); XBT_DEBUG("del %s on %s", key, host->getCname()); @@ -756,15 +755,9 @@ void MSG_vm_migrate(msg_vm_t vm, msg_host_t dst_pm) char *pr_rx_name = get_mig_process_rx_name(vm, src_pm, dst_pm); char *pr_tx_name = get_mig_process_tx_name(vm, src_pm, dst_pm); - char** argv = xbt_new(char*, 2); - argv[0] = pr_rx_name; - argv[1] = nullptr; - MSG_process_create_with_arguments(pr_rx_name, migration_rx_fun, ms, dst_pm, 1, argv); + MSG_process_create(pr_rx_name, migration_rx_fun, ms, dst_pm); - argv = xbt_new(char*, 2); - argv[0] = pr_tx_name; - argv[1] = nullptr; - MSG_process_create_with_arguments(pr_tx_name, migration_tx_fun, ms, src_pm, 1, argv); + MSG_process_create(pr_tx_name, migration_tx_fun, ms, src_pm); /* wait until the migration have finished or on error has occurred */ XBT_DEBUG("wait for reception of the final ACK (i.e. migration has been correctly performed"); @@ -816,8 +809,8 @@ void MSG_vm_suspend(msg_vm_t vm) if (TRACE_msg_vm_is_enabled()) { container_t vm_container = PJ_container_get(vm->getCname()); type_t type = PJ_type_get("MSG_VM_STATE", vm_container->type); - val_t value = PJ_value_get_or_new("suspend", "1 0 0", type); // suspend is red - new PushStateEvent(MSG_get_clock(), vm_container, type, value); + value* val = value::get_or_new("suspend", "1 0 0", type); // suspend is red + new PushStateEvent(MSG_get_clock(), vm_container, type, val); } }