The MC is currently broken.
#surf_host_model_init_current_default() or #surf_host_model_init_ptask_L07()
to create the platform.
- Then you can access the hosts with the global variables \ref host_lib.
+ Then you can access the hosts with the global variables \ref host_list.
Some functions of the \ref SURF_host_interface and similar can give
you some information about:
- a host: get_speed(), get_available_speed();
--- /dev/null
+/* Copyright (c) 2015. 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. */
+
+#ifndef SIMGRID_HOST_HPP
+#define SIMGRID_HOST_HPP
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include <xbt/base.h>
+#include <xbt/Lib.hpp>
+
+namespace simgrid {
+
+XBT_PUBLIC_CLASS Host : public simgrid::xbt::Lib<Host> {
+private:
+ std::string id_;
+public:
+ Host(std::string id);
+ ~Host();
+ std::string const& id() const { return id_; }
+ static Host* find_host(const char* name);
+ static Host* get_host(const char* name);
+};
+
+}
+
+#endif
#ifdef __cplusplus
+namespace simgrid {
+class Host;
+}
+
namespace simgrid {
namespace surf {
}
}
+typedef simgrid::Host simgrid_Host;
typedef simgrid::surf::Cpu surf_Cpu;
typedef simgrid::surf::RoutingEdge surf_RoutingEdge;
typedef simgrid::surf::As surf_As;
#else
+typedef struct simgrid_Host simgrid_Host;
typedef struct surf_Cpu surf_Cpu;
typedef struct surf_RoutingEdge surf_RoutingEdge;
typedef struct surf_As surf_As;
#endif
+typedef simgrid_Host* sg_host_t;
typedef surf_Cpu *surf_cpu_t;
typedef surf_RoutingEdge *routing_edge_t;
typedef surf_RoutingEdge *sg_routing_edge_t;
typedef surf_As *AS_t;
// Types which are in fact dictelmt:
-
-typedef xbt_dictelm_t sg_host_t;
typedef xbt_dictelm_t sg_storage_t;
-
typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */
typedef void *sg_routing_link_t; /* FIXME:The actual type is model-dependent so use void* instead*/
#ifndef SIMGRID_HOST_H_
#define SIMGRID_HOST_H_
+#include <stddef.h>
+
#include <xbt/dict.h>
#include <xbt/dynar.h>
#include <simgrid/forward.h>
+#ifdef __cplusplus
+#include <simgrid/Host.hpp>
+#endif
+
SG_BEGIN_DECL()
+XBT_PUBLIC(size_t) sg_host_count();
+XBT_PUBLIC(size_t) sg_host_add_level(void(*deleter)(void*));
XBT_PUBLIC(sg_host_t) sg_host_by_name(const char *name);
XBT_PUBLIC(sg_host_t) sg_host_by_name_or_create(const char *name);
-static XBT_INLINE char *sg_host_get_name(sg_host_t host){
- return host->key;
-}
+XBT_PUBLIC(void*) sg_host_get_facet(sg_host_t host, size_t facet);
+XBT_PUBLIC(const char*) sg_host_get_name(sg_host_t host);
XBT_PUBLIC(xbt_dynar_t) sg_hosts_as_dynar(void);
// ========== User Data ==============
resource with computing capabilities</em> and has a <em>name</em>.
@see SD_workstation_management */
-typedef xbt_dictelm_t SD_workstation_t;
+typedef sg_host_t SD_workstation_t;
/** @brief Workstation access mode
@ingroup SD_datatypes_management
SG_BEGIN_DECL()
-XBT_PUBLIC_DATA(xbt_lib_t) host_lib;
+XBT_PUBLIC_DATA(xbt_dict_t) host_list;
XBT_PUBLIC_DATA(int) SURF_HOST_LEVEL; //Surf workstation level
XBT_PUBLIC_DATA(int) SIMIX_STORAGE_LEVEL; //Simix storage level
XBT_PUBLIC_DATA(int) SD_STORAGE_LEVEL; //Simdag storage level
--- /dev/null
+/* Copyright (c) 2015. 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. */
+
+#ifndef SIMGRID_XBT_LIB_HPP
+#define SIMGRID_XBT_LIB_HPP
+
+#include <cstddef>
+
+#include <vector>
+
+namespace simgrid {
+namespace xbt {
+
+template<class T>
+class Lib {
+private:
+ static std::vector<void(*)(void*)> deleters_;
+protected:
+ std::vector<void*> facets_;
+public:
+ static std::size_t add_level(void (*deleter)(void*))
+ {
+ std::size_t res = deleters_.size();
+ deleters_.push_back(deleter);
+ return res;
+ }
+ template<class U> static
+ std::size_t add_level()
+ {
+ return add_level([](void* p){ delete (U*)p; });
+ }
+ Lib() : facets_(deleters_.size(), nullptr) {}
+ ~Lib()
+ {
+ for (std::size_t i = 0; i < facets_.size(); ++i)
+ if (facets_[i] != nullptr)
+ deleters_[i](facets_[i]);
+ }
+
+ // TODO, make type-safe versions of this
+ void* facet(std::size_t level)
+ {
+ if (level >= facets_.size())
+ return nullptr;
+ else
+ return facets_.at(level);
+ }
+ void set_facet(std::size_t level, void* value, bool use_dtor = true)
+ {
+ if (level >= facets_.size())
+ facets_.resize(level + 1, nullptr);
+ void* old_value = this->facet(level);
+ facets_.at(level) = value;
+ if (use_dtor && old_value != nullptr && deleters_[level])
+ deleters_[level](old_value);
+ }
+};
+
+template<class T>
+std::vector<void(*)(void*)> Lib<T>::deleters_ = {};
+
+}
+}
+
+#endif
MSG_init(&argc, argv);
- JAVA_HOST_LEVEL = xbt_lib_add_level(host_lib, (void_f_pvoid_t) __JAVA_host_priv_free);
- JAVA_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, (void_f_pvoid_t) __JAVA_storage_priv_free);
+ JAVA_HOST_LEVEL = simgrid::Host::add_level(__JAVA_host_priv_free);
+ JAVA_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, __JAVA_storage_priv_free);
for (index = 0; index < argc; index++)
free(argv[index]);
/* Cleanup java hosts */
xbt_dynar_t hosts = MSG_hosts_as_dynar();
for (unsigned long index = 0; index < xbt_dynar_length(hosts) - 1; index++) {
- jobject jhost = (jobject) xbt_lib_get_level(xbt_dynar_get_as(hosts,index,msg_host_t), JAVA_HOST_LEVEL);
+ msg_host_t msg_host = xbt_dynar_get_as(hosts,index,msg_host_t);
+ jobject jhost = (jobject) msg_host->facet(JAVA_HOST_LEVEL);
if (jhost)
jhost_unref(env, jhost);
host = xbt_dynar_get_as(table,index,msg_host_t);
- jhost = (jobject) xbt_lib_get_level(host, JAVA_HOST_LEVEL);
+ jhost = (jobject) host->facet(JAVA_HOST_LEVEL);
if (!jhost) {
jname = env->NewStringUTF(MSG_host_get_name(host));
}
env->ReleaseStringUTFChars(jname, name);
- if (!xbt_lib_get_level(host, JAVA_HOST_LEVEL)) { /* native host not associated yet with java host */
+ if (!host->facet(JAVA_HOST_LEVEL)) { /* native host not associated yet with java host */
/* Instantiate a new java host */
jhost = jhost_new_instance(env);
/* the native host data field is set with the global reference to the
* java host returned by this function
*/
- xbt_lib_set(host_lib, host->key, JAVA_HOST_LEVEL, (void *) jhost);
+ host->set_facet(JAVA_HOST_LEVEL, (void *)jhost);
}
/* return the global reference to the java host instance */
- return (jobject) xbt_lib_get_level(host, JAVA_HOST_LEVEL);
+ return (jobject) host->facet(JAVA_HOST_LEVEL);
}
JNIEXPORT jobject JNICALL
msg_host_t host = MSG_host_self();
- if (!xbt_lib_get_level(host, JAVA_HOST_LEVEL)) {
+ if (!host->facet(JAVA_HOST_LEVEL)) {
/* the native host not yet associated with the java host instance */
/* instanciate a new java host instance */
env->SetObjectField(jhost, jhost_field_Host_name, jname);
/* Bind & store it */
jhost_bind(jhost, host, env);
- xbt_lib_set(host_lib, host->key, JAVA_HOST_LEVEL, (void *) jhost);
+ host->set_facet(JAVA_HOST_LEVEL, (void *) jhost);
} else {
- jhost = (jobject) xbt_lib_get_level(host, JAVA_HOST_LEVEL);
+ jhost = (jobject) host->facet(JAVA_HOST_LEVEL);
}
return jhost;
for (index = 0; index < count; index++) {
host = xbt_dynar_get_as(table,index,msg_host_t);
- jhost = (jobject) (xbt_lib_get_level(host, JAVA_HOST_LEVEL));
+ jhost = (jobject) host->facet(JAVA_HOST_LEVEL);
if (!jhost) {
jname = env->NewStringUTF(MSG_host_get_name(host));
if (host == NULL) {
return NULL;
}
- if (!xbt_lib_get_level(host, JAVA_HOST_LEVEL)) {
+ if (!host->facet(JAVA_HOST_LEVEL)) {
jxbt_throw_jni(env, "MSG_task_get_source() failed");
return NULL;
}
- return (jobject) xbt_lib_get_level(host, JAVA_HOST_LEVEL);
+ return (jobject) host->facet(JAVA_HOST_LEVEL);
}
JNIEXPORT jdouble JNICALL
msg_vm_t vm = jvm_get_native(env,jvm);
msg_host_t host = MSG_vm_get_pm(vm);
- if (!xbt_lib_get_level(host, JAVA_HOST_LEVEL)) {
+ if (!host->facet(JAVA_HOST_LEVEL)) {
/* the native host not yet associated with the java host instance */
/* instanciate a new java host instance */
jname);
/* Bind & store it */
jhost_bind(jhost, host, env);
- xbt_lib_set(host_lib, host->key, JAVA_HOST_LEVEL, (void *) jhost);
+ host->set_facet(JAVA_HOST_LEVEL, (void *) jhost);
} else {
- jhost = (jobject) xbt_lib_get_level(host, JAVA_HOST_LEVEL);
+ jhost = (jobject) host->facet(JAVA_HOST_LEVEL);
}
return jhost;
XBT_PUBLIC_DATA(routing_platf_t) routing_platf;
-static inline surf_host_t surf_host_resource_priv(const void *host){
- return (surf_host_t) xbt_lib_get_level((xbt_dictelm_t)host, SURF_HOST_LEVEL);
+static inline surf_host_t surf_host_resource_priv(sg_host_t host)
+{
+ return (surf_host_t) sg_host_get_facet(host, SURF_HOST_LEVEL);
}
static inline void *surf_storage_resource_priv(const void *storage){
return (void*)xbt_lib_get_level((xbt_dictelm_t)storage, SURF_STORAGE_LEVEL);
double rate);
/** @brief Get the route (dynar of sg_link_t) between two hosts */
-XBT_PUBLIC(xbt_dynar_t) surf_host_model_get_route(surf_host_model_t model, surf_resource_t src, surf_resource_t dst);
+XBT_PUBLIC(xbt_dynar_t) surf_host_model_get_route(
+ surf_host_model_t model, sg_host_t src, sg_host_t dst);
/** @brief Create a new VM on the specified host */
-XBT_PUBLIC(void) surf_vm_model_create(const char *name, surf_resource_t host_PM);
+XBT_PUBLIC(void) surf_vm_model_create(const char *name, sg_host_t host_PM);
/** @brief Create a communication between two hosts
*
}
/** @brief Get the speed of the cpu associated to a host */
-XBT_PUBLIC(double) surf_host_get_speed(surf_resource_t resource, double load);
+XBT_PUBLIC(double) surf_host_get_speed(sg_host_t resource, double load);
/** @brief Get the available speed of cpu associated to a host */
-XBT_PUBLIC(double) surf_host_get_available_speed(surf_resource_t host);
+XBT_PUBLIC(double) surf_host_get_available_speed(sg_host_t host);
/** @brief Get the number of cores of the cpu associated to a host */
-XBT_PUBLIC(int) surf_host_get_core(surf_resource_t host);
+XBT_PUBLIC(int) surf_host_get_core(sg_host_t host);
/** @brief Create a computation action on the given host */
-XBT_PUBLIC(surf_action_t) surf_host_execute(surf_resource_t host, double size);
+XBT_PUBLIC(surf_action_t) surf_host_execute(sg_host_t host, double size);
/** @brief Create a sleep action on the given host */
-XBT_PUBLIC(surf_action_t) surf_host_sleep(surf_resource_t host, double duration);
+XBT_PUBLIC(surf_action_t) surf_host_sleep(sg_host_t host, double duration);
/** @brief Create a file opening action on the given host */
-XBT_PUBLIC(surf_action_t) surf_host_open(surf_resource_t host, const char* fullpath);
+XBT_PUBLIC(surf_action_t) surf_host_open(sg_host_t host, const char* fullpath);
/** @brief Create a file closing action on the given host */
-XBT_PUBLIC(surf_action_t) surf_host_close(surf_resource_t host, surf_file_t fd);
+XBT_PUBLIC(surf_action_t) surf_host_close(sg_host_t host, surf_file_t fd);
/** @brief Create a file reading action on the given host */
-XBT_PUBLIC(surf_action_t) surf_host_read(surf_resource_t host, surf_file_t fd, sg_size_t size);
+XBT_PUBLIC(surf_action_t) surf_host_read(sg_host_t host, surf_file_t fd, sg_size_t size);
/** @brief Create a file writing action on the given host */
-XBT_PUBLIC(surf_action_t) surf_host_write(surf_resource_t host, surf_file_t fd, sg_size_t size);
+XBT_PUBLIC(surf_action_t) surf_host_write(sg_host_t host, surf_file_t fd, sg_size_t size);
/**
* @brief Get the informations of a file descriptor
* @param fd The file descriptor
* @return An xbt_dynar_t with the file informations
*/
-XBT_PUBLIC(xbt_dynar_t) surf_host_get_info(surf_resource_t host, surf_file_t fd);
+XBT_PUBLIC(xbt_dynar_t) surf_host_get_info(sg_host_t host, surf_file_t fd);
/**
* @brief Get the available space of the storage at the mount point
* @param name The mount point
* @return The amount of available space in bytes
*/
-XBT_PUBLIC(sg_size_t) surf_host_get_free_size(surf_resource_t resource, const char* name);
+XBT_PUBLIC(sg_size_t) surf_host_get_free_size(sg_host_t resource, const char* name);
/**
* @brief Get the used space of the storage at the mount point
* @param name The mount point
* @return The amount of used space in bytes
*/
-XBT_PUBLIC(sg_size_t) surf_host_get_used_size(surf_resource_t resource, const char* name);
+XBT_PUBLIC(sg_size_t) surf_host_get_used_size(sg_host_t resource, const char* name);
/** @brief Get the list of VMs hosted on the host */
-XBT_PUBLIC(xbt_dynar_t) surf_host_get_vms(surf_resource_t resource);
+XBT_PUBLIC(xbt_dynar_t) surf_host_get_vms(sg_host_t resource);
/** @brief Retrieve the params of that VM
* @details You can use fields ramsize and overcommit on a PM, too.
*/
-XBT_PUBLIC(void) surf_host_get_params(surf_resource_t resource, vm_params_t params);
+XBT_PUBLIC(void) surf_host_get_params(sg_host_t resource, vm_params_t params);
/** @brief Sets the params of that VM/PM
* @details You can use fields ramsize and overcommit on a PM, too.
*/
-XBT_PUBLIC(void) surf_host_set_params(surf_resource_t resource, vm_params_t params);
+XBT_PUBLIC(void) surf_host_set_params(sg_host_t resource, vm_params_t params);
/**
* @brief Destroy a VM
*
* @param resource The surf vm
*/
-XBT_PUBLIC(void) surf_vm_destroy(surf_resource_t resource);
+XBT_PUBLIC(void) surf_vm_destroy(sg_host_t resource);
/** @brief Suspend a VM */
-XBT_PUBLIC(void) surf_vm_suspend(surf_resource_t resource);
+XBT_PUBLIC(void) surf_vm_suspend(sg_host_t resource);
/** @brief Resume a VM */
-XBT_PUBLIC(void) surf_vm_resume(surf_resource_t resource);
+XBT_PUBLIC(void) surf_vm_resume(sg_host_t resource);
/**
* @brief Save the VM (Not yet implemented)
*
* @param resource The surf vm
*/
-XBT_PUBLIC(void) surf_vm_save(surf_resource_t resource);
+XBT_PUBLIC(void) surf_vm_save(sg_host_t resource);
/**
* @brief Restore the VM (Not yet implemented)
*
* @param resource The surf vm
*/
-XBT_PUBLIC(void) surf_vm_restore(surf_resource_t resource);
+XBT_PUBLIC(void) surf_vm_restore(sg_host_t resource);
/**
* @brief Migrate the VM to the destination host
* @param resource The surf vm
* @param ind_vm_ws_dest The destination host
*/
-XBT_PUBLIC(void) surf_vm_migrate(surf_resource_t resource, surf_resource_t ind_vm_ws_dest);
+XBT_PUBLIC(void) surf_vm_migrate(sg_host_t resource, sg_host_t ind_vm_ws_dest);
/**
* @brief Get the physical machine hosting the VM
* @param resource The surf vm
* @return The physical machine hosting the VM
*/
-XBT_PUBLIC(surf_resource_t) surf_vm_get_pm(surf_resource_t resource);
+XBT_PUBLIC(sg_host_t) surf_vm_get_pm(sg_host_t resource);
/**
* @brief [brief description]
* @param resource [description]
* @param bound [description]
*/
-XBT_PUBLIC(void) surf_vm_set_bound(surf_resource_t resource, double bound);
+XBT_PUBLIC(void) surf_vm_set_bound(sg_host_t resource, double bound);
/**
* @brief [brief description]
* @param cpu [description]
* @param mask [description]
*/
-XBT_PUBLIC(void) surf_vm_set_affinity(surf_resource_t resource, surf_resource_t cpu, unsigned long mask);
+XBT_PUBLIC(void) surf_vm_set_affinity(sg_host_t resource, sg_host_t cpu, unsigned long mask);
/**
* @brief Execute some quantity of computation
* @param size The value of the processing amount (in flop) needed to process
* @return The surf action corresponding to the processing
*/
-XBT_PUBLIC(surf_action_t) surf_cpu_execute(surf_resource_t cpu, double size);
+XBT_PUBLIC(surf_action_t) surf_cpu_execute(sg_host_t cpu, double size);
/**
* @brief Make the cpu sleep for duration (in seconds)
* @param duration The number of seconds to sleep
* @return The surf action corresponding to the sleeping
*/
-XBT_PUBLIC(surf_action_t) surf_cpu_sleep(surf_resource_t cpu, double duration);
+XBT_PUBLIC(surf_action_t) surf_cpu_sleep(sg_host_t cpu, double duration);
/**
* @brief Get the host power peak
* @param host The surf host
* @return The power peak
*/
-XBT_PUBLIC(double) surf_host_get_current_power_peak(surf_resource_t host);
+XBT_PUBLIC(double) surf_host_get_current_power_peak(sg_host_t host);
/**
* @brief [brief description]
*
* @return [description]
*/
-XBT_PUBLIC(double) surf_host_get_power_peak_at(surf_resource_t host, int pstate_index);
+XBT_PUBLIC(double) surf_host_get_power_peak_at(sg_host_t host, int pstate_index);
/**
* @brief [brief description]
* @param host [description]
* @return [description]
*/
-XBT_PUBLIC(int) surf_host_get_nb_pstates(surf_resource_t host);
+XBT_PUBLIC(int) surf_host_get_nb_pstates(sg_host_t host);
-XBT_PUBLIC(void) surf_host_set_pstate(surf_resource_t host, int pstate_index);
-XBT_PUBLIC(int) surf_host_get_pstate(surf_resource_t host);
-XBT_PUBLIC(double) surf_host_get_wattmin_at(surf_resource_t resource, int pstate);
-XBT_PUBLIC(double) surf_host_get_wattmax_at(surf_resource_t resource, int pstate);
+XBT_PUBLIC(void) surf_host_set_pstate(sg_host_t host, int pstate_index);
+XBT_PUBLIC(int) surf_host_get_pstate(sg_host_t host);
+XBT_PUBLIC(double) surf_host_get_wattmin_at(sg_host_t resource, int pstate);
+XBT_PUBLIC(double) surf_host_get_wattmax_at(sg_host_t resource, int pstate);
/**
* @brief Get the consumed energy (in joules) of an host
* @param host The surf host
* @return The consumed energy
*/
-XBT_PUBLIC(double) surf_host_get_consumed_energy(surf_resource_t host);
+XBT_PUBLIC(double) surf_host_get_consumed_energy(sg_host_t host);
/**
* @brief Get the list of storages mounted on an host
* @param host The surf host
* @return Dictionary of mount point, Storage
*/
-XBT_PUBLIC(xbt_dict_t) surf_host_get_mounted_storage_list(surf_resource_t host);
+XBT_PUBLIC(xbt_dict_t) surf_host_get_mounted_storage_list(sg_host_t host);
/**
* @brief Get the list of storages attached to an host
* @param host The surf host
* @return Dictionary of storage
*/
-XBT_PUBLIC(xbt_dynar_t) surf_host_get_attached_storage_list(surf_resource_t host);
+XBT_PUBLIC(xbt_dynar_t) surf_host_get_attached_storage_list(sg_host_t host);
/**
* @brief Unlink a file descriptor
*
* @return 0 if failed to unlink, 1 otherwise
*/
-XBT_PUBLIC(int) surf_host_unlink(surf_resource_t host, surf_file_t fd);
+XBT_PUBLIC(int) surf_host_unlink(sg_host_t host, surf_file_t fd);
/**
* @brief Get the size of a file on a host
*
* @return The size in bytes of the file
*/
-XBT_PUBLIC(size_t) surf_host_get_size(surf_resource_t host, surf_file_t fd);
+XBT_PUBLIC(size_t) surf_host_get_size(sg_host_t host, surf_file_t fd);
/**
* @brief Get the current position of the file descriptor
* @param fd The file descriptor
* @return The current position of the file descriptor
*/
-XBT_PUBLIC(size_t) surf_host_file_tell(surf_resource_t host, surf_file_t fd);
+XBT_PUBLIC(size_t) surf_host_file_tell(sg_host_t host, surf_file_t fd);
/**
* @brief Move a file to another location on the *same mount point*.
*
* @return MSG_OK if successful, otherwise MSG_TASK_CANCELED
*/
-XBT_PUBLIC(int) surf_host_file_move(surf_resource_t host, surf_file_t fd, const char* fullpath);
+XBT_PUBLIC(int) surf_host_file_move(sg_host_t host, surf_file_t fd, const char* fullpath);
/**
* @brief Set the position indictator assiociated with the file descriptor to a new position
* - SEEK_END: end of the file
* @return MSG_OK if successful, otherwise MSG_TASK_CANCELED
*/
-XBT_PUBLIC(int) surf_host_file_seek(surf_resource_t host,
+XBT_PUBLIC(int) surf_host_file_seek(sg_host_t host,
surf_file_t fd, sg_offset_t offset,
int origin);
* @param cpu [description]
* @param mask [description]
*/
-XBT_PUBLIC(void) surf_cpu_action_set_affinity(surf_action_t action, surf_resource_t cpu, unsigned long mask);
+XBT_PUBLIC(void) surf_cpu_action_set_affinity(surf_action_t action, sg_host_t cpu, unsigned long mask);
/**
* @brief [brief description]
*
* @param resource The surf storage
* @return The host name
+ * may not exist.
*/
XBT_PUBLIC(const char * ) surf_storage_get_host(surf_resource_t resource);
-XBT_PUBLIC(surf_model_t) surf_resource_model(const void *host, int level);
+XBT_PUBLIC(surf_host_model_t) surf_host_get_model(sg_host_t host);
/** @} */
const char* ModelChecker::get_host_name(const char* hostname)
{
+ // FIXME, simgrid::Host
// Lookup the host name in the dictionary (or create it):
xbt_dictelm_t elt = xbt_dict_get_elm_or_null(this->hostnames_, hostname);
if (!elt) {
simgrid::mc::Process* process = &mc_model_checker->process();
+ // FIXME, simgrid::Host
// Currently, smx_host_t = xbt_dictelm_t.
// TODO, add an static_assert on this if switching to C++
// The host name is host->key and the host->key_len==strlen(host->key).
#include "xbt/sysdep.h"
#include "xbt/log.h"
#include "simgrid/simix.h"
+#include "simgrid/Host.hpp"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(msg);
*/
msg_host_t MSG_host_by_name(const char *name)
{
- return (msg_host_t) xbt_lib_get_elm_or_null(host_lib,name);
+ return simgrid::Host::find_host(name);
}
/** \ingroup m_host_management
*/
int MSG_get_host_number(void)
{
- return xbt_lib_length(host_lib);
+ return xbt_dict_length(host_list);
}
#ifdef MSG_USE_DEPRECATED
msg_host_t *MSG_get_host_table(void)
{
- void **array;
- int i = 0;
- xbt_lib_cursor_t cursor;
- char *key;
- void **data;
+ if (xbt_dict_is_empty(host_list))
+ return nullptr;
- if (xbt_lib_length(host_lib) == 0)
- return NULL;
- else
- array = xbt_new0(void *, xbt_lib_length(host_lib));
+ void **array = xbt_new0(void *, xbt_dict_length(host_list));
- xbt_lib_foreach(host_lib, cursor, key, data) {
+ xbt_lib_cursor_t cursor;
+ const char *id;
+ simgrid::Host* host;
+ xbt_dict_foreach(host_list, cursor, id, host)
if(routing_get_network_element_type(key) == SURF_NETWORK_ELEMENT_HOST)
- array[i++] = data[MSG_HOST_LEVEL];
- }
+ array[i++] = host->facet(MSG_HOST_LEVEL);
return (msg_host_t *)array;
}
{
/* make sure the VM of the same name does not exit */
{
- xbt_dictelm_t ind_host_tmp = xbt_lib_get_elm_or_null(host_lib, name);
- if (ind_host_tmp && sg_host_simix(ind_host_tmp) != NULL) {
+ simgrid::Host* ind_host_tmp =
+ (simgrid::Host*) xbt_dict_get_or_null(host_list, name);
+ if (ind_host_tmp != nullptr && sg_host_simix(ind_host_tmp) != nullptr) {
XBT_ERROR("host %s already exits", name);
- return NULL;
+ return nullptr;
}
}
* migration. The names of these mailboxes must not conflict with others. */
static inline char *get_mig_mbox_src_dst(msg_vm_t vm, msg_host_t src_pm, msg_host_t dst_pm)
{
- char *vm_name = sg_host_get_name(vm);
- char *src_pm_name = sg_host_get_name(src_pm);
- char *dst_pm_name = sg_host_get_name(dst_pm);
+ const char *vm_name = sg_host_get_name(vm);
+ const char *src_pm_name = sg_host_get_name(src_pm);
+ const char *dst_pm_name = sg_host_get_name(dst_pm);
return bprintf("__mbox_mig_src_dst:%s(%s-%s)", vm_name, src_pm_name, dst_pm_name);
}
static inline char *get_mig_mbox_ctl(msg_vm_t vm, msg_host_t src_pm, msg_host_t dst_pm)
{
- char *vm_name = sg_host_get_name(vm);
- char *src_pm_name = sg_host_get_name(src_pm);
- char *dst_pm_name = sg_host_get_name(dst_pm);
+ const char *vm_name = sg_host_get_name(vm);
+ const char *src_pm_name = sg_host_get_name(src_pm);
+ const char *dst_pm_name = sg_host_get_name(dst_pm);
return bprintf("__mbox_mig_ctl:%s(%s-%s)", vm_name, src_pm_name, dst_pm_name);
}
static inline char *get_mig_process_tx_name(msg_vm_t vm, msg_host_t src_pm, msg_host_t dst_pm)
{
- char *vm_name = sg_host_get_name(vm);
- char *src_pm_name = sg_host_get_name(src_pm);
- char *dst_pm_name = sg_host_get_name(dst_pm);
+ const char *vm_name = sg_host_get_name(vm);
+ const char *src_pm_name = sg_host_get_name(src_pm);
+ const char *dst_pm_name = sg_host_get_name(dst_pm);
return bprintf("__pr_mig_tx:%s(%s-%s)", vm_name, src_pm_name, dst_pm_name);
}
static inline char *get_mig_process_rx_name(msg_vm_t vm, msg_host_t src_pm, msg_host_t dst_pm)
{
- char *vm_name = sg_host_get_name(vm);
- char *src_pm_name = sg_host_get_name(src_pm);
- char *dst_pm_name = sg_host_get_name(dst_pm);
+ const char *vm_name = sg_host_get_name(vm);
+ const char *src_pm_name = sg_host_get_name(src_pm);
+ const char *dst_pm_name = sg_host_get_name(dst_pm);
return bprintf("__pr_mig_rx:%s(%s-%s)", vm_name, src_pm_name, dst_pm_name);
}
static inline char *get_mig_task_name(msg_vm_t vm, msg_host_t src_pm, msg_host_t dst_pm, int stage)
{
- char *vm_name = sg_host_get_name(vm);
- char *src_pm_name = sg_host_get_name(src_pm);
- char *dst_pm_name = sg_host_get_name(dst_pm);
+ const char *vm_name = sg_host_get_name(vm);
+ const char *src_pm_name = sg_host_get_name(src_pm);
+ const char *dst_pm_name = sg_host_get_name(dst_pm);
return bprintf("__task_mig_stage%d:%s(%s-%s)", stage, vm_name, src_pm_name, dst_pm_name);
}
// Now the VM is running on the new host (the migration is completed) (even if the SRC crash)
msg_host_priv_t priv = sg_host_msg(vm);
priv->is_migrating = 0;
- XBT_DEBUG("VM(%s) moved from PM(%s) to PM(%s)", ms->vm->key, ms->src_pm->key, ms->dst_pm->key);
+ XBT_DEBUG("VM(%s) moved from PM(%s) to PM(%s)",
+ sg_host_get_name(ms->vm), sg_host_get_name(ms->src_pm),
+ sg_host_get_name(ms->dst_pm));
TRACE_msg_vm_change_host(ms->vm, ms->src_pm, ms->dst_pm);
}
// Inform the SRC that the migration has been correctly performed
boost::unordered_map<std::string, Host*> *Host::hosts
= new boost::unordered_map<std::string, Host*>();
-Host::Host(const char*name) {
+Host::Host(const char*name)
+{
p_inferior = sg_host_by_name(name);
if (p_inferior==NULL)
xbt_die("No such host: %s",name); //FIXME: raise an exception
computer = xbt_dynar_new(sizeof(SD_task_t), NULL);
xbt_dict_set(computers, char_performer, computer, NULL);
}
- if(performer < xbt_lib_length(host_lib)){
+ if(performer < xbt_dict_length(host_list)){
/* the wanted computer is available */
SD_task_t *task_test = NULL;
if(order < computer->used)
#include "xbt/dynar.h"
#include "surf/surf.h"
#include "simgrid/sg_config.h"
+#include "simgrid/host.h"
#include "xbt/ex.h"
#include "xbt/log.h"
#include "xbt/str.h"
{
xbt_lib_cursor_t cursor = NULL;
char *name = NULL;
- void **surf_workstation = NULL;
void **surf_storage = NULL;
parse_platform_file(platform_file);
/* now let's create the SD wrappers for workstations, storages and links */
- xbt_lib_foreach(host_lib, cursor, name, surf_workstation){
- if(surf_workstation[SURF_HOST_LEVEL])
- __SD_workstation_create(surf_workstation[SURF_HOST_LEVEL], NULL);
+ {
+ xbt_dict_cursor_t cursor = NULL;
+ simgrid_Host* host = NULL;
+ xbt_dict_foreach(host_list, cursor, name, host){
+ surf_Host* surf_host = (surf_Host*) sg_host_get_facet(host, SURF_HOST_LEVEL);
+ if (surf_host != NULL)
+ __SD_workstation_create(surf_host, NULL);
+ }
}
xbt_lib_foreach(storage_lib, cursor, name, surf_storage) {
*/
SD_workstation_t SD_workstation_get_by_name(const char *name)
{
- return xbt_lib_get_elm_or_null(host_lib, name);
+ return sg_host_by_name(name);
}
/**
*/
int SD_workstation_get_number(void)
{
- return xbt_lib_length(host_lib);
+ return sg_host_count();
}
/**
#include "xbt/dict.h"
#include "simgrid/host.h"
+#include "simgrid/Host.hpp"
#include "surf/surf.h" // routing_get_network_element_type FIXME:killme
-sg_host_t sg_host_by_name(const char *name){
- return xbt_lib_get_elm_or_null(host_lib, name);
+size_t sg_host_count()
+{
+ return xbt_dict_length(host_list);
}
-sg_host_t sg_host_by_name_or_create(const char *name) {
- sg_host_t res = xbt_lib_get_elm_or_null(host_lib, name);
- if (!res) {
- xbt_lib_set(host_lib,name,0,NULL); // Should only create the bucklet with no data added
- res = xbt_lib_get_elm_or_null(host_lib, name);
- }
- return res;
+void* sg_host_get_facet(sg_host_t host, size_t facet)
+{
+ return host->facet(facet);
+}
+
+const char *sg_host_get_name(sg_host_t host)
+{
+ return host->id().c_str();
+}
+
+size_t sg_host_add_level(void(*deleter)(void*))
+{
+ return simgrid::Host::add_level(deleter);
}
-xbt_dynar_t sg_hosts_as_dynar(void) {
- xbt_lib_cursor_t cursor;
- char *key;
- void **data;
+
+sg_host_t sg_host_by_name(const char *name)
+{
+ return simgrid::Host::find_host(name);
+}
+
+sg_host_t sg_host_by_name_or_create(const char *name)
+{
+ return simgrid::Host::get_host(name);
+}
+
+xbt_dynar_t sg_hosts_as_dynar(void)
+{
xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t),NULL);
- xbt_lib_foreach(host_lib, cursor, key, data) {
- if(routing_get_network_element_type(key) == SURF_NETWORK_ELEMENT_HOST) {
- xbt_dictelm_t elm = xbt_dict_cursor_get_elm(cursor);
- xbt_dynar_push(res, &elm);
- }
- }
+ xbt_dict_cursor_t cursor = nullptr;
+ const char* name = nullptr;
+ simgrid::Host* host = nullptr;
+ xbt_dict_foreach(host_list, cursor, name, host)
+ if(routing_get_network_element_type(name) == SURF_NETWORK_ELEMENT_HOST)
+ xbt_dynar_push(res, &host);
return res;
}
delete static_cast<simgrid::surf::RoutingEdge*>(p);
}
-void sg_host_init() {
- MSG_HOST_LEVEL = xbt_lib_add_level(host_lib, (void_f_pvoid_t) __MSG_host_priv_free);
- SD_HOST_LEVEL = xbt_lib_add_level(host_lib,__SD_workstation_destroy);
-
- SIMIX_HOST_LEVEL = xbt_lib_add_level(host_lib,SIMIX_host_destroy);
- SURF_CPU_LEVEL = xbt_lib_add_level(host_lib,surf_cpu_free);
- ROUTING_HOST_LEVEL = xbt_lib_add_level(host_lib,routing_asr_host_free);
- USER_HOST_LEVEL = xbt_lib_add_level(host_lib,NULL);
+void sg_host_init()
+{
+ MSG_HOST_LEVEL = simgrid::Host::add_level([](void *p) {
+ __MSG_host_priv_free((msg_host_priv_t) p);
+ });
+ SD_HOST_LEVEL = simgrid::Host::add_level(__SD_workstation_destroy);
+ SIMIX_HOST_LEVEL = simgrid::Host::add_level(SIMIX_host_destroy);
+ SURF_CPU_LEVEL = simgrid::Host::add_level(surf_cpu_free);
+ ROUTING_HOST_LEVEL = simgrid::Host::add_level(routing_asr_host_free);
+ USER_HOST_LEVEL = simgrid::Host::add_level(NULL);
}
+
// ========== User data Layer ==========
void *sg_host_user(sg_host_t host) {
- return xbt_lib_get_level(host, USER_HOST_LEVEL);
+ return host->facet(USER_HOST_LEVEL);
}
void sg_host_user_set(sg_host_t host, void* userdata) {
- xbt_lib_set(host_lib,host->key,USER_HOST_LEVEL,userdata);
+ host->set_facet(USER_HOST_LEVEL,userdata);
}
void sg_host_user_destroy(sg_host_t host) {
- xbt_lib_unset(host_lib,host->key,USER_HOST_LEVEL,1);
+ host->set_facet(USER_HOST_LEVEL, nullptr);
}
// ========== MSG Layer ==============
msg_host_priv_t sg_host_msg(sg_host_t host) {
- return (msg_host_priv_t) xbt_lib_get_level(host, MSG_HOST_LEVEL);
+ return (msg_host_priv_t) host->facet(MSG_HOST_LEVEL);
}
void sg_host_msg_set(sg_host_t host, msg_host_priv_t smx_host) {
- xbt_lib_set(host_lib,host->key,MSG_HOST_LEVEL,smx_host);
+ host->set_facet(MSG_HOST_LEVEL, smx_host);
}
void sg_host_msg_destroy(sg_host_t host) {
- xbt_lib_unset(host_lib,host->key,MSG_HOST_LEVEL,1);
+ host->set_facet(MSG_HOST_LEVEL, nullptr);
}
// ========== SimDag Layer ==============
SD_workstation_priv_t sg_host_sd(sg_host_t host) {
- return (SD_workstation_priv_t) xbt_lib_get_level(host, SD_HOST_LEVEL);
+ return (SD_workstation_priv_t) host->facet(SD_HOST_LEVEL);
}
void sg_host_sd_set(sg_host_t host, SD_workstation_priv_t smx_host) {
- xbt_lib_set(host_lib,host->key,SD_HOST_LEVEL,smx_host);
+ host->set_facet(SD_HOST_LEVEL, smx_host);
}
void sg_host_sd_destroy(sg_host_t host) {
- xbt_lib_unset(host_lib,host->key,SD_HOST_LEVEL,1);
+ host->set_facet(SD_HOST_LEVEL, nullptr);
}
// ========== Simix layer =============
smx_host_priv_t sg_host_simix(sg_host_t host){
- return (smx_host_priv_t) xbt_lib_get_level(host, SIMIX_HOST_LEVEL);
+ return (smx_host_priv_t) host->facet(SIMIX_HOST_LEVEL);
}
void sg_host_simix_set(sg_host_t host, smx_host_priv_t smx_host) {
- xbt_assert(xbt_lib_get_or_null(host_lib,host->key,SIMIX_HOST_LEVEL) == NULL);
- xbt_lib_set(host_lib,host->key,SIMIX_HOST_LEVEL,smx_host);
+ host->set_facet(SIMIX_HOST_LEVEL, smx_host);
}
void sg_host_simix_destroy(sg_host_t host) {
- xbt_lib_unset(host_lib,host->key,SIMIX_HOST_LEVEL,1);
+ host->set_facet(SIMIX_HOST_LEVEL, nullptr);
}
// ========== SURF CPU ============
surf_cpu_t sg_host_surfcpu(sg_host_t host) {
- return (surf_cpu_t) xbt_lib_get_level(host, SURF_CPU_LEVEL);
+ return (surf_cpu_t) host->facet(SURF_CPU_LEVEL);
}
void sg_host_surfcpu_set(sg_host_t host, surf_cpu_t cpu) {
- xbt_lib_set(host_lib, host->key, SURF_CPU_LEVEL, cpu);
+ host->set_facet(SURF_CPU_LEVEL, cpu);
}
void sg_host_surfcpu_register(sg_host_t host, surf_cpu_t cpu)
{
sg_host_surfcpu_set(host, cpu);
}
void sg_host_surfcpu_destroy(sg_host_t host) {
- xbt_lib_unset(host_lib,host->key,SURF_CPU_LEVEL,1);
+ host->set_facet(SURF_CPU_LEVEL, nullptr);
}
// ========== RoutingEdge ============
surf_RoutingEdge *sg_host_edge(sg_host_t host) {
- return (surf_RoutingEdge*) xbt_lib_get_level(host, ROUTING_HOST_LEVEL);
+ return (surf_RoutingEdge*) host->facet(ROUTING_HOST_LEVEL);
}
void sg_host_edge_set(sg_host_t host, surf_RoutingEdge *edge) {
- xbt_lib_set(host_lib, host->key, ROUTING_HOST_LEVEL, edge);
+ host->set_facet(ROUTING_HOST_LEVEL, edge);
}
void sg_host_edge_destroy(sg_host_t host, int do_callback) {
- xbt_lib_unset(host_lib,host->key,ROUTING_HOST_LEVEL,do_callback);
+ host->set_facet(ROUTING_HOST_LEVEL, nullptr, do_callback);
}
-
// =========== user-level functions ===============
// ================================================
double sg_host_get_speed(sg_host_t host){
int sg_host_get_pstate(sg_host_t host) {
return surf_host_get_pstate(host);
}
+
+namespace simgrid {
+
+Host::Host(std::string id)
+ : id_(std::move(id))
+{
+}
+
+Host::~Host()
+{
+}
+
+Host* Host::find_host(const char* name)
+{
+ return (Host*) xbt_dict_get_or_null(host_list, name);
+}
+
+Host* Host::get_host(const char* name)
+{
+ Host* host = find_host(name);
+ if (host == nullptr) {
+ host = new Host(name);
+ xbt_dict_set(host_list, name, host, NULL);
+ }
+ return host;
+}
+
+}
int val = xbt_cfg_get_boolean(_sg_cfg_set, name);
if (val) {
if (!already_set) {
- COORD_HOST_LEVEL = xbt_lib_add_level(host_lib,xbt_dynar_free_voidp);
+ COORD_HOST_LEVEL = sg_host_add_level(xbt_dynar_free_voidp);
COORD_ASR_LEVEL = xbt_lib_add_level(as_router_lib,xbt_dynar_free_voidp);
}
already_set = 1;
/* FIXME: what happens if host_list contains VMs and PMs. If
* execute_parallel_task() does not change the state of the model, we can mix
* them. */
- surf_model_t ws_model = surf_resource_model(host_list[0], SURF_HOST_LEVEL);
+ surf_host_model_t ws_model = surf_host_get_model(host_list[0]);
for (i = 1; i < host_nb; i++) {
- surf_model_t ws_model_tmp = surf_resource_model(host_list[i], SURF_HOST_LEVEL);
+ surf_host_model_t ws_model_tmp = surf_host_get_model(host_list[0]);
if (ws_model_tmp != ws_model) {
XBT_CRITICAL("mixing VMs and PMs is not supported");
DIE_IMPOSSIBLE;
}
if (pm_overcommit) {
- XBT_INFO("%s allows memory overcommit.", pm->key);
+ XBT_INFO("%s allows memory overcommit.", sg_host_get_name(pm));
return 1;
}
if (vm_ramsize > pm_ramsize - total_ramsize_of_vms) {
XBT_WARN("cannnot start %s@%s due to memory shortage: vm_ramsize %ld, free %ld, pm_ramsize %ld (bytes).",
- vm->key, pm->key, vm_ramsize, pm_ramsize - total_ramsize_of_vms, pm_ramsize);
+ sg_host_get_name(vm), sg_host_get_name(pm),
+ vm_ramsize, pm_ramsize - total_ramsize_of_vms, pm_ramsize);
xbt_dynar_free(&dyn_vms);
return 0;
}
netElm, cpu);
surf_callback_emit(hostCreatedCallbacks, host);
XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage));
- xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, host);
+ simgrid::Host::find_host(name)->set_facet(SURF_HOST_LEVEL, host);
return host;
}
Cpu *cpu);
/** @brief Host destructor */
- ~ Host();
+ ~Host();
void setState(e_surf_resource_state_t state);
HostL07 *host = new HostL07(this, name, NULL, netElm, cpu);
surf_callback_emit(hostCreatedCallbacks, host);
- xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, host);
+ simgrid::Host::get_host(name)->set_facet(SURF_HOST_LEVEL, host);
return host;
}
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ns3);
-extern xbt_lib_t host_lib;
-extern xbt_lib_t as_router_lib;
-
-extern xbt_dict_t dict_socket;
-
xbt_dynar_t IPV4addr;
static double time_to_next_flow_completion = -1;
+extern xbt_dict_t dict_socket;
+
/*************
* Callbacks *
*************/
{
const char* id = host->getName();
XBT_DEBUG("NS3_ADD_HOST '%s'", id);
- xbt_lib_set(host_lib,
- id,
- NS3_HOST_LEVEL,
- ns3_add_host(id)
- );
+ simgrid::Host::get_host(id)->set_facet(NS3_HOST_LEVEL, ns3_add_host(id));
}
static void parse_ns3_add_link(sg_platf_link_cbarg_t link)
start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
xbt_dynar_push_as(tab_elements_num, int, start);
router_id = bprintf("ns3_%s%d%s", cluster_prefix, start, cluster_suffix);
- xbt_lib_set(host_lib,
- router_id,
- NS3_HOST_LEVEL,
- ns3_add_host_cluster(router_id)
- );
+ simgrid::Host::get_host(router_id)
+ ->set_facet(NS3_HOST_LEVEL, ns3_add_host_cluster(router_id));
XBT_DEBUG("NS3_ADD_ROUTER '%s'",router_id);
free(router_id);
break;
for (i = start; i <= end; i++){
xbt_dynar_push_as(tab_elements_num, int, i);
router_id = bprintf("ns3_%s%d%s", cluster_prefix, i, cluster_suffix);
- xbt_lib_set(host_lib,
- router_id,
- NS3_HOST_LEVEL,
- ns3_add_host_cluster(router_id)
- );
+ simgrid::Host::get_host(router_id)
+ ->set_facet(NS3_HOST_LEVEL, ns3_add_host_cluster(router_id));
XBT_DEBUG("NS3_ADD_ROUTER '%s'",router_id);
free(router_id);
}
router_id = bprintf("ns3_%s%d%s", cluster_prefix, elmts, cluster_suffix);
XBT_DEBUG("Create link from '%s' to '%s'",host_id,router_id);
- ns3_nodes_t host_src = static_cast<ns3_nodes_t>(xbt_lib_get_or_null(host_lib,host_id, NS3_HOST_LEVEL));
- ns3_nodes_t host_dst = static_cast<ns3_nodes_t>(xbt_lib_get_or_null(host_lib,router_id,NS3_HOST_LEVEL));
+ ns3_nodes_t host_src = ns3_find_host(host_id);
+ ns3_nodes_t host_dst = ns3_find_host(router_id);
if(host_src && host_dst){}
else xbt_die("\tns3_add_link from %d to %d",host_src->node_num,host_dst->node_num);
XBT_DEBUG("\tLink (%s) bdw:%s lat:%s", link->getName(), link_bdw, link_lat);
//create link ns3
- ns3_nodes_t host_src = static_cast<ns3_nodes_t>(xbt_lib_get_or_null(host_lib,src,NS3_HOST_LEVEL));
+ ns3_nodes_t host_src = ns3_find_host(src);
if(!host_src) host_src = static_cast<ns3_nodes_t>(xbt_lib_get_or_null(as_router_lib,src,NS3_ASR_LEVEL));
- ns3_nodes_t host_dst = static_cast<ns3_nodes_t>(xbt_lib_get_or_null(host_lib,dst,NS3_HOST_LEVEL));
+ ns3_nodes_t host_dst = ns3_find_host(dst);
if(!host_dst) host_dst = static_cast<ns3_nodes_t>(xbt_lib_get_or_null(as_router_lib,dst,NS3_ASR_LEVEL));
if(host_src && host_dst){}
routing_model_create(NULL);
define_callbacks_ns3();
- NS3_HOST_LEVEL = xbt_lib_add_level(host_lib,(void_f_pvoid_t)free_ns3_host);
- NS3_ASR_LEVEL = xbt_lib_add_level(as_router_lib,(void_f_pvoid_t)free_ns3_host);
+ NS3_HOST_LEVEL = simgrid::Host::add_level(free_ns3_host);
+ NS3_ASR_LEVEL = xbt_lib_add_level(as_router_lib, free_ns3_host);
}
NetworkNS3Model::~NetworkNS3Model() {
using namespace ns3;
-extern xbt_lib_t host_lib;
extern int NS3_HOST_LEVEL; //host node for ns3
extern xbt_dynar_t IPV4addr;
int ns3_create_flow(const char* a,const char *b,double start,u_int32_t TotalBytes,void * action)
{
- ns3_nodes_t node1 = (ns3_nodes_t) xbt_lib_get_or_null(host_lib,a,NS3_HOST_LEVEL);
- ns3_nodes_t node2 = (ns3_nodes_t) xbt_lib_get_or_null(host_lib,b,NS3_HOST_LEVEL);
+ ns3_nodes_t node1 = ns3_find_host(a);
+ ns3_nodes_t node2 = ns3_find_host(b);
Ptr<Node> src_node = nodes.Get(node1->node_num);
Ptr<Node> dst_node = nodes.Get(node2->node_num);
#include "xbt/misc.h"
#include "xbt/sysdep.h"
+#include <simgrid/host.h>
+#include <surf/surf_routing.h>
+
typedef enum {
NS3_NETWORK_ELEMENT_NULL = 0, /* NULL */
NS3_NETWORK_ELEMENT_HOST, /* host type */
XBT_PUBLIC(void) ns3_end_platform(void);
XBT_PUBLIC(void) ns3_add_cluster(char * bw,char * lat,const char *id);
+XBT_INLINE
+ns3_nodes_t ns3_find_host(const char* id)
+{
+ sg_host_t host = sg_host_by_name(id);
+ if (host == nullptr)
+ return nullptr;
+ else
+ return (ns3_nodes_t) sg_host_get_facet(host, NS3_HOST_LEVEL);
+}
+
SG_END_DECL()
#endif
* TOOLS *
*********/
-static simgrid::surf::Host *get_casted_host(surf_resource_t resource){
+static simgrid::surf::Host *get_casted_host(sg_host_t resource){
return static_cast<simgrid::surf::Host*>(surf_host_resource_priv(resource));
}
-static simgrid::surf::VirtualMachine *get_casted_vm(surf_resource_t resource){
+static simgrid::surf::VirtualMachine *get_casted_vm(sg_host_t resource){
return static_cast<simgrid::surf::VirtualMachine*>(surf_host_resource_priv(resource));
}
* MODEL *
*********/
-surf_model_t surf_resource_model(const void *host, int level) {
- /* If level is SURF_WKS_LEVEL, ws is a host_CLM03 object. It has
- * surf_resource at the generic_resource field. */
- simgrid::surf::Resource *ws = static_cast<simgrid::surf::Resource*>(
- xbt_lib_get_level((xbt_dictelm_t) host, level));
- return ws->getModel();
+surf_host_model_t surf_host_get_model(sg_host_t host)
+{
+ simgrid::surf::Host* surf_host =
+ (simgrid::surf::Host*) host->facet(SURF_HOST_LEVEL);
+ return (surf_host_model_t) surf_host->getModel();
}
surf_action_t surf_model_extract_done_action_set(surf_model_t model){
}
xbt_dynar_t surf_host_model_get_route(surf_host_model_t /*model*/,
- surf_resource_t src, surf_resource_t dst){
+ sg_host_t src, sg_host_t dst){
xbt_dynar_t route = NULL;
routing_platf->getRouteAndLatency(
get_casted_host(src)->p_netElm,
return route;
}
-void surf_vm_model_create(const char *name, surf_resource_t ind_phys_host){
+void surf_vm_model_create(const char *name, sg_host_t ind_phys_host){
surf_vm_model->createVM(name, ind_phys_host);
}
resource->setState(state);
}
-surf_action_t surf_host_sleep(surf_resource_t host, double duration){
+surf_action_t surf_host_sleep(sg_host_t host, double duration){
return get_casted_host(host)->sleep(duration);
}
-double surf_host_get_speed(surf_resource_t host, double load){
+double surf_host_get_speed(sg_host_t host, double load){
return sg_host_surfcpu(host)->getSpeed(load);
}
-double surf_host_get_available_speed(surf_resource_t host){
+double surf_host_get_available_speed(sg_host_t host){
return sg_host_surfcpu(host)->getAvailableSpeed();
}
-int surf_host_get_core(surf_resource_t host){
+int surf_host_get_core(sg_host_t host){
return sg_host_surfcpu(host)->getCore();
}
-surf_action_t surf_host_execute(surf_resource_t host, double size){
+surf_action_t surf_host_execute(sg_host_t host, double size){
return get_casted_host(host)->execute(size);
}
-double surf_host_get_current_power_peak(surf_resource_t host){
+double surf_host_get_current_power_peak(sg_host_t host){
return sg_host_surfcpu(host)->getCurrentPowerPeak();
}
-double surf_host_get_power_peak_at(surf_resource_t host, int pstate_index){
+double surf_host_get_power_peak_at(sg_host_t host, int pstate_index){
return sg_host_surfcpu(host)->getPowerPeakAt(pstate_index);
}
-int surf_host_get_nb_pstates(surf_resource_t host){
+int surf_host_get_nb_pstates(sg_host_t host){
return sg_host_surfcpu(host)->getNbPstates();
}
-void surf_host_set_pstate(surf_resource_t host, int pstate_index){
+void surf_host_set_pstate(sg_host_t host, int pstate_index){
sg_host_surfcpu(host)->setPstate(pstate_index);
}
-int surf_host_get_pstate(surf_resource_t host){
+int surf_host_get_pstate(sg_host_t host){
return sg_host_surfcpu(host)->getPstate();
}
using simgrid::energy::HostEnergy;
using simgrid::energy::surf_energy;
-double surf_host_get_wattmin_at(surf_resource_t resource, int pstate){
+double surf_host_get_wattmin_at(sg_host_t resource, int pstate){
xbt_assert(surf_energy!=NULL, "The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization.");
std::map<simgrid::surf::Host*, HostEnergy*>::iterator hostIt = surf_energy->find(get_casted_host(resource));
return hostIt->second->getWattMinAt(pstate);
}
-double surf_host_get_wattmax_at(surf_resource_t resource, int pstate){
+double surf_host_get_wattmax_at(sg_host_t resource, int pstate){
xbt_assert(surf_energy!=NULL, "The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization.");
std::map<simgrid::surf::Host*, HostEnergy*>::iterator hostIt = surf_energy->find(get_casted_host(resource));
return hostIt->second->getWattMaxAt(pstate);
}
-double surf_host_get_consumed_energy(surf_resource_t resource){
+double surf_host_get_consumed_energy(sg_host_t resource){
xbt_assert(surf_energy!=NULL, "The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization.");
std::map<simgrid::surf::Host*, HostEnergy*>::iterator hostIt = surf_energy->find(get_casted_host(resource));
return hostIt->second->getConsumedEnergy();
}
-xbt_dict_t surf_host_get_mounted_storage_list(surf_resource_t host){
+xbt_dict_t surf_host_get_mounted_storage_list(sg_host_t host){
return get_casted_host(host)->getMountedStorageList();
}
-xbt_dynar_t surf_host_get_attached_storage_list(surf_resource_t host){
+xbt_dynar_t surf_host_get_attached_storage_list(sg_host_t host){
return get_casted_host(host)->getAttachedStorageList();
}
-surf_action_t surf_host_open(surf_resource_t host, const char* fullpath){
+surf_action_t surf_host_open(sg_host_t host, const char* fullpath){
return get_casted_host(host)->open(fullpath);
}
-surf_action_t surf_host_close(surf_resource_t host, surf_file_t fd){
+surf_action_t surf_host_close(sg_host_t host, surf_file_t fd){
return get_casted_host(host)->close(fd);
}
-int surf_host_unlink(surf_resource_t host, surf_file_t fd){
+int surf_host_unlink(sg_host_t host, surf_file_t fd){
return get_casted_host(host)->unlink(fd);
}
-size_t surf_host_get_size(surf_resource_t host, surf_file_t fd){
+size_t surf_host_get_size(sg_host_t host, surf_file_t fd){
return get_casted_host(host)->getSize(fd);
}
-surf_action_t surf_host_read(surf_resource_t host, surf_file_t fd, sg_size_t size){
+surf_action_t surf_host_read(sg_host_t host, surf_file_t fd, sg_size_t size){
return get_casted_host(host)->read(fd, size);
}
-surf_action_t surf_host_write(surf_resource_t host, surf_file_t fd, sg_size_t size){
+surf_action_t surf_host_write(sg_host_t host, surf_file_t fd, sg_size_t size){
return get_casted_host(host)->write(fd, size);
}
-xbt_dynar_t surf_host_get_info(surf_resource_t host, surf_file_t fd){
+xbt_dynar_t surf_host_get_info(sg_host_t host, surf_file_t fd){
return get_casted_host(host)->getInfo(fd);
}
-size_t surf_host_file_tell(surf_resource_t host, surf_file_t fd){
+size_t surf_host_file_tell(sg_host_t host, surf_file_t fd){
return get_casted_host(host)->fileTell(fd);
}
-int surf_host_file_seek(surf_resource_t host, surf_file_t fd,
+int surf_host_file_seek(sg_host_t host, surf_file_t fd,
sg_offset_t offset, int origin){
return get_casted_host(host)->fileSeek(fd, offset, origin);
}
-int surf_host_file_move(surf_resource_t host, surf_file_t fd, const char* fullpath){
+int surf_host_file_move(sg_host_t host, surf_file_t fd, const char* fullpath){
return get_casted_host(host)->fileMove(fd, fullpath);
}
-xbt_dynar_t surf_host_get_vms(surf_resource_t host){
+xbt_dynar_t surf_host_get_vms(sg_host_t host){
xbt_dynar_t vms = get_casted_host(host)->getVms();
xbt_dynar_t vms_ = xbt_dynar_new(sizeof(sg_host_t), NULL);
unsigned int cpt;
simgrid::surf::VirtualMachine *vm;
xbt_dynar_foreach(vms, cpt, vm) {
- sg_host_t vm_ = xbt_lib_get_elm_or_null(host_lib, vm->getName());
+ // TODO, use a backlink from simgrid::surf::Host to simgrid::Host
+ sg_host_t vm_ = (sg_host_t) xbt_dict_get_elm_or_null(host_list, vm->getName());
xbt_dynar_push(vms_, &vm_);
}
xbt_dynar_free(&vms);
return vms_;
}
-void surf_host_get_params(surf_resource_t host, vm_params_t params){
+void surf_host_get_params(sg_host_t host, vm_params_t params){
get_casted_host(host)->getParams(params);
}
-void surf_host_set_params(surf_resource_t host, vm_params_t params){
+void surf_host_set_params(sg_host_t host, vm_params_t params){
get_casted_host(host)->setParams(params);
}
-void surf_vm_destroy(surf_resource_t resource){
+void surf_vm_destroy(sg_host_t resource){
/* Before clearing the entries in host_lib, we have to pick up resources. */
- simgrid::surf::VirtualMachine *vm = get_casted_vm(resource);
- char* name = xbt_dict_get_elm_key(resource);
+ const char* name = resource->id().c_str();
/* We deregister objects from host_lib, without invoking the freeing callback
* of each level.
*
* Do not call xbt_lib_remove() here. It deletes all levels of the key,
* including MSG_HOST_LEVEL and others. We should unregister only what we know.
*/
- sg_host_surfcpu_destroy((sg_host_t)resource);
- sg_host_edge_destroy((sg_host_t)resource,1);
- xbt_lib_unset(host_lib, name, SURF_HOST_LEVEL, 0);
+ sg_host_surfcpu_destroy(resource);
+ sg_host_edge_destroy(resource,1);
+ // TODO, use backlink from simgrid::surf::Host to simgrid::Host
+ simgrid::Host* host = (simgrid::Host*) xbt_dict_get_or_null(host_list, name);
+ host->set_facet(SURF_HOST_LEVEL, nullptr);
/* TODO: comment out when VM storage is implemented. */
- // xbt_lib_unset(host_lib, name, SURF_STORAGE_LEVEL, 0);
-
- delete vm;
+ // host->set_facet(SURF_STORAGE_LEVEL, nullptr);
}
-void surf_vm_suspend(surf_resource_t vm){
+void surf_vm_suspend(sg_host_t vm){
get_casted_vm(vm)->suspend();
}
-void surf_vm_resume(surf_resource_t vm){
+void surf_vm_resume(sg_host_t vm){
get_casted_vm(vm)->resume();
}
-void surf_vm_save(surf_resource_t vm){
+void surf_vm_save(sg_host_t vm){
get_casted_vm(vm)->save();
}
-void surf_vm_restore(surf_resource_t vm){
+void surf_vm_restore(sg_host_t vm){
get_casted_vm(vm)->restore();
}
-void surf_vm_migrate(surf_resource_t vm, surf_resource_t ind_vm_ws_dest){
+void surf_vm_migrate(sg_host_t vm, sg_host_t ind_vm_ws_dest){
get_casted_vm(vm)->migrate(ind_vm_ws_dest);
}
-surf_resource_t surf_vm_get_pm(surf_resource_t vm){
+sg_host_t surf_vm_get_pm(sg_host_t vm){
return get_casted_vm(vm)->getPm();
}
-void surf_vm_set_bound(surf_resource_t vm, double bound){
+void surf_vm_set_bound(sg_host_t vm, double bound){
return get_casted_vm(vm)->setBound(bound);
}
-void surf_vm_set_affinity(surf_resource_t vm, surf_resource_t cpu, unsigned long mask){
+void surf_vm_set_affinity(sg_host_t vm, sg_host_t cpu, unsigned long mask){
return get_casted_vm(vm)->setAffinity(sg_host_surfcpu(cpu), mask);
}
return static_cast<simgrid::surf::Storage*>(surf_storage_resource_priv(resource))->p_attach;
}
-surf_action_t surf_cpu_execute(surf_resource_t cpu, double size){
+surf_action_t surf_cpu_execute(sg_host_t cpu, double size){
return sg_host_surfcpu(cpu)->execute(size);
}
-surf_action_t surf_cpu_sleep(surf_resource_t cpu, double duration){
+surf_action_t surf_cpu_sleep(sg_host_t cpu, double duration){
return sg_host_surfcpu(cpu)->sleep(duration);
}
return action->getCost();
}
-void surf_cpu_action_set_affinity(surf_action_t action, surf_resource_t cpu, unsigned long mask) {
+void surf_cpu_action_set_affinity(surf_action_t action, sg_host_t cpu, unsigned long mask) {
static_cast<simgrid::surf::CpuAction*>(action)->setAffinity(sg_host_surfcpu(cpu), mask);
}
void surf_init(int *argc, char **argv)
{
XBT_DEBUG("Create all Libs");
- host_lib = xbt_lib_new();
+ host_list = xbt_dict_new_homogeneous([](void*p) {
+ delete (simgrid::Host*)p;
+ });
as_router_lib = xbt_lib_new();
storage_lib = xbt_lib_new();
storage_type_lib = xbt_lib_new();
ROUTING_PROP_ASR_LEVEL = xbt_lib_add_level(as_router_lib,routing_asr_prop_free);
XBT_DEBUG("Add SURF levels");
- SURF_HOST_LEVEL = xbt_lib_add_level(host_lib,surf_host_free);
+ SURF_HOST_LEVEL = simgrid::Host::add_level(surf_host_free);
SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_storage_free);
xbt_init(argc, argv);
xbt_dynar_free(&host_that_restart);
xbt_dynar_free(&surf_path);
- xbt_lib_free(&host_lib);
+ xbt_dict_free(&host_list);
xbt_lib_free(&as_router_lib);
xbt_lib_free(&storage_lib);
sg_link_exit();
* @ingroup SURF_build_api
* @brief A library containing all known hosts
*/
-xbt_lib_t host_lib;
+xbt_dict_t host_list;
int SURF_HOST_LEVEL; //Surf host level
int COORD_HOST_LEVEL=0; //Coordinates level
}
xbt_dynar_shrink(ctn, 0);
xbt_dynar_free(&ctn_str);
- xbt_lib_set(host_lib, host->id, COORD_HOST_LEVEL, (void *) ctn);
+ simgrid::Host::get_host(host->id)->set_facet(COORD_HOST_LEVEL, (void *) ctn);
XBT_DEBUG("Having set host coordinates for '%s'",host->id);
}
xbt_dynar_t surf_AS_get_hosts(simgrid::surf::As *as)
{
xbt_dynar_t elms = as->p_indexNetworkElm;
- sg_routing_edge_t relm;
- xbt_dictelm_t delm;
- int index;
int count = xbt_dynar_length(elms);
- xbt_dynar_t res = xbt_dynar_new(sizeof(xbt_dictelm_t), NULL);
- for (index = 0; index < count; index++) {
- relm = xbt_dynar_get_as(elms, index, simgrid::surf::RoutingEdge*);
- delm = xbt_lib_get_elm_or_null(host_lib, relm->getName());
+ xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t), NULL);
+ for (int index = 0; index < count; index++) {
+ sg_routing_edge_t relm =
+ xbt_dynar_get_as(elms, index, simgrid::surf::RoutingEdge*);
+ sg_host_t delm = simgrid::Host::find_host(relm->getName());
if (delm!=NULL) {
xbt_dynar_push(res, &delm);
}
*lat += static_cast<Link*>(info.link_up)->getLatency();
}
}
- src_ctn = (xbt_dynar_t) xbt_lib_get_or_null(host_lib, tmp_src_name, COORD_HOST_LEVEL);
- if(!src_ctn ) src_ctn = (xbt_dynar_t) xbt_lib_get_or_null(host_lib, src->getName(), COORD_HOST_LEVEL);
+ src_ctn = (xbt_dynar_t) simgrid::Host::get_host(tmp_src_name)->facet(COORD_HOST_LEVEL);
+ if (src_ctn == nullptr)
+ src_ctn = (xbt_dynar_t) simgrid::Host::get_host(src->getName())->facet(COORD_HOST_LEVEL);
}
else if(src->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_NETWORK_ELEMENT_AS){
tmp_src_name = ROUTER_PEER(src->getName());
*lat += static_cast<Link*>(info.link_down)->getLatency();
}
}
- dst_ctn = (xbt_dynar_t) xbt_lib_get_or_null(host_lib, tmp_dst_name, COORD_HOST_LEVEL);
- if(!dst_ctn ) dst_ctn = (xbt_dynar_t) xbt_lib_get_or_null(host_lib, dst->getName(), COORD_HOST_LEVEL);
+ dst_ctn = (xbt_dynar_t) simgrid::Host::get_host(tmp_dst_name)
+ ->facet(COORD_HOST_LEVEL);
+ if (dst_ctn == nullptr)
+ dst_ctn = (xbt_dynar_t) simgrid::Host::get_host(dst->getName())
+ ->facet(COORD_HOST_LEVEL);
}
else if(dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || dst->getRcType() == SURF_NETWORK_ELEMENT_AS){
tmp_dst_name = ROUTER_PEER(dst->getName());
: Host(model, name, props, NULL, netElm, cpu)
{
VMModel::ws_vms.push_back(*this);
-
- xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, this);
+ simgrid::Host::get_host(name)->set_facet(SURF_HOST_LEVEL, this);
}
/*
* A surf level object will be useless in the upper layer. Returning the
* dict_elm of the host.
**/
-surf_resource_t VirtualMachine::getPm()
+sg_host_t VirtualMachine::getPm()
{
- return xbt_lib_get_elm_or_null(host_lib, p_subWs->getName());
+ return simgrid::Host::find_host(p_subWs->getName());
}
/**********
virtual void restore()=0;
/** @brief Migrate the VM to the destination host */
- virtual void migrate(surf_resource_t dest_PM)=0;
+ virtual void migrate(sg_host_t dest_PM)=0;
/** @brief Get the physical machine hosting the VM */
- virtual surf_resource_t getPm()=0;
+ virtual sg_host_t getPm()=0;
virtual void setBound(double bound)=0;
virtual void setAffinity(Cpu *cpu, unsigned long mask)=0;
* @param host_PM The real machine hosting the VM
*
*/
- virtual VirtualMachine *createVM(const char *name, surf_resource_t host_PM)=0;
+ virtual VirtualMachine *createVM(const char *name, sg_host_t host_PM)=0;
void adjustWeightOfDummyCpuActions() {};
typedef boost::intrusive::member_hook<
/* ind means ''indirect'' that this is a reference on the whole dict_elm
* structure (i.e not on the surf_resource_private infos) */
-VirtualMachine *VMHL13Model::createVM(const char *name, surf_resource_t host_PM)
+VirtualMachine *VMHL13Model::createVM(const char *name, sg_host_t host_PM)
{
VirtualMachine* vm = new VMHL13(this, name, NULL, host_PM);
surf_callback_emit(VMCreatedCallbacks, vm);
************/
VMHL13::VMHL13(VMModel *model, const char* name, xbt_dict_t props,
- surf_resource_t host_PM)
+ sg_host_t host_PM)
: VirtualMachine(model, name, props, NULL, NULL)
{
Host *sub_ws = surf_host_resource_priv(host_PM);
/*
* Update the physical host of the given VM
*/
-void VMHL13::migrate(surf_resource_t ind_dst_pm)
+void VMHL13::migrate(sg_host_t ind_dst_pm)
{
/* ind_dst_pm equals to smx_host_t */
Host *ws_dst = static_cast<Host*>(surf_host_resource_priv(ind_dst_pm));
* A surf level object will be useless in the upper layer. Returning the
* dict_elm of the host.
**/
-surf_resource_t VMHL13::getPm()
+sg_host_t VMHL13::getPm()
{
- return xbt_lib_get_elm_or_null(host_lib, p_subWs->getName());
+ // TODO, store pointer to the PM?
+ return simgrid::Host::find_host(p_subWs->getName());
}
/* Adding a task to a VM updates the VCPU task on its physical machine. */
VMHL13Model();
~VMHL13Model(){};
- VirtualMachine *createVM(const char *name, surf_resource_t host_PM);
+ VirtualMachine *createVM(const char *name, sg_host_t host_PM) override;
double shareResources(double now);
- void adjustWeightOfDummyCpuActions() {};
+ void adjustWeightOfDummyCpuActions() override {};
Action *executeParallelTask(int host_nb,
sg_host_t *host_list,
double *flops_amount,
double *bytes_amount,
- double rate);
- void updateActionsState(double /*now*/, double /*delta*/);
+ double rate) override;
+ void updateActionsState(double /*now*/, double /*delta*/) override;
};
/************
class VMHL13 : public VirtualMachine {
public:
- VMHL13(VMModel *model, const char* name, xbt_dict_t props, surf_resource_t host_PM);
+ VMHL13(VMModel *model, const char* name, xbt_dict_t props, sg_host_t host_PM);
~VMHL13();
void suspend();
void save();
void restore();
- void migrate(surf_resource_t ind_dst_pm);
+ void migrate(sg_host_t ind_dst_pm);
e_surf_resource_state_t getState();
void setState(e_surf_resource_state_t state);
- surf_resource_t getPm(); // will be vm_ws_get_pm()
+ sg_host_t getPm(); // will be vm_ws_get_pm()
void setBound(double bound);
void setAffinity(Cpu *cpu, unsigned long mask);
}
}
-
- xbt_lib_foreach(host_lib, cursor_src, src, value1) // Routes from host
+ sg_host_t host1, host2;
+ xbt_dict_foreach(host_list, cursor_src, src, host1) // Routes from host
{
value1 = sg_host_edge(sg_host_by_name(src));
- xbt_lib_foreach(host_lib, cursor_dst, dst, value2) //to host
+ xbt_dict_foreach(host_list, cursor_dst, dst, host2) //to host
{
printf(" <route src=\"%s\" dst=\"%s\">\n "
,src
,dst);
xbt_dynar_t route=NULL;
value2 = sg_host_edge(sg_host_by_name(dst));
- routing_get_route_and_latency(value1,value2,&route,NULL);
+ routing_get_route_and_latency(value1, value2, &route,NULL);
for(i=0;i<xbt_dynar_length(route) ;i++)
{
void *link = xbt_dynar_get_as(route,i,void *);
printf("\n </route>\n");
}
}
- xbt_lib_foreach(host_lib, cursor_dst, dst, value2) //to host
+ xbt_dict_foreach(host_list, cursor_dst, dst, value2) //to host
{
printf(" <route src=\"%s\" dst=\"%s\">\n "
,src, dst);
/* creation of the environment */
SD_create_environment(argv[1]);
- size = xbt_lib_length(host_lib) + xbt_lib_length(as_router_lib);
+ size = xbt_dict_length(host_list) + xbt_lib_length(as_router_lib);
printf("Workstation number: %d, link number: %d, elmts number: %d\n",
SD_workstation_get_number(), SD_link_get_number(), size);
- xbt_lib_foreach(host_lib, cursor, key, data) {
+ xbt_dict_foreach(host_list, cursor, key, data) {
printf(" - Seen: \"%s\" is type : %d\n", key,
(int) routing_get_network_element_type(key));
}