p Tracing master/worker application with xml config
$ $SG_TEST_EXENV ${bindir:=.}/trace-masterworker$EXEEXT ${srcdir:=.}/config_tracing.xml ${srcdir:=.}/../msg/app-masterworker/app-masterworker_d.xml
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/uncategorized' to 'yes'
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/buffer' to 'yes'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing' to 'yes'
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'viva/categorized' to 'trace-masterworker.cat.plist'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/buffer' to 'yes'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/categorized' to 'yes'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/filename' to 'trace-masterworker.trace'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/uncategorized' to 'yes'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'viva/categorized' to 'trace-masterworker.cat.plist'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'viva/uncategorized' to 'trace-masterworker.uncat.plist'
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/categorized' to 'yes'
> [4.214821] [msg_trace_masterworker/INFO] Declared tracing categories:
> [4.214821] [msg_trace_masterworker/INFO] request
> [4.214821] [msg_trace_masterworker/INFO] finalize
#ifdef __cplusplus
#include "simgrid/simix.h"
+#include <map>
namespace simgrid {
namespace msg {
class Comm;
XBT_PUBLIC(msg_error_t) MSG_process_join(msg_process_t process, double timeout);
XBT_PUBLIC(msg_error_t) MSG_process_sleep(double nb_sec);
-XBT_PUBLIC(void) MSG_task_set_flops_amount(msg_task_t task,
- double flops_amount);
+XBT_PUBLIC(void) MSG_task_set_flops_amount(msg_task_t task, double flops_amount);
XBT_PUBLIC(double) MSG_task_get_flops_amount(msg_task_t task);
-XBT_PUBLIC(void) MSG_task_set_bytes_amount(msg_task_t task,
- double bytes_amount);
+XBT_PUBLIC(void) MSG_task_set_bytes_amount(msg_task_t task, double bytes_amount);
XBT_PUBLIC(double) MSG_task_get_remaining_communication(msg_task_t task);
XBT_PUBLIC(int) MSG_task_is_latency_bounded(msg_task_t task);
XBT_PUBLIC(double) MSG_task_get_bytes_amount(msg_task_t task);
+XBT_PUBLIC(msg_error_t) MSG_task_receive_ext(msg_task_t* task, const char* alias, double timeout, msg_host_t host);
-XBT_PUBLIC(msg_error_t)
- MSG_task_receive_ext(msg_task_t * task, const char *alias, double timeout,
- msg_host_t host);
-
-XBT_PUBLIC(msg_error_t)
- MSG_task_receive_with_timeout(msg_task_t * task, const char *alias,
- double timeout);
+XBT_PUBLIC(msg_error_t) MSG_task_receive_with_timeout(msg_task_t* task, const char* alias, double timeout);
-XBT_PUBLIC(msg_error_t)
- MSG_task_receive(msg_task_t * task, const char *alias);
+XBT_PUBLIC(msg_error_t) MSG_task_receive(msg_task_t* task, const char* alias);
#define MSG_task_recv(t,a) MSG_task_receive(t,a)
-
-
XBT_PUBLIC(msg_error_t)
- MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, double timeout,
- msg_host_t host, double rate);
+MSG_task_receive_ext_bounded(msg_task_t* task, const char* alias, double timeout, msg_host_t host, double rate);
-XBT_PUBLIC(msg_error_t) MSG_task_receive_with_timeout_bounded(msg_task_t * task, const char *alias, double timeout, double rate);
+XBT_PUBLIC(msg_error_t)
+MSG_task_receive_with_timeout_bounded(msg_task_t* task, const char* alias, double timeout, double rate);
XBT_PUBLIC(msg_error_t) MSG_task_receive_bounded(msg_task_t * task, const char *alias,double rate);
#define MSG_task_recv_bounded(t,a,r) MSG_task_receive_bounded(t,a,r)
XBT_PUBLIC(msg_host_t) MSG_vm_get_pm(msg_vm_t vm);
XBT_PUBLIC(void) MSG_vm_set_bound(msg_vm_t vm, double bound);
-
#include "simgrid/instr.h"
/* ****************************************************************************************** */
/* Used only by the bindings -- unclean pimple, please ignore if you're not writing a binding */
XBT_PUBLIC(smx_context_t) MSG_process_get_smx_ctx(msg_process_t process);
-
/* Functions renamed in 3.14 */
#define MSG_mailbox_get_head(m) MSG_mailbox_front(m)
-
SG_END_DECL()
#ifdef __cplusplus
XBT_PUBLIC(msg_process_t)
MSG_process_create_from_stdfunc(const char* name, std::function<void()> code, void* data, msg_host_t host,
- xbt_dict_t properties);
+ std::map<std::string, std::string>* properties);
#endif
#endif
#ifndef SIMGRID_S4U_HOST_HPP
#define SIMGRID_S4U_HOST_HPP
+#include <map>
#include <string>
#include <unordered_map>
double getSpeed();
int getCoreCount();
- std::unordered_map<std::string, std::string>* getProperties();
+ std::map<std::string, std::string>* getProperties();
const char* getProperty(const char* key);
- void setProperty(const char* key, const char* value);
+ void setProperty(std::string key, std::string value);
void getProcesses(std::vector<ActorPtr> * list);
double getPstateSpeed(int pstate_index);
int getPstatesCount() const;
sg_size_t getSizeFree();
sg_size_t getSizeUsed();
- std::unordered_map<std::string, std::string>* getProperties();
+ std::map<std::string, std::string>* getProperties();
const char* getProperty(const char* key);
void setProperty(const char* key, const char* value);
std::map<std::string, sg_size_t>* getContent();
#include "simgrid/host.h"
#include "xbt/ex.h"
#include "xbt/parmap.h"
-
+#include <map>
/* ******************************** Host ************************************ */
/** @brief Host datatype
@ingroup simix_host_management
*/
XBT_PUBLIC(void) SIMIX_maestro_create(void (*code)(void*), void* data);
-XBT_PUBLIC(smx_actor_t) SIMIX_process_attach(
- const char* name,
- void *data,
- const char* hostname,
- xbt_dict_t properties,
- smx_actor_t parent_process);
+XBT_PUBLIC(smx_actor_t)
+SIMIX_process_attach(const char* name, void* data, const char* hostname, std::map<std::string, std::string>* properties,
+ smx_actor_t parent_process);
XBT_PUBLIC(void) SIMIX_process_detach();
/*********************************** Host *************************************/
/* Constructor and Destructor */
XBT_PUBLIC(smx_actor_t)
simcall_process_create(const char* name, xbt_main_func_t code, void* data, sg_host_t host, int argc, char** argv,
- xbt_dict_t properties);
+ std::map<std::string, std::string>* properties);
XBT_PUBLIC(void) simcall_process_kill(smx_actor_t process);
XBT_PUBLIC(void) simcall_process_killall(int reset_pid);
/* Getters and Setters */
XBT_PUBLIC(int) simcall_process_count();
XBT_PUBLIC(void) simcall_process_set_data(smx_actor_t process, void *data);
-XBT_PUBLIC(xbt_dict_t) simcall_process_get_properties(smx_actor_t host);
XBT_PUBLIC(void) simcall_process_set_kill_time(smx_actor_t process, double kill_time);
XBT_PUBLIC(void) simcall_process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_t fun, void *data);
XBT_PUBLIC(void) simcall_process_join(smx_actor_t process, double timeout);
#ifndef SIMGRID_SIMIX_HPP
#define SIMGRID_SIMIX_HPP
-//#include <xbt/function_types.h>
-#include <xbt/future.hpp>
+#include <simgrid/simix.h>
#include <xbt/functional.hpp>
+#include <xbt/future.hpp>
#include <xbt/signal.hpp>
-#include <simgrid/simix.h>
+#include <map>
+#include <string>
XBT_PUBLIC(void) simcall_run_kernel(std::function<void()> const& code);
* void *data: data a pointer to any data one may want to attach to the new object.
* sg_host_t host: the location where the new process is executed
* int argc, char **argv: parameters passed to code
- * xbt_dict_t pros: properties
+ * std::map<std::string, std::string>* props: properties
*/
-typedef smx_actor_t (*smx_creation_func_t) (
- /* name */ const char*,
- std::function<void()> code,
- /* userdata */ void*,
- /* hostname */ sg_host_t,
- /* props */ xbt_dict_t,
- /* parent_process */ smx_actor_t);
+typedef smx_actor_t (*smx_creation_func_t)(
+ /* name */ const char*, std::function<void()> code,
+ /* userdata */ void*,
+ /* hostname */ sg_host_t,
+ /* props */ std::map<std::string, std::string>*,
+ /* parent_process */ smx_actor_t);
extern "C"
XBT_PUBLIC(void) SIMIX_function_register_process_create(smx_creation_func_t function);
XBT_PUBLIC(smx_actor_t)
-simcall_process_create(const char* name, std::function<void()> code, void* data, sg_host_t host, xbt_dict_t properties);
+simcall_process_create(const char* name, std::function<void()> code, void* data, sg_host_t host,
+ std::map<std::string, std::string>* properties);
XBT_PUBLIC(smx_timer_t) SIMIX_timer_set(double date, simgrid::xbt::Task<void()> callback);
#include "simgrid/datatypes.h"
#include "simgrid/forward.h"
-
#ifdef __cplusplus
namespace simgrid {
*/
XBT_PUBLIC(void) surf_exit();
-/* Prototypes of the functions that handle the properties */
-XBT_PUBLIC_DATA(xbt_dict_t) current_property_set;// the prop set for the currently parsed element (also used in SIMIX)
-
/* surf parse file related (public because called from a test suite) */
XBT_PUBLIC(void) parse_platform_file(const char *file);
}
simgrid::s4u::Host* NetZoneImpl::createHost(const char* name, std::vector<double>* speedPerPstate, int coreAmount,
- std::unordered_map<std::string, std::string>* props)
+ std::map<std::string, std::string>* props)
{
simgrid::s4u::Host* res = new simgrid::s4u::Host(name);
if (props != nullptr)
for (auto kv : *props)
- res->setProperty(kv.first.c_str(), kv.second.c_str());
+ res->setProperty(kv.first, kv.second);
simgrid::s4u::Host::onCreation(*res); // notify the signal
public:
/** @brief Make an host within that NetZone */
simgrid::s4u::Host* createHost(const char* name, std::vector<double>* speedPerPstate, int coreAmount,
- std::unordered_map<std::string, std::string>* props);
+ std::map<std::string, std::string>* props);
/** @brief Creates a new route in this NetZone */
void addBypassRoute(sg_platf_route_cbarg_t e_route) override;
{
xbt_assert((host != nullptr), "Invalid parameters (host is nullptr)");
xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f);
- std::unordered_map<std::string, std::string>* props = host->getProperties();
+ std::map<std::string, std::string>* props = host->getProperties();
if (props == nullptr)
return nullptr;
for (auto elm : *props) {
{
xbt_assert((storage != nullptr), "Invalid parameters (storage is nullptr)");
xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f);
- std::unordered_map<std::string, std::string>* props = storage->getProperties();
+ std::map<std::string, std::string>* props = storage->getProperties();
if (props == nullptr)
return nullptr;
for (auto elm : *props) {
/*************************************************************/
XBT_PRIVATE void MSG_process_cleanup_from_SIMIX(smx_actor_t smx_proc);
XBT_PRIVATE smx_actor_t MSG_process_create_from_SIMIX(const char* name, std::function<void()> code, void* data,
- sg_host_t host, xbt_dict_t properties,
+ sg_host_t host, std::map<std::string, std::string>* properties,
smx_actor_t parent_process);
XBT_PRIVATE void MSG_comm_copy_data_from_SIMIX(smx_activity_t comm, void* buff, size_t buff_size);
/* This function creates a MSG process. It has the prototype enforced by SIMIX_function_register_process_create */
smx_actor_t MSG_process_create_from_SIMIX(const char* name, std::function<void()> code, void* data, sg_host_t host,
- xbt_dict_t properties, smx_actor_t parent_process)
+ std::map<std::string, std::string>* properties, smx_actor_t parent_process)
{
msg_process_t p = MSG_process_create_from_stdfunc(name, std::move(code), data, host, properties);
return p == nullptr ? nullptr : p->getImpl();
if (code)
function = simgrid::xbt::wrapMain(code, argc, static_cast<const char* const*>(argv));
- msg_process_t res = MSG_process_create_from_stdfunc(name, std::move(function), data, host, properties);
+ std::map<std::string, std::string> props;
+ xbt_dict_cursor_t cursor = nullptr;
+ char* key;
+ char* value;
+ xbt_dict_foreach (properties, cursor, key, value)
+ props[key] = value;
+ xbt_dict_free(&properties);
+
+ msg_process_t res = MSG_process_create_from_stdfunc(name, std::move(function), data, host, &props);
for (int i = 0; i != argc; ++i)
xbt_free(argv[i]);
xbt_free(argv);
SG_END_DECL()
msg_process_t MSG_process_create_from_stdfunc(const char* name, std::function<void()> code, void* data, msg_host_t host,
- xbt_dict_t properties)
+ std::map<std::string, std::string>* properties)
{
xbt_assert(code != nullptr && host != nullptr, "Invalid parameters: host and code params must not be nullptr");
simgrid::msg::ActorExt* msgExt = new simgrid::msg::ActorExt(data);
msg_process_t MSG_process_attach(const char *name, void *data, msg_host_t host, xbt_dict_t properties)
{
xbt_assert(host != nullptr, "Invalid parameters: host and code params must not be nullptr");
+ std::map<std::string, std::string> props;
+ xbt_dict_cursor_t cursor = nullptr;
+ char* key;
+ char* value;
+ xbt_dict_foreach (properties, cursor, key, value)
+ props[key] = value;
+ xbt_dict_free(&properties);
/* Let's create the process: SIMIX may decide to start it right now, even before returning the flow control to us */
- smx_actor_t process =
- SIMIX_process_attach(name, new simgrid::msg::ActorExt(data), host->getCname(), properties, nullptr);
+ smx_actor_t process = SIMIX_process_attach(name, new simgrid::msg::ActorExt(data), host->getCname(), &props, nullptr);
if (not process)
xbt_die("Could not attach");
simcall_process_on_exit(process,(int_f_pvoid_pvoid_t)TRACE_msg_process_kill,process);
*/
const char *MSG_process_get_property_value(msg_process_t process, const char *name)
{
- return (char*) xbt_dict_get_or_null(MSG_process_get_properties(process), name);
+ return process->getProperty(name);
}
/** \ingroup m_process_management
xbt_dict_t MSG_process_get_properties(msg_process_t process)
{
xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
- return simcall_process_get_properties(process->getImpl());
+ xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f);
+ std::map<std::string, std::string>* props =
+ simgrid::simix::kernelImmediate([process] { return process->getImpl()->getProperties(); });
+ if (props == nullptr)
+ return nullptr;
+ for (auto elm : *props) {
+ xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str()), nullptr);
+ }
+ return as_dict;
}
/** \ingroup m_process_management
/** Retrieve the property value (or nullptr if not set) */
const char* Actor::getProperty(const char* key)
{
- return (char*)xbt_dict_get_or_null(simcall_process_get_properties(pimpl_), key);
+ return simgrid::simix::kernelImmediate([this, key] { return pimpl_->getProperty(key); });
}
void Actor::setProperty(const char* key, const char* value)
{
- simgrid::simix::kernelImmediate([this, key, value] {
- xbt_dict_set(simcall_process_get_properties(pimpl_), key, (char*)value, (void_f_pvoid_t) nullptr);
- });
+ simgrid::simix::kernelImmediate([this, key, value] { pimpl_->setProperty(key, value); });
}
Actor* Actor::restart()
}
/** Get the properties assigned to a host */
-std::unordered_map<std::string, std::string>* Host::getProperties()
+std::map<std::string, std::string>* Host::getProperties()
{
- return simgrid::simix::kernelImmediate([this] {
- return this->pimpl_->getProperties();
- });
+ return simgrid::simix::kernelImmediate([this] { return this->pimpl_->getProperties(); });
}
/** Retrieve the property value (or nullptr if not set) */
return this->pimpl_->getProperty(key);
}
-void Host::setProperty(const char* key, const char* value)
+void Host::setProperty(std::string key, std::string value)
{
simgrid::simix::kernelImmediate([this, key, value] { this->pimpl_->setProperty(key, value); });
}
return pimpl_->getSize();
}
-std::unordered_map<std::string, std::string>* Storage::getProperties()
+std::map<std::string, std::string>* Storage::getProperties()
{
return simgrid::simix::kernelImmediate([this] { return pimpl_->getProperties(); });
}
/** @brief Get the properties of an host */
xbt_dict_t sg_host_get_properties(sg_host_t host) {
xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f);
- std::unordered_map<std::string, std::string>* props = host->getProperties();
+ std::map<std::string, std::string>* props = host->getProperties();
if (props == nullptr)
return nullptr;
for (auto elm : *props) {
XBT_INFO("Displaying host %s", host->getCname());
XBT_INFO(" - speed: %.0f", host->getSpeed());
XBT_INFO(" - available speed: %.2f", sg_host_get_available_speed(host));
- std::unordered_map<std::string, std::string>* props = host->getProperties();
+ std::map<std::string, std::string>* props = host->getProperties();
if (not props->empty()) {
XBT_INFO(" - properties:");
#include <exception>
#include <functional>
+#include <map>
#include <string>
#include <utility>
#include <boost/range/algorithm.hpp>
-#include "xbt/dict.h"
#include "xbt/ex.hpp"
#include "xbt/functional.hpp"
#include "xbt/log.h"
ActorImpl::~ActorImpl()
{
delete this->context;
- xbt_dict_free(&this->properties);
}
static int dying_daemon(void* exit_status, void* data)
* \return the process created
*/
smx_actor_t SIMIX_process_create(const char* name, std::function<void()> code, void* data, simgrid::s4u::Host* host,
- xbt_dict_t properties, smx_actor_t parent_process)
+ std::map<std::string, std::string>* properties, smx_actor_t parent_process)
{
XBT_DEBUG("Start process %s on host '%s'", name, host->getCname());
process->context = SIMIX_context_new(std::move(code), simix_global->cleanup_process_function, process);
/* Add properties */
- process->properties = properties;
+ if (properties != nullptr)
+ for (auto kv : *properties)
+ process->setProperty(kv.first, kv.second);
/* Make sure that the process is initialized for simix, in case we are called from the Host::onCreation signal */
if (host->extension<simgrid::simix::Host>() == nullptr)
return process;
}
-smx_actor_t SIMIX_process_attach(const char* name, void* data, const char* hostname, xbt_dict_t properties,
- smx_actor_t parent_process)
+smx_actor_t SIMIX_process_attach(const char* name, void* data, const char* hostname,
+ std::map<std::string, std::string>* properties, smx_actor_t parent_process)
{
// This is mostly a copy/paste from SIMIX_process_new(),
// it'd be nice to share some code between those two functions.
XBT_DEBUG("Attach process %s on host '%s'", name, hostname);
if (host->isOff()) {
- XBT_WARN("Cannot launch process '%s' on failed host '%s'",
- name, hostname);
+ XBT_WARN("Cannot launch process '%s' on failed host '%s'", name, hostname);
return nullptr;
}
process->context = simix_global->context_factory->attach(simix_global->cleanup_process_function, process);
/* Add properties */
- process->properties = properties;
+ if (properties != nullptr)
+ for (auto kv : *properties)
+ process->setProperty(kv.first, kv.second);
/* Add the process to it's host process list */
xbt_swag_insert(process, host->extension<simgrid::simix::Host>()->process_list);
/* Add the process to the list of process to restart, only if the host is down */
if (self->auto_restart && self->host->isOff()) {
SIMIX_host_add_auto_restart_process(self->host, self->cname(), self->code, self->userdata,
- SIMIX_timer_get_date(self->kill_timer), self->properties, self->auto_restart);
+ SIMIX_timer_get_date(self->kill_timer), self->getProperties(),
+ self->auto_restart);
}
XBT_DEBUG("Process %s@%s is dead", self->cname(), self->host->getCname());
self->context->stop();
* \param properties the properties of the process
* \param auto_restart either it is autorestarting or not.
*/
-extern "C"
-smx_actor_t simcall_process_create(const char* name, xbt_main_func_t code, void* data, sg_host_t host, int argc,
- char** argv, xbt_dict_t properties)
+extern "C" smx_actor_t simcall_process_create(const char* name, xbt_main_func_t code, void* data, sg_host_t host,
+ int argc, char** argv, std::map<std::string, std::string>* properties)
{
if (name == nullptr)
name = "";
}
smx_actor_t simcall_process_create(const char* name, std::function<void()> code, void* data, sg_host_t host,
- xbt_dict_t properties)
+ std::map<std::string, std::string>* properties)
{
if (name == nullptr)
name = "";
#include "simgrid/s4u/Actor.hpp"
#include "src/simix/popping_private.h"
+#include "src/surf/PropertyHolder.hpp"
#include "xbt/swag.h"
#include <list>
+#include <map>
typedef struct s_smx_process_exit_fun {
int_f_pvoid_pvoid_t fun;
void *data = nullptr;
sg_host_t host = nullptr;
double kill_time = 0.0;
- xbt_dict_t properties = nullptr;
+ std::map<std::string, std::string>* properties = nullptr;
bool auto_restart = false;
};
-class ActorImpl {
+class ActorImpl : public simgrid::surf::PropertyHolder {
public:
ActorImpl() : piface_(this) {}
~ActorImpl();
sg_host_t new_host = nullptr; /* if not null, the host on which the process must migrate to */
smx_activity_t waiting_synchro = nullptr; /* the current blocking synchro if any */
std::list<smx_activity_t> comms; /* the current non-blocking communication synchros */
- xbt_dict_t properties = nullptr;
s_smx_simcall_t simcall;
void* userdata = nullptr; /* kept for compatibility, it should be replaced with moddata */
std::vector<s_smx_process_exit_fun_t> on_exit; /* list of functions executed when the process dies */
SG_BEGIN_DECL()
-XBT_PRIVATE smx_actor_t SIMIX_process_create(
- const char *name,
- std::function<void()> code,
- void *data,
- sg_host_t host,
- xbt_dict_t properties,
- smx_actor_t parent_process);
+XBT_PRIVATE smx_actor_t SIMIX_process_create(const char* name, std::function<void()> code, void* data, sg_host_t host,
+ std::map<std::string, std::string>* properties,
+ smx_actor_t parent_process);
XBT_PRIVATE void SIMIX_process_runall();
XBT_PRIVATE void SIMIX_process_kill(smx_actor_t process, smx_actor_t issuer);
});
}
-/**
- * \ingroup simix_process_management
- * \brief Return the properties
- *
- * This function returns the properties associated with this process
- */
-xbt_dict_t simcall_process_get_properties(smx_actor_t process)
-{
- return process->properties;
-}
/**
* \ingroup simix_process_management
* \brief Add an on_exit function
* The processes will only be restarted once, meaning that you will have to register the process
* again to restart the process again.
*/
-void SIMIX_host_add_auto_restart_process(
- sg_host_t host, const char *name, std::function<void()> code,
- void* data, double kill_time, xbt_dict_t properties, int auto_restart)
+void SIMIX_host_add_auto_restart_process(sg_host_t host, const char* name, std::function<void()> code, void* data,
+ double kill_time, std::map<std::string, std::string>* properties,
+ int auto_restart)
{
smx_process_arg_t arg = new simgrid::simix::ProcessArg();
arg->name = name;
#ifndef SIMIX_HOST_PRIVATE_H
#define SIMIX_HOST_PRIVATE_H
-#include <vector>
#include <functional>
+#include <map>
+#include <vector>
#include <xbt/base.h>
#include <xbt/Extendable.hpp>
}
SG_BEGIN_DECL()
-XBT_PRIVATE void SIMIX_host_add_auto_restart_process(sg_host_t host,
- const char *name,
- std::function<void()> code,
- void *data,
- double kill_time,
- xbt_dict_t properties,
- int auto_restart);
+XBT_PRIVATE void SIMIX_host_add_auto_restart_process(sg_host_t host, const char* name, std::function<void()> code,
+ void* data, double kill_time,
+ std::map<std::string, std::string>* properties, int auto_restart);
XBT_PRIVATE void SIMIX_host_autorestart(sg_host_t host);
XBT_PRIVATE void SIMIX_execution_cancel(smx_activity_t synchro);
namespace simgrid {
namespace surf {
-PropertyHolder::PropertyHolder() = default;
-
PropertyHolder::~PropertyHolder() {
delete properties_;
}
}
/** @brief Change the value of a given key in the property set */
-void PropertyHolder::setProperty(const char*key, const char*value) {
+void PropertyHolder::setProperty(std::string key, std::string value)
+{
if (not properties_)
- properties_ = new std::unordered_map<std::string, std::string>;
+ properties_ = new std::map<std::string, std::string>;
(*properties_)[key] = value;
}
/** @brief Return the whole set of properties. Don't mess with it, dude! */
-std::unordered_map<std::string, std::string>* PropertyHolder::getProperties()
+std::map<std::string, std::string>* PropertyHolder::getProperties()
{
if (not properties_)
- properties_ = new std::unordered_map<std::string, std::string>;
+ properties_ = new std::map<std::string, std::string>;
return properties_;
}
#ifndef SRC_SURF_PROPERTYHOLDER_HPP_
#define SRC_SURF_PROPERTYHOLDER_HPP_
-#include <unordered_map>
+#include <map>
namespace simgrid {
namespace surf {
class PropertyHolder { // DO NOT DERIVE THIS CLASS, or the diamond inheritance mayhem will get you
public:
- explicit PropertyHolder();
+ PropertyHolder() = default;
~PropertyHolder();
const char *getProperty(const char*id);
- void setProperty(const char*id, const char*value);
+ void setProperty(std::string id, std::string value);
/* FIXME: This should not be exposed, as users may do bad things with the dict they got (it's not a copy).
* But some user API expose this call so removing it is not so easy.
*/
- std::unordered_map<std::string, std::string>* getProperties();
+ std::map<std::string, std::string>* getProperties();
private:
- std::unordered_map<std::string, std::string>* properties_ = nullptr;
+ std::map<std::string, std::string>* properties_ = nullptr;
};
} /* namespace surf */
std::string id;
std::string model;
std::string content;
- xbt_dict_t properties;
+ std::map<std::string, std::string>* properties;
std::map<std::string, std::string>* model_properties;
sg_size_t size;
- StorageType(std::string id, std::string model, std::string content, xbt_dict_t properties,
+ StorageType(std::string id, std::string model, std::string content, std::map<std::string, std::string>* properties,
std::map<std::string, std::string>* model_properties, sg_size_t size)
: id(id), model(model), content(content), properties(properties), model_properties(model_properties), size(size)
{
/** @brief Add an host to the current AS */
void sg_platf_new_host(sg_platf_host_cbarg_t args)
{
- std::unordered_map<std::string, std::string> props;
+ std::map<std::string, std::string> props;
if (args->properties) {
- xbt_dict_cursor_t cursor=nullptr;
- char *key;
- char* data;
- xbt_dict_foreach (args->properties, cursor, key, data)
- props[key] = data;
- xbt_dict_free(&args->properties);
+ for (auto elm : *args->properties)
+ props.insert({elm.first, elm.second});
+ delete args->properties;
}
simgrid::s4u::Host* host =
surf_network_model->createLink(link_name.c_str(), link->bandwidth, link->latency, link->policy);
if (link->properties) {
- xbt_dict_cursor_t cursor = nullptr;
- char* key;
- char* data;
- xbt_dict_foreach (link->properties, cursor, key, data)
- l->setProperty(key, data);
- xbt_dict_free(&link->properties);
+ for (auto elm : *link->properties)
+ l->setProperty(elm.first, elm.second);
+ delete link->properties;
}
if (link->latency_trace)
s_sg_platf_host_cbarg_t host;
memset(&host, 0, sizeof(host));
host.id = host_id;
- if ((cluster->properties != nullptr) && (not xbt_dict_is_empty(cluster->properties))) {
- xbt_dict_cursor_t cursor=nullptr;
- char *key;
- char* data;
- host.properties = xbt_dict_new_homogeneous(free);
-
- xbt_dict_foreach(cluster->properties,cursor,key,data) {
- xbt_dict_set(host.properties, key, xbt_strdup(data), nullptr);
- }
+ if ((cluster->properties != nullptr) && (not cluster->properties->empty())) {
+ host.properties = new std::map<std::string, std::string>;
+
+ for (auto elm : *cluster->properties)
+ host.properties->insert({elm.first, elm.second});
}
host.speed_per_pstate = cluster->speeds;
xbt_free(host_id);
rankId++;
}
- xbt_dict_free(&cluster->properties);
+ delete cluster->properties;
// Add a router.
XBT_DEBUG(" ");
auto s = surf_storage_model->createStorage(storage->id, stype->id, storage->content, storage->attach);
if (storage->properties) {
- xbt_dict_cursor_t cursor = nullptr;
- char *key;
- char* data;
- xbt_dict_foreach (storage->properties, cursor, key, data)
- s->setProperty(key, data);
- xbt_dict_free(&storage->properties);
+ for (auto elm : *storage->properties)
+ s->setProperty(elm.first, elm.second);
+ delete storage->properties;
}
}
sg_link_exit();
for (auto e : storage_types) {
simgrid::surf::StorageType* stype = e.second;
- xbt_dict_free(&(stype->properties));
+ delete stype->properties;
delete stype->model_properties;
delete stype;
}
tmgr_trace_t speed_trace;
tmgr_trace_t state_trace;
const char* coord;
- xbt_dict_t properties;
+ std::map<std::string, std::string>* properties;
} s_sg_platf_host_cbarg_t;
typedef s_sg_platf_host_cbarg_t* sg_platf_host_cbarg_t;
tmgr_trace_t latency_trace = nullptr;
tmgr_trace_t state_trace = nullptr;
e_surf_link_sharing_policy_t policy = SURF_LINK_FATPIPE;
- xbt_dict_t properties = nullptr;
+ std::map<std::string, std::string>* properties = nullptr;
};
class PeerCreationArgs {
double limiter_link;
e_surf_cluster_topology_t topology;
const char* topo_parameters;
- xbt_dict_t properties;
+ std::map<std::string, std::string>* properties;
const char* router_id;
e_surf_link_sharing_policy_t sharing_policy;
e_surf_link_sharing_policy_t bb_sharing_policy;
std::string id;
std::string type_id;
std::string content;
- xbt_dict_t properties;
+ std::map<std::string, std::string>* properties;
std::string attach;
};
std::string id;
std::string model;
std::string content;
- xbt_dict_t properties;
+ std::map<std::string, std::string>* properties;
std::map<std::string, std::string>* model_properties;
sg_size_t size;
};
typedef struct s_sg_platf_process_cbarg {
const char **argv;
int argc;
- xbt_dict_t properties;
+ std::map<std::string, std::string>* properties;
const char *host;
const char *function;
double start_time;
} s_sg_platf_AS_cbarg_t;
#define SG_PLATF_AS_INITIALIZER {nullptr,0}
+/* The default current property receiver. Setup in the corresponding opening callbacks. */
+extern std::map<std::string, std::string>* current_property_set;
/********** Routing **********/
void routing_cluster_add_backbone(simgrid::surf::LinkImpl* bb);
/* make sure these symbols are defined as strong ones in this file so that the linker can resolve them */
/* The default current property receiver. Setup in the corresponding opening callbacks. */
-xbt_dict_t current_property_set = nullptr;
+std::map<std::string, std::string>* current_property_set = nullptr;
std::map<std::string, std::string>* current_model_property_set = nullptr;
int ZONE_TAG = 0; // Whether we just opened a zone tag (to see what to do with the properties)
simgrid::s4u::NetZone* netzone = simgrid::s4u::Engine::getInstance()->getNetzoneByNameOrNull(A_surfxml_zone_id);
netzone->setProperty(A_surfxml_prop_id, A_surfxml_prop_value);
- }
- else{
+ } else {
if (not current_property_set)
- current_property_set = xbt_dict_new_homogeneous(&xbt_free_f); // Maybe, it should raise an error
- xbt_dict_set(current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), nullptr);
+ current_property_set = new std::map<std::string, std::string>; // Maybe, it should raise an error
+ current_property_set->insert({A_surfxml_prop_id, A_surfxml_prop_value});
XBT_DEBUG("add prop %s=%s into current property set %p", A_surfxml_prop_id, A_surfxml_prop_value,
current_property_set);
}
void ETag_surfxml_config()
{
- xbt_dict_cursor_t cursor = nullptr;
- char *key;
- char *elem;
- xbt_dict_foreach(current_property_set, cursor, key, elem) {
- if (xbt_cfg_is_default_value(key)) {
- std::string cfg = std::string(key) + ":" + elem;
+ for (auto elm : *current_property_set) {
+ if (xbt_cfg_is_default_value(elm.first.c_str())) {
+ std::string cfg = elm.first + ":" + elm.second;
xbt_cfg_set_parse(cfg.c_str());
} else
- XBT_INFO("The custom configuration '%s' is already defined by user!",key);
+ XBT_INFO("The custom configuration '%s' is already defined by user!", elm.first.c_str());
}
XBT_DEBUG("End configuration name = %s",A_surfxml_config_id);
- xbt_dict_free(¤t_property_set);
+ delete current_property_set;
current_property_set = nullptr;
}
static void display_storage_properties(simgrid::s4u::Storage* storage)
{
- std::unordered_map<std::string, std::string>* props = storage->getProperties();
+ std::map<std::string, std::string>* props = storage->getProperties();
if (not props->empty()) {
XBT_INFO("\tProperties of mounted storage: %s", storage->getName());
> Workstation number: 4, link number: 5
$ ${bindir:=.}/basic-parsing-test ../platforms/properties.xml
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'host/model' to 'compound'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'cpu/optim' to 'TI'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'host/model' to 'compound'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '0.000010'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'Vegas'
> Workstation number: 1, link number: 1
$ ${bindir:=.}/basic-parsing-test ../platforms/properties.xml --cfg=cpu/optim:TI
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'cpu/optim' to 'TI'
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'host/model' to 'compound'
> [0.000000] [surf_parse/INFO] The custom configuration 'cpu/optim' is already defined by user!
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'host/model' to 'compound'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '0.000010'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'Vegas'
> Workstation number: 1, link number: 1