* Kill the xbt_peer_t data type: it's useless without GRAS.
* Kill rm_cb feature of config sets: it was never useful.
* Kill graphxml parsing feature. It was not used.
+ * Kill the deprecated code protected by XBT_USE_DEPRECATED
* New functions:
- xbt_dynar_sort_strings(), when the content is char*
- xbt_str_parse_int / xbt_str_parse_double, wrapping strtol/strtod
do { if (!(cond)) THROWF(0, 0, __VA_ARGS__); } while (0)
#endif
-#ifdef XBT_USE_DEPRECATED
-
-#define xbt_assert0(...) xbt_assert(__VA_ARGS__)
-#define xbt_assert1(...) xbt_assert(__VA_ARGS__)
-#define xbt_assert2(...) xbt_assert(__VA_ARGS__)
-#define xbt_assert3(...) xbt_assert(__VA_ARGS__)
-#define xbt_assert4(...) xbt_assert(__VA_ARGS__)
-#define xbt_assert5(...) xbt_assert(__VA_ARGS__)
-#define xbt_assert6(...) xbt_assert(__VA_ARGS__)
-
-#endif
/** @} */
SG_END_DECL()
#endif /* _XBT_ASSERTS_H */
/** @} */
-#ifdef XBT_USE_DEPRECATED
-
-/* Kept for backward compatibility. */
-
-#define xbt_test_add0(...) xbt_test_add(__VA_ARGS__)
-#define xbt_test_add1(...) xbt_test_add(__VA_ARGS__)
-#define xbt_test_add2(...) xbt_test_add(__VA_ARGS__)
-#define xbt_test_add3(...) xbt_test_add(__VA_ARGS__)
-#define xbt_test_add4(...) xbt_test_add(__VA_ARGS__)
-#define xbt_test_add5(...) xbt_test_add(__VA_ARGS__)
-
-#define xbt_test_fail0(...) xbt_test_fail(__VA_ARGS__)
-#define xbt_test_fail1(...) xbt_test_fail(__VA_ARGS__)
-#define xbt_test_fail2(...) xbt_test_fail(__VA_ARGS__)
-#define xbt_test_fail3(...) xbt_test_fail(__VA_ARGS__)
-#define xbt_test_fail4(...) xbt_test_fail(__VA_ARGS__)
-#define xbt_test_fail5(...) xbt_test_fail(__VA_ARGS__)
-
-#define xbt_test_assert0(...) xbt_test_assert(__VA_ARGS__)
-#define xbt_test_assert1(...) xbt_test_assert(__VA_ARGS__)
-#define xbt_test_assert2(...) xbt_test_assert(__VA_ARGS__)
-#define xbt_test_assert3(...) xbt_test_assert(__VA_ARGS__)
-#define xbt_test_assert4(...) xbt_test_assert(__VA_ARGS__)
-#define xbt_test_assert5(...) xbt_test_assert(__VA_ARGS__)
-
-#define xbt_test_log0(...) xbt_test_log(__VA_ARGS__)
-#define xbt_test_log1(...) xbt_test_log(__VA_ARGS__)
-#define xbt_test_log2(...) xbt_test_log(__VA_ARGS__)
-#define xbt_test_log3(...) xbt_test_log(__VA_ARGS__)
-#define xbt_test_log4(...) xbt_test_log(__VA_ARGS__)
-#define xbt_test_log5(...) xbt_test_log(__VA_ARGS__)
-
-#endif
-
SG_END_DECL()
-#endif /* _TS_H_ */
+#endif /* _XBT_CUNIT_H_ */
XBT_PUBLIC(void) xbt_dict_remove_ext(xbt_dict_t dict, const char *key,
int key_len);
-#ifdef XBT_USE_DEPRECATED
-XBT_PUBLIC(void) xbt_dicti_set(xbt_dict_t dict, uintptr_t key,
- uintptr_t data);
-XBT_PUBLIC(uintptr_t) xbt_dicti_get(xbt_dict_t dict, uintptr_t key);
-XBT_PUBLIC(void) xbt_dicti_remove(xbt_dict_t dict, uintptr_t key);
-#endif
-
struct s_xbt_dict_cursor {
xbt_dictelm_t current;
int line;
/** @} */
-#ifdef XBT_USE_DEPRECATED
-/** @defgroup XBT_dict_multi Multi-level dictionaries
- * @ingroup XBT_dict
- *
- * They can be seen as dictionary of multiple keys or as dictionary of
- * dictionary of ... of data. Most of the functions here work the same way
- * than their simple dictionary counterpart.
- *
- * Note that there is no xbt_multidict_free neither xbt_multi_dict_new functions.
- * Use xbt_dict_free() and xbt_dict_new() instead.
- *
- * @{
- */
-
-/*----[ xbt_multidict_set ]--------------------------------------------------*/
-XBT_PUBLIC(void)
-xbt_multidict_set(xbt_dict_t mdict,
- xbt_dynar_t keys, void *data, void (*free_ctn) (void *));
-XBT_PUBLIC(void)
-xbt_multidict_set_ext(xbt_dict_t mdict,
- xbt_dynar_t keys, xbt_dynar_t lens,
- void *data, void_f_pvoid_t free_ctn);
-
-/*----[ xbt_multidict_get ]--------------------------------------------------*/
-XBT_PUBLIC(void *) xbt_multidict_get(xbt_dict_t mdict, xbt_dynar_t keys);
-XBT_PUBLIC(void *) xbt_multidict_get_ext(xbt_dict_t mdict,
- xbt_dynar_t keys,
- xbt_dynar_t lens);
-
-/*----[ xbt_multidict_remove ]-----------------------------------------------*/
-/*---------------------------------------------------------------------------*/
-XBT_PUBLIC(void) xbt_multidict_remove(xbt_dict_t mdict, xbt_dynar_t keys);
-XBT_PUBLIC(void) xbt_multidict_remove_ext(xbt_dict_t mdict,
- xbt_dynar_t keys,
- xbt_dynar_t lens);
-
-/** @} */
-#endif
-
SG_END_DECL()
#endif /* _XBT_DICT_H */
/** @brief Get current backtrace with libunwind */
XBT_PUBLIC(int) xbt_libunwind_backtrace(void *bt[XBT_BACKTRACE_SIZE], int size);
-#ifdef XBT_USE_DEPRECATED
-
-/* Kept for backward compatibility. */
-
-#define THROW0(c, v, m) \
- do { if (m) THROWF(c, v, m); else THROW(c, v); } while (0)
-#define THROW1(c, v, ...) THROWF(c, v, __VA_ARGS__)
-#define THROW2(c, v, ...) THROWF(c, v, __VA_ARGS__)
-#define THROW3(c, v, ...) THROWF(c, v, __VA_ARGS__)
-#define THROW4(c, v, ...) THROWF(c, v, __VA_ARGS__)
-#define THROW5(c, v, ...) THROWF(c, v, __VA_ARGS__)
-#define THROW6(c, v, ...) THROWF(c, v, __VA_ARGS__)
-#define THROW7(c, v, ...) THROWF(c, v, __VA_ARGS__)
-
-#define RETHROW0(...) RETHROWF(__VA_ARGS__)
-#define RETHROW1(...) RETHROWF(__VA_ARGS__)
-#define RETHROW2(...) RETHROWF(__VA_ARGS__)
-#define RETHROW3(...) RETHROWF(__VA_ARGS__)
-#define RETHROW4(...) RETHROWF(__VA_ARGS__)
-#define RETHROW5(...) RETHROWF(__VA_ARGS__)
-
-#endif
-
SG_END_DECL()
/** @} */
*/
#define XBT_HERE(...) XBT_LOG(xbt_log_priority_trace, "-- was here" __VA_ARGS__)
-#ifdef XBT_USE_DEPRECATED
-
-/* Kept for backward compatibility. */
-
-#define CLOG0(...) XBT_CLOG(__VA_ARGS__)
-#define CLOG1(...) XBT_CLOG(__VA_ARGS__)
-#define CLOG2(...) XBT_CLOG(__VA_ARGS__)
-#define CLOG3(...) XBT_CLOG(__VA_ARGS__)
-#define CLOG4(...) XBT_CLOG(__VA_ARGS__)
-#define CLOG5(...) XBT_CLOG(__VA_ARGS__)
-#define CLOG6(...) XBT_CLOG(__VA_ARGS__)
-#define CLOG7(...) XBT_CLOG(__VA_ARGS__)
-#define CLOG8(...) XBT_CLOG(__VA_ARGS__)
-#define CLOG9(...) XBT_CLOG(__VA_ARGS__)
-#define CLOG10(...) XBT_CLOG(__VA_ARGS__)
-
-#define CDEBUG0(...) XBT_CDEBUG(__VA_ARGS__)
-#define CDEBUG1(...) XBT_CDEBUG(__VA_ARGS__)
-#define CDEBUG2(...) XBT_CDEBUG(__VA_ARGS__)
-#define CDEBUG3(...) XBT_CDEBUG(__VA_ARGS__)
-#define CDEBUG4(...) XBT_CDEBUG(__VA_ARGS__)
-#define CDEBUG5(...) XBT_CDEBUG(__VA_ARGS__)
-#define CDEBUG6(...) XBT_CDEBUG(__VA_ARGS__)
-#define CDEBUG7(...) XBT_CDEBUG(__VA_ARGS__)
-#define CDEBUG8(...) XBT_CDEBUG(__VA_ARGS__)
-#define CDEBUG9(...) XBT_CDEBUG(__VA_ARGS__)
-#define CDEBUG10(...) XBT_CDEBUG(__VA_ARGS__)
-
-#define CVERB0(...) XBT_CVERB(__VA_ARGS__)
-#define CVERB1(...) XBT_CVERB(__VA_ARGS__)
-#define CVERB2(...) XBT_CVERB(__VA_ARGS__)
-#define CVERB3(...) XBT_CVERB(__VA_ARGS__)
-#define CVERB4(...) XBT_CVERB(__VA_ARGS__)
-#define CVERB5(...) XBT_CVERB(__VA_ARGS__)
-#define CVERB6(...) XBT_CVERB(__VA_ARGS__)
-#define CVERB7(...) XBT_CVERB(__VA_ARGS__)
-#define CVERB8(...) XBT_CVERB(__VA_ARGS__)
-#define CVERB9(...) XBT_CVERB(__VA_ARGS__)
-#define CVERB10(...) XBT_CVERB(__VA_ARGS__)
-
-#define CINFO0(...) XBT_CINFO(__VA_ARGS__)
-#define CINFO1(...) XBT_CINFO(__VA_ARGS__)
-#define CINFO2(...) XBT_CINFO(__VA_ARGS__)
-#define CINFO3(...) XBT_CINFO(__VA_ARGS__)
-#define CINFO4(...) XBT_CINFO(__VA_ARGS__)
-#define CINFO5(...) XBT_CINFO(__VA_ARGS__)
-#define CINFO6(...) XBT_CINFO(__VA_ARGS__)
-#define CINFO7(...) XBT_CINFO(__VA_ARGS__)
-#define CINFO8(...) XBT_CINFO(__VA_ARGS__)
-#define CINFO9(...) XBT_CINFO(__VA_ARGS__)
-#define CINFO10(...) XBT_CINFO(__VA_ARGS__)
-
-#define CWARN0(...) XBT_CWARN(__VA_ARGS__)
-#define CWARN1(...) XBT_CWARN(__VA_ARGS__)
-#define CWARN2(...) XBT_CWARN(__VA_ARGS__)
-#define CWARN3(...) XBT_CWARN(__VA_ARGS__)
-#define CWARN4(...) XBT_CWARN(__VA_ARGS__)
-#define CWARN5(...) XBT_CWARN(__VA_ARGS__)
-#define CWARN6(...) XBT_CWARN(__VA_ARGS__)
-#define CWARN7(...) XBT_CWARN(__VA_ARGS__)
-#define CWARN8(...) XBT_CWARN(__VA_ARGS__)
-#define CWARN9(...) XBT_CWARN(__VA_ARGS__)
-#define CWARN10(...) XBT_CWARN(__VA_ARGS__)
-
-#define CERROR0(...) XBT_CERROR(__VA_ARGS__)
-#define CERROR1(...) XBT_CERROR(__VA_ARGS__)
-#define CERROR2(...) XBT_CERROR(__VA_ARGS__)
-#define CERROR3(...) XBT_CERROR(__VA_ARGS__)
-#define CERROR4(...) XBT_CERROR(__VA_ARGS__)
-#define CERROR5(...) XBT_CERROR(__VA_ARGS__)
-#define CERROR6(...) XBT_CERROR(__VA_ARGS__)
-#define CERROR7(...) XBT_CERROR(__VA_ARGS__)
-#define CERROR8(...) XBT_CERROR(__VA_ARGS__)
-#define CERROR9(...) XBT_CERROR(__VA_ARGS__)
-#define CERROR10(...) XBT_CERROR(__VA_ARGS__)
-
-#define CCRITICAL0(...) XBT_CCRITICAL(__VA_ARGS__)
-#define CCRITICAL1(...) XBT_CCRITICAL(__VA_ARGS__)
-#define CCRITICAL2(...) XBT_CCRITICAL(__VA_ARGS__)
-#define CCRITICAL3(...) XBT_CCRITICAL(__VA_ARGS__)
-#define CCRITICAL4(...) XBT_CCRITICAL(__VA_ARGS__)
-#define CCRITICAL5(...) XBT_CCRITICAL(__VA_ARGS__)
-#define CCRITICAL6(...) XBT_CCRITICAL(__VA_ARGS__)
-#define CCRITICAL7(...) XBT_CCRITICAL(__VA_ARGS__)
-#define CCRITICAL8(...) XBT_CCRITICAL(__VA_ARGS__)
-#define CCRITICAL9(...) XBT_CCRITICAL(__VA_ARGS__)
-#define CCRITICAL10(...) XBT_CCRITICAL(__VA_ARGS__)
-
-#define LOG0(...) XBT_LOG(__VA_ARGS__)
-#define LOG1(...) XBT_LOG(__VA_ARGS__)
-#define LOG2(...) XBT_LOG(__VA_ARGS__)
-#define LOG3(...) XBT_LOG(__VA_ARGS__)
-#define LOG4(...) XBT_LOG(__VA_ARGS__)
-#define LOG5(...) XBT_LOG(__VA_ARGS__)
-#define LOG6(...) XBT_LOG(__VA_ARGS__)
-#define LOG7(...) XBT_LOG(__VA_ARGS__)
-#define LOG8(...) XBT_LOG(__VA_ARGS__)
-#define LOG9(...) XBT_LOG(__VA_ARGS__)
-#define LOG10(...) XBT_LOG(__VA_ARGS__)
-
-#define DEBUG0(...) XBT_DEBUG(__VA_ARGS__)
-#define DEBUG1(...) XBT_DEBUG(__VA_ARGS__)
-#define DEBUG2(...) XBT_DEBUG(__VA_ARGS__)
-#define DEBUG3(...) XBT_DEBUG(__VA_ARGS__)
-#define DEBUG4(...) XBT_DEBUG(__VA_ARGS__)
-#define DEBUG5(...) XBT_DEBUG(__VA_ARGS__)
-#define DEBUG6(...) XBT_DEBUG(__VA_ARGS__)
-#define DEBUG7(...) XBT_DEBUG(__VA_ARGS__)
-#define DEBUG8(...) XBT_DEBUG(__VA_ARGS__)
-#define DEBUG9(...) XBT_DEBUG(__VA_ARGS__)
-#define DEBUG10(...) XBT_DEBUG(__VA_ARGS__)
-
-#define VERB0(...) XBT_VERB(__VA_ARGS__)
-#define VERB1(...) XBT_VERB(__VA_ARGS__)
-#define VERB2(...) XBT_VERB(__VA_ARGS__)
-#define VERB3(...) XBT_VERB(__VA_ARGS__)
-#define VERB4(...) XBT_VERB(__VA_ARGS__)
-#define VERB5(...) XBT_VERB(__VA_ARGS__)
-#define VERB6(...) XBT_VERB(__VA_ARGS__)
-#define VERB7(...) XBT_VERB(__VA_ARGS__)
-#define VERB8(...) XBT_VERB(__VA_ARGS__)
-#define VERB9(...) XBT_VERB(__VA_ARGS__)
-#define VERB10(...) XBT_VERB(__VA_ARGS__)
-
-#define INFO0(...) XBT_INFO(__VA_ARGS__)
-#define INFO1(...) XBT_INFO(__VA_ARGS__)
-#define INFO2(...) XBT_INFO(__VA_ARGS__)
-#define INFO3(...) XBT_INFO(__VA_ARGS__)
-#define INFO4(...) XBT_INFO(__VA_ARGS__)
-#define INFO5(...) XBT_INFO(__VA_ARGS__)
-#define INFO6(...) XBT_INFO(__VA_ARGS__)
-#define INFO7(...) XBT_INFO(__VA_ARGS__)
-#define INFO8(...) XBT_INFO(__VA_ARGS__)
-#define INFO9(...) XBT_INFO(__VA_ARGS__)
-#define INFO10(...) XBT_INFO(__VA_ARGS__)
-
-#define WARN0(...) XBT_WARN(__VA_ARGS__)
-#define WARN1(...) XBT_WARN(__VA_ARGS__)
-#define WARN2(...) XBT_WARN(__VA_ARGS__)
-#define WARN3(...) XBT_WARN(__VA_ARGS__)
-#define WARN4(...) XBT_WARN(__VA_ARGS__)
-#define WARN5(...) XBT_WARN(__VA_ARGS__)
-#define WARN6(...) XBT_WARN(__VA_ARGS__)
-#define WARN7(...) XBT_WARN(__VA_ARGS__)
-#define WARN8(...) XBT_WARN(__VA_ARGS__)
-#define WARN9(...) XBT_WARN(__VA_ARGS__)
-#define WARN10(...) XBT_WARN(__VA_ARGS__)
-
-#define ERROR0(...) XBT_ERROR(__VA_ARGS__)
-#define ERROR1(...) XBT_ERROR(__VA_ARGS__)
-#define ERROR2(...) XBT_ERROR(__VA_ARGS__)
-#define ERROR3(...) XBT_ERROR(__VA_ARGS__)
-#define ERROR4(...) XBT_ERROR(__VA_ARGS__)
-#define ERROR5(...) XBT_ERROR(__VA_ARGS__)
-#define ERROR6(...) XBT_ERROR(__VA_ARGS__)
-#define ERROR7(...) XBT_ERROR(__VA_ARGS__)
-#define ERROR8(...) XBT_ERROR(__VA_ARGS__)
-#define ERROR9(...) XBT_ERROR(__VA_ARGS__)
-#define ERROR10(...) XBT_ERROR(__VA_ARGS__)
-
-#define CRITICAL0(...) XBT_CRITICAL(__VA_ARGS__)
-#define CRITICAL1(...) XBT_CRITICAL(__VA_ARGS__)
-#define CRITICAL2(...) XBT_CRITICAL(__VA_ARGS__)
-#define CRITICAL3(...) XBT_CRITICAL(__VA_ARGS__)
-#define CRITICAL4(...) XBT_CRITICAL(__VA_ARGS__)
-#define CRITICAL5(...) XBT_CRITICAL(__VA_ARGS__)
-#define CRITICAL6(...) XBT_CRITICAL(__VA_ARGS__)
-#define CRITICAL7(...) XBT_CRITICAL(__VA_ARGS__)
-#define CRITICAL8(...) XBT_CRITICAL(__VA_ARGS__)
-#define CRITICAL9(...) XBT_CRITICAL(__VA_ARGS__)
-#define CRITICAL10(...) XBT_CRITICAL(__VA_ARGS__)
-
-#define XBT_IN1(...) XBT_IN(__VA_ARGS__);
-#define XBT_IN2(...) XBT_IN(__VA_ARGS__);
-#define XBT_IN3(...) XBT_IN(__VA_ARGS__);
-#define XBT_IN4(...) XBT_IN(__VA_ARGS__);
-#define XBT_IN5(...) XBT_IN(__VA_ARGS__);
-#define XBT_IN6(...) XBT_IN(__VA_ARGS__);
-
-#endif
-
SG_END_DECL()
#endif /* ! _XBT_LOG_H_ */
#include "lua_private.h"
#include "src/surf/xml/platf_private.hpp"
+#include "src/surf/network_interface.hpp"
#include "surf/surf_routing.h"
#include <string.h>
#include <ctype.h>
if (type != LUA_TSTRING) {
XBT_ERROR("Attribute 'links' must be specified for any route and must be a string (different links separated by commas or single spaces.");
}
- route.link_list = xbt_str_split(lua_tostring(L, -1), ", \t\r\n");
- if (xbt_dynar_is_empty(route.link_list))
- xbt_dynar_push_as(route.link_list,char*,xbt_strdup(lua_tostring(L, -1)));
+ route.link_list = new std::vector<Link*>();
+ xbt_dynar_t names = xbt_str_split(lua_tostring(L, -1), ", \t\r\n");
+ if (xbt_dynar_is_empty(names)) {
+ /* unique name */
+ route.link_list->push_back(Link::byName(lua_tostring(L, -1)));
+ } else {
+ // Several names separated by , \t\r\n
+ unsigned int cpt;
+ char *name;
+ xbt_dynar_foreach(names, cpt, name) {
+ if (strlen(name)>0) {
+ Link *link = Link::byName(name);
+ route.link_list->push_back(link);
+ }
+ }
+ }
lua_pop(L,1);
/* We are relying on the XML bypassing mechanism since the corresponding sg_platf does not exist yet.
lua_pushstring(L,"links");
lua_gettable(L,-2);
- ASroute.link_list = xbt_str_split(lua_tostring(L, -1), ", \t\r\n");
- if (xbt_dynar_is_empty(ASroute.link_list))
- xbt_dynar_push_as(ASroute.link_list,char*,xbt_strdup(lua_tostring(L, -1)));
+ ASroute.link_list = new std::vector<Link*>();
+ xbt_dynar_t names = xbt_str_split(lua_tostring(L, -1), ", \t\r\n");
+ if (xbt_dynar_is_empty(names)) {
+ /* unique name */
+ ASroute.link_list->push_back(Link::byName(lua_tostring(L, -1)));
+ } else {
+ // Several names separated by , \t\r\n
+ unsigned int cpt;
+ char *name;
+ xbt_dynar_foreach(names, cpt, name) {
+ if (strlen(name)>0) {
+ Link *link = Link::byName(name);
+ ASroute.link_list->push_back(link);
+ }
+ }
+ }
lua_pop(L,1);
lua_pushstring(L,"symmetrical");
double value,
InstrUserVariable what)
{
- xbt_dynar_t route=NULL;
sg_netcard_t src_elm = sg_netcard_by_name_or_null(src);
if(!src_elm) xbt_die("Element '%s' not found!",src);
sg_netcard_t dst_elm = sg_netcard_by_name_or_null(dst);
if(!dst_elm) xbt_die("Element '%s' not found!",dst);
- routing_platf->getRouteAndLatency (src_elm, dst_elm, &route,NULL);
- unsigned int i;
- surf_cpp_resource_t link;
- xbt_dynar_foreach (route, i, link) {
- char *link_name = (char*)surf_resource_name(link);
- instr_user_variable (time, link_name, variable, father_type, value, what, NULL, user_link_variables);
- }
+ std::vector<Link*> *route = new std::vector<Link*>();
+ routing_platf->getRouteAndLatency (src_elm, dst_elm, route,NULL);
+ for (auto link : *route)
+ instr_user_variable (time, link->getName(), variable, father_type, value, what, NULL, user_link_variables);
+ delete route;
}
/** \ingroup TRACE_API
*/
SD_link_t *SD_route_get_list(sg_host_t src, sg_host_t dst)
{
- void *surf_link;
- unsigned int cpt;
- xbt_dynar_t surf_route = NULL;
- routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, &surf_route, NULL);
+ std::vector<Link*> *route = new std::vector<Link*>();
+ routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, route, NULL);
- SD_link_t *list = xbt_new(SD_link_t, xbt_dynar_length(surf_route));
- xbt_dynar_foreach(surf_route, cpt, surf_link) {
- list[cpt] = (SD_link_t)surf_link;
- }
+ int cpt=0;
+ SD_link_t *list = xbt_new(SD_link_t, route->size());
+ for (auto link : *route)
+ list[cpt++] = link;
+
+ delete route;
return list;
}
*/
int SD_route_get_size(sg_host_t src, sg_host_t dst)
{
- xbt_dynar_t surf_route = NULL;
- routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, &surf_route, NULL);
- return xbt_dynar_length(surf_route);
+ std::vector<Link*> *route = new std::vector<Link*>();
+ routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, route, NULL);
+ int size = route->size();
+ delete route;
+ return size;
}
/**
*/
double SD_route_get_latency(sg_host_t src, sg_host_t dst)
{
- xbt_dynar_t route = NULL;
double latency = 0;
-
- routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, &route, &latency);
+ std::vector<Link*> *route = new std::vector<Link*>();
+ routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, route, &latency);
+ delete route;
return latency;
}
*/
double SD_route_get_bandwidth(sg_host_t src, sg_host_t dst)
{
- xbt_dynar_t route = NULL;
- unsigned int cpt;
- double latency = 0;
double min_bandwidth = -1.0;
- SD_link_t link;
- routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, &route, &latency);
+ std::vector<Link*> *route = new std::vector<Link*>();
+ routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, route, NULL);
- xbt_dynar_foreach(route, cpt, link){
+ for (auto link : *route) {
double bandwidth = sg_link_bandwidth(link);
if (bandwidth < min_bandwidth || min_bandwidth == -1.0)
min_bandwidth = bandwidth;
}
+ delete route;
return min_bandwidth;
}
const char* name = nullptr;
simgrid::s4u::Host* host = nullptr;
xbt_dict_foreach(host_list, cursor, name, host)
- if (host && host->pimpl_netcard && host->pimpl_netcard->getRcType() == SURF_NETWORK_ELEMENT_HOST)
+ if (host && host->pimpl_netcard && host->pimpl_netcard->isHost())
xbt_dynar_push(res, &host);
return res;
}
Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst,
double size, double rate)
{
- unsigned int i;
- void *_link;
- NetworkCm02Link *link;
int failed = 0;
NetworkCm02Action *action = NULL;
double bandwidth_bound;
double latency = 0.0;
- xbt_dynar_t back_route = NULL;
+ std::vector<Link*> * back_route = NULL;
int constraints_per_variable = 0;
- xbt_dynar_t route = xbt_dynar_new(sizeof(NetCard*), NULL);
+ std::vector<Link*> *route = new std::vector<Link*>();
XBT_IN("(%s,%s,%g,%g)", src->name(), dst->name(), size, rate);
- routing_platf->getRouteAndLatency(src, dst, &route, &latency);
- xbt_assert(!xbt_dynar_is_empty(route) || latency,
+ routing_platf->getRouteAndLatency(src, dst, route, &latency);
+ xbt_assert(! route->empty() || latency,
"You're trying to send data from %s to %s but there is no connecting path between these two hosts.",
src->name(), dst->name());
- xbt_dynar_foreach(route, i, _link) {
- link = static_cast<NetworkCm02Link*>(_link);
- if (link->isOff()) {
+ for (auto link: *route)
+ if (link->isOff())
failed = 1;
- break;
- }
- }
+
if (sg_network_crosstraffic == 1) {
- routing_platf->getRouteAndLatency(dst, src, &back_route, NULL);
- xbt_dynar_foreach(back_route, i, _link) {
- link = static_cast<NetworkCm02Link*>(_link);
- if (link->isOff()) {
+ back_route = new std::vector<Link*>();
+ routing_platf->getRouteAndLatency(dst, src, back_route, NULL);
+ for (auto link: *back_route)
+ if (link->isOff())
failed = 1;
- break;
- }
- }
}
action = new NetworkCm02Action(this, size, failed);
}
bandwidth_bound = -1.0;
- if (sg_weight_S_parameter > 0) {
- xbt_dynar_foreach(route, i, _link) {
- link = static_cast<NetworkCm02Link*>(_link);
+ if (sg_weight_S_parameter > 0)
+ for (auto link : *route)
action->m_weight += sg_weight_S_parameter / link->getBandwidth();
- }
- }
- xbt_dynar_foreach(route, i, _link) {
- link = static_cast<NetworkCm02Link*>(_link);
+
+ for (auto link : *route) {
double bb = bandwidthFactor(size) * link->getBandwidth();
- bandwidth_bound =
- (bandwidth_bound < 0.0) ? bb : std::min(bandwidth_bound, bb);
+ bandwidth_bound = (bandwidth_bound < 0.0) ? bb : std::min(bandwidth_bound, bb);
}
action->m_latCurrent = action->m_latency;
action->m_latency *= latencyFactor(size);
action->m_rate = bandwidthConstraint(action->m_rate, bandwidth_bound, size);
if (m_haveGap) {
- xbt_assert(!xbt_dynar_is_empty(route),
+ xbt_assert(! route->empty(),
"Using a model with a gap (e.g., SMPI) with a platform without links (e.g. vivaldi)!!!");
- link = *static_cast<NetworkCm02Link **>(xbt_dynar_get_ptr(route, 0));
- gapAppend(size, link, action);
- XBT_DEBUG("Comm %p: %s -> %s gap=%f (lat=%f)",
- action, src->name(), dst->name(), action->m_senderGap,
- action->m_latency);
+ gapAppend(size, route->at(0), action);
+ XBT_DEBUG("Comm %p: %s -> %s gap=%f (lat=%f)", action, src->name(), dst->name(), action->m_senderGap, action->m_latency);
}
- constraints_per_variable = xbt_dynar_length(route);
+ constraints_per_variable = route->size();
if (back_route != NULL)
- constraints_per_variable += xbt_dynar_length(back_route);
+ constraints_per_variable += back_route->size();
if (action->m_latency > 0) {
action->p_variable = lmm_variable_new(p_maxminSystem, action, 0.0, -1.0,
constraints_per_variable);
if (p_updateMechanism == UM_LAZY) {
// add to the heap the event when the latency is payed
- XBT_DEBUG("Added action (%p) one latency event at date %f", action,
- action->m_latency + action->m_lastUpdate);
- action->heapInsert(p_actionHeap, action->m_latency + action->m_lastUpdate, xbt_dynar_is_empty(route) ? NORMAL : LATENCY);
+ XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->m_latency + action->m_lastUpdate);
+ action->heapInsert(p_actionHeap, action->m_latency + action->m_lastUpdate, route->empty() ? NORMAL : LATENCY);
}
} else
action->p_variable = lmm_variable_new(p_maxminSystem, action, 1.0, -1.0, constraints_per_variable);
lmm_update_variable_bound(p_maxminSystem, action->getVariable(), (action->m_latCurrent > 0) ? std::min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)) : action->m_rate);
}
- xbt_dynar_foreach(route, i, _link) {
- link = static_cast<NetworkCm02Link*>(_link);
+ for (auto link: *route)
lmm_expand(p_maxminSystem, link->getConstraint(), action->getVariable(), 1.0);
- }
if (sg_network_crosstraffic == 1) {
XBT_DEBUG("Fullduplex active adding backward flow using 5%%");
- xbt_dynar_foreach(back_route, i, _link) {
- link = static_cast<NetworkCm02Link*>(_link);
+ for (auto link : *back_route)
lmm_expand(p_maxminSystem, link->getConstraint(), action->getVariable(), .05);
- }
lmm_variable_concurrency_share_set(action->getVariable(),2);
}
- xbt_dynar_free(&route);
+ delete route;
XBT_OUT();
networkCommunicateCallbacks(action, src, dst, size, rate);
routing_model_create(NULL);
simgrid::surf::on_link.connect([](sg_platf_link_cbarg_t link){
- xbt_die("There is no link in the Constant network model. "
- "Please remove any link from your platform (and switch to routing='None')");
+ xbt_die("There is no link in the Constant network model. "
+ "Please remove any link from your platform (and switch to routing='None')");
});
}
namespace simgrid {
-namespace surf {
-
-double NetworkConstantModel::next_occuring_event(double /*now*/)
-{
- NetworkConstantAction *action = NULL;
- double min = -1.0;
-
- ActionList *actionSet = getRunningActionSet();
- for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end())
- ; it != itend ; ++it) {
- action = static_cast<NetworkConstantAction*>(&*it);
- if (action->m_latency > 0 && (min < 0 || action->m_latency < min))
- min = action->m_latency;
- }
+ namespace surf {
+
+ double NetworkConstantModel::next_occuring_event(double /*now*/)
+ {
+ NetworkConstantAction *action = NULL;
+ double min = -1.0;
+
+ ActionList *actionSet = getRunningActionSet();
+ for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end())
+ ; it != itend ; ++it) {
+ action = static_cast<NetworkConstantAction*>(&*it);
+ if (action->m_latency > 0 && (min < 0 || action->m_latency < min))
+ min = action->m_latency;
+ }
- return min;
-}
+ return min;
+ }
-void NetworkConstantModel::updateActionsState(double /*now*/, double delta)
-{
- NetworkConstantAction *action = NULL;
- ActionList *actionSet = getRunningActionSet();
- for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end())
- ; it != itend ; it=itNext) {
- ++itNext;
- action = static_cast<NetworkConstantAction*>(&*it);
- if (action->m_latency > 0) {
- if (action->m_latency > delta) {
- double_update(&(action->m_latency), delta, sg_surf_precision);
- } else {
- action->m_latency = 0.0;
+ void NetworkConstantModel::updateActionsState(double /*now*/, double delta)
+ {
+ NetworkConstantAction *action = NULL;
+ ActionList *actionSet = getRunningActionSet();
+ for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end())
+ ; it != itend ; it=itNext) {
+ ++itNext;
+ action = static_cast<NetworkConstantAction*>(&*it);
+ if (action->m_latency > 0) {
+ if (action->m_latency > delta) {
+ double_update(&(action->m_latency), delta, sg_surf_precision);
+ } else {
+ action->m_latency = 0.0;
+ }
+ }
+ action->updateRemains(action->getCost() * delta / action->m_latInit);
+ if (action->getMaxDuration() != NO_MAX_DURATION)
+ action->updateMaxDuration(delta);
+
+ if (action->getRemainsNoUpdate() <= 0) {
+ action->finish();
+ action->setState(SURF_ACTION_DONE);
+ } else if ((action->getMaxDuration() != NO_MAX_DURATION)
+ && (action->getMaxDuration() <= 0)) {
+ action->finish();
+ action->setState(SURF_ACTION_DONE);
+ }
}
}
- action->updateRemains(action->getCost() * delta / action->m_latInit);
- if (action->getMaxDuration() != NO_MAX_DURATION)
- action->updateMaxDuration(delta);
-
- if (action->getRemainsNoUpdate() <= 0) {
- action->finish();
- action->setState(SURF_ACTION_DONE);
- } else if ((action->getMaxDuration() != NO_MAX_DURATION)
- && (action->getMaxDuration() <= 0)) {
- action->finish();
- action->setState(SURF_ACTION_DONE);
- }
- }
-}
-
-Action *NetworkConstantModel::communicate(NetCard *src, NetCard *dst,
- double size, double rate)
-{
- char *src_name = src->name();
- char *dst_name = dst->name();
- XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
- NetworkConstantAction *action = new NetworkConstantAction(this, size, sg_latency_factor);
- XBT_OUT();
+ Action *NetworkConstantModel::communicate(NetCard *src, NetCard *dst,
+ double size, double rate)
+ {
+ char *src_name = src->name();
+ char *dst_name = dst->name();
- networkCommunicateCallbacks(action, src, dst, size, rate);
- return action;
-}
+ XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
+ NetworkConstantAction *action = new NetworkConstantAction(this, size, sg_latency_factor);
+ XBT_OUT();
-/**********
- * Action *
- **********/
+ networkCommunicateCallbacks(action, src, dst, size, rate);
+ return action;
+ }
-int NetworkConstantAction::unref()
-{
- m_refcount--;
- if (!m_refcount) {
- if (action_hook.is_linked())
- p_stateSet->erase(p_stateSet->iterator_to(*this));
- delete this;
- return 1;
- }
- return 0;
-}
+ /**********
+ * Action *
+ **********/
+
+ int NetworkConstantAction::unref()
+ {
+ m_refcount--;
+ if (!m_refcount) {
+ if (action_hook.is_linked())
+ p_stateSet->erase(p_stateSet->iterator_to(*this));
+ delete this;
+ return 1;
+ }
+ return 0;
+ }
-void NetworkConstantAction::cancel()
-{
- return;
-}
+ void NetworkConstantAction::cancel()
+ {
+ return;
+ }
-}
+ }
}
#include "network_interface.hpp"
namespace simgrid {
-namespace surf {
+ namespace surf {
-/***********
- * Classes *
- ***********/
-
-class XBT_PRIVATE NetworkConstantModel;
-class XBT_PRIVATE NetworkConstantAction;
+ /***********
+ * Classes *
+ ***********/
-/*********
- * Model *
- *********/
-class NetworkConstantModel : public NetworkModel {
-public:
- NetworkConstantModel() : NetworkModel() { };
- ~NetworkConstantModel() { }
+ class XBT_PRIVATE NetworkConstantModel;
+ class XBT_PRIVATE NetworkConstantAction;
- Action *communicate(NetCard *src, NetCard *dst, double size, double rate) override;
- double next_occuring_event(double now) override;
- bool next_occuring_event_isIdempotent() override {return true;}
- void updateActionsState(double now, double delta) override;
+ /*********
+ * Model *
+ *********/
+ class NetworkConstantModel : public NetworkModel {
+ public:
+ NetworkConstantModel() : NetworkModel() { };
+ ~NetworkConstantModel() { }
- Link*
- createLink(const char *name,
- double bw_initial, tmgr_trace_t bw_trace,
- double lat_initial, tmgr_trace_t lat_trace,
- tmgr_trace_t state_trace,
- e_surf_link_sharing_policy_t policy,
- xbt_dict_t properties) override { DIE_IMPOSSIBLE; }
-};
+ Action *communicate(NetCard *src, NetCard *dst, double size, double rate) override;
+ double next_occuring_event(double now) override;
+ bool next_occuring_event_isIdempotent() override {return true;}
+ void updateActionsState(double now, double delta) override;
-/**********
- * Action *
- **********/
-class NetworkConstantAction : public NetworkAction {
-public:
- NetworkConstantAction(NetworkConstantModel *model_, double size, double latency)
- : NetworkAction(model_, size, false)
- , m_latInit(latency)
- {
- m_latency = latency;
- if (m_latency <= 0.0) {
- p_stateSet = getModel()->getDoneActionSet();
- p_stateSet->push_back(*this);
- }
- p_variable = NULL;
- };
- int unref() override;
- void cancel() override;
- double m_latInit;
-};
+ Link*
+ createLink(const char *name,
+ double bw_initial, tmgr_trace_t bw_trace,
+ double lat_initial, tmgr_trace_t lat_trace,
+ tmgr_trace_t state_trace,
+ e_surf_link_sharing_policy_t policy,
+ xbt_dict_t properties) override { DIE_IMPOSSIBLE; }
+ };
-}
+ /**********
+ * Action *
+ **********/
+ class NetworkConstantAction : public NetworkAction {
+ public:
+ NetworkConstantAction(NetworkConstantModel *model_, double size, double latency)
+ : NetworkAction(model_, size, false)
+ , m_latInit(latency)
+ {
+ m_latency = latency;
+ if (m_latency <= 0.0) {
+ p_stateSet = getModel()->getDoneActionSet();
+ p_stateSet->push_back(*this);
+ }
+ p_variable = NULL;
+ };
+ int unref() override;
+ void cancel() override;
+ double m_latInit;
+ };
+
+ }
}
#endif /* NETWORK_CONSTANT_HPP_ */
static void IB_create_host_callback(simgrid::s4u::Host& host){
using namespace simgrid::surf;
-
+
static int id=0;
-// pour t->id -> rajouter une nouvelle struct dans le dict, pour stocker les comms actives
+ // pour t->id -> rajouter une nouvelle struct dans le dict, pour stocker les comms actives
if(((NetworkIBModel*)surf_network_model)->active_nodes==NULL)
((NetworkIBModel*)surf_network_model)->active_nodes=xbt_dict_new();
-
+
IBNode* act = new IBNode(id);
id++;
xbt_dict_set(((NetworkIBModel*)surf_network_model)->active_nodes,
- host.name().c_str(), act, NULL);
+ host.name().c_str(), act, NULL);
}
static void IB_action_state_changed_callback(
- simgrid::surf::NetworkAction *action,
- e_surf_action_state_t statein, e_surf_action_state_t stateout)
+ simgrid::surf::NetworkAction *action,
+ e_surf_action_state_t statein, e_surf_action_state_t stateout)
{
- using namespace simgrid::surf;
- if(statein!=SURF_ACTION_RUNNING|| stateout!=SURF_ACTION_DONE)
+ using namespace simgrid::surf;
+ if(statein!=SURF_ACTION_RUNNING|| stateout!=SURF_ACTION_DONE)
return;
std::pair<IBNode*,IBNode*> pair = ((NetworkIBModel*)surf_network_model)->active_comms[action];
XBT_DEBUG("IB callback - action %p finished", action);
-
- ((NetworkIBModel*)surf_network_model)->updateIBfactors(action, pair.first, pair.second, 1);
+
+ ((NetworkIBModel*)surf_network_model)->updateIBfactors(action, pair.first, pair.second, 1);
((NetworkIBModel*)surf_network_model)->active_comms.erase(action);
-
+
}
static void IB_action_init_callback(
- simgrid::surf::NetworkAction *action, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst,
- double size, double rate)
+ simgrid::surf::NetworkAction *action, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst,
+ double size, double rate)
{
using namespace simgrid::surf;
if(((NetworkIBModel*)surf_network_model)->active_nodes==NULL)
xbt_die("IB comm added, without any node connected !");
-
+
IBNode* act_src= (IBNode*) xbt_dict_get_or_null(((NetworkIBModel*)surf_network_model)->active_nodes, src->name());
if(act_src==NULL)
xbt_die("could not find src node active comms !");
//act_src->rate=rate;
-
+
IBNode* act_dst= (IBNode*) xbt_dict_get_or_null(((NetworkIBModel*)surf_network_model)->active_nodes, dst->name());
if(act_dst==NULL)
xbt_die("could not find dst node active comms !");
- // act_dst->rate=rate;
-
+ // act_dst->rate=rate;
+
((NetworkIBModel*)surf_network_model)->active_comms[action]=std::make_pair(act_src, act_dst);
//post the action in the second dist, to retrieve in the other callback
XBT_DEBUG("IB callback - action %p init", action);
((NetworkIBModel*)surf_network_model)->updateIBfactors(action, act_src, act_dst, 0);
-
+
}
/*********
networkCommunicateCallbacks.connect(IB_action_init_callback);
simgrid::s4u::Host::onCreation.connect(IB_create_host_callback);
xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 8775);
-
+
}
#include "src/surf/xml/platf.hpp" // FIXME: move that back to the parsing area
namespace simgrid {
-namespace surf {
-
-NetworkIBModel::NetworkIBModel()
- : NetworkSmpiModel() {
- m_haveGap=false;
- active_nodes=NULL;
-
- const char* IB_factors_string=sg_cfg_get_string("smpi/IB_penalty_factors");
- xbt_dynar_t radical_elements = xbt_str_split(IB_factors_string, ";");
-
- surf_parse_assert(xbt_dynar_length(radical_elements)==3,
- "smpi/IB_penalty_factors should be provided and contain 3 elements, semi-colon separated : for example 0.965;0.925;1.35");
-
- Be = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 0, char *), "First part of smpi/IB_penalty_factors is not numerical: %s");
- Bs = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 1, char *), "Second part of smpi/IB_penalty_factors is not numerical: %s");
- ys = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 2, char *), "Third part of smpi/IB_penalty_factors is not numerical: %s");
-
- xbt_dynar_free(&radical_elements);
-}
+ namespace surf {
-NetworkIBModel::~NetworkIBModel()
-{
- xbt_dict_cursor_t cursor = NULL;
- IBNode* instance = NULL;
- char *name = NULL;
- xbt_dict_foreach(active_nodes, cursor, name, instance)
- delete instance;
- xbt_dict_free(&active_nodes);
-}
+ NetworkIBModel::NetworkIBModel()
+ : NetworkSmpiModel() {
+ m_haveGap=false;
+ active_nodes=NULL;
-void NetworkIBModel::computeIBfactors(IBNode *root) {
- double penalized_bw=0.0;
- double num_comm_out = (double) root->ActiveCommsUp.size();
- double max_penalty_out=0.0;
- //first, compute all outbound penalties to get their max
- for (std::vector<ActiveComm*>::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) {
- double my_penalty_out = 1.0;
-
- if(num_comm_out!=1){
- if((*it)->destination->nbActiveCommsDown > 2)//number of comms sent to the receiving node
- my_penalty_out = num_comm_out * Bs * ys;
- else
- my_penalty_out = num_comm_out * Bs;
- }
+ const char* IB_factors_string=sg_cfg_get_string("smpi/IB_penalty_factors");
+ xbt_dynar_t radical_elements = xbt_str_split(IB_factors_string, ";");
- max_penalty_out = std::max(max_penalty_out,my_penalty_out);
- }
+ surf_parse_assert(xbt_dynar_length(radical_elements)==3,
+ "smpi/IB_penalty_factors should be provided and contain 3 elements, semi-colon separated : for example 0.965;0.925;1.35");
- for (std::vector<ActiveComm*>::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) {
-
- //compute inbound penalty
- double my_penalty_in = 1.0;
- int nb_comms = (*it)->destination->nbActiveCommsDown;//total number of incoming comms
- if(nb_comms!=1)
- my_penalty_in = ((*it)->destination->ActiveCommsDown)[root] //number of comm sent to dest by root node
- * Be
- * (*it)->destination->ActiveCommsDown.size();//number of different nodes sending to dest
-
- double penalty = std::max(my_penalty_in,max_penalty_out);
-
- double rate_before_update = (*it)->action->getBound();
- //save initial rate of the action
- if((*it)->init_rate==-1)
- (*it)->init_rate= rate_before_update;
-
- penalized_bw= ! num_comm_out ? (*it)->init_rate : (*it)->init_rate /penalty;
-
- if (!double_equals(penalized_bw, rate_before_update, sg_surf_precision)){
- XBT_DEBUG("%d->%d action %p penalty updated : bw now %f, before %f , initial rate %f", root->id,(*it)->destination->id,(*it)->action,penalized_bw, (*it)->action->getBound(), (*it)->init_rate );
- lmm_update_variable_bound(p_maxminSystem, (*it)->action->getVariable(), penalized_bw);
- }else{
- XBT_DEBUG("%d->%d action %p penalty not updated : bw %f, initial rate %f", root->id,(*it)->destination->id,(*it)->action,penalized_bw, (*it)->init_rate );
+ Be = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 0, char *), "First part of smpi/IB_penalty_factors is not numerical: %s");
+ Bs = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 1, char *), "Second part of smpi/IB_penalty_factors is not numerical: %s");
+ ys = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 2, char *), "Third part of smpi/IB_penalty_factors is not numerical: %s");
+
+ xbt_dynar_free(&radical_elements);
}
- }
- XBT_DEBUG("Finished computing IB penalties");
-}
+ NetworkIBModel::~NetworkIBModel()
+ {
+ xbt_dict_cursor_t cursor = NULL;
+ IBNode* instance = NULL;
+ char *name = NULL;
+ xbt_dict_foreach(active_nodes, cursor, name, instance)
+ delete instance;
+ xbt_dict_free(&active_nodes);
+ }
-void NetworkIBModel::updateIBfactors_rec(IBNode *root, bool* updatedlist) {
- if(updatedlist[root->id]==0){
- XBT_DEBUG("IB - Updating rec %d", root->id);
- computeIBfactors(root);
- updatedlist[root->id]=1;
- for (std::vector<ActiveComm*>::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) {
- if(updatedlist[(*it)->destination->id]!=1)
- updateIBfactors_rec((*it)->destination, updatedlist);
+ void NetworkIBModel::computeIBfactors(IBNode *root) {
+ double penalized_bw=0.0;
+ double num_comm_out = (double) root->ActiveCommsUp.size();
+ double max_penalty_out=0.0;
+ //first, compute all outbound penalties to get their max
+ for (std::vector<ActiveComm*>::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) {
+ double my_penalty_out = 1.0;
+
+ if(num_comm_out!=1){
+ if((*it)->destination->nbActiveCommsDown > 2)//number of comms sent to the receiving node
+ my_penalty_out = num_comm_out * Bs * ys;
+ else
+ my_penalty_out = num_comm_out * Bs;
+ }
+
+ max_penalty_out = std::max(max_penalty_out,my_penalty_out);
+ }
+
+ for (std::vector<ActiveComm*>::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) {
+
+ //compute inbound penalty
+ double my_penalty_in = 1.0;
+ int nb_comms = (*it)->destination->nbActiveCommsDown;//total number of incoming comms
+ if(nb_comms!=1)
+ my_penalty_in = ((*it)->destination->ActiveCommsDown)[root] //number of comm sent to dest by root node
+ * Be
+ * (*it)->destination->ActiveCommsDown.size();//number of different nodes sending to dest
+
+ double penalty = std::max(my_penalty_in,max_penalty_out);
+
+ double rate_before_update = (*it)->action->getBound();
+ //save initial rate of the action
+ if((*it)->init_rate==-1)
+ (*it)->init_rate= rate_before_update;
+
+ penalized_bw= ! num_comm_out ? (*it)->init_rate : (*it)->init_rate /penalty;
+
+ if (!double_equals(penalized_bw, rate_before_update, sg_surf_precision)){
+ XBT_DEBUG("%d->%d action %p penalty updated : bw now %f, before %f , initial rate %f", root->id,(*it)->destination->id,(*it)->action,penalized_bw, (*it)->action->getBound(), (*it)->init_rate );
+ lmm_update_variable_bound(p_maxminSystem, (*it)->action->getVariable(), penalized_bw);
+ }else{
+ XBT_DEBUG("%d->%d action %p penalty not updated : bw %f, initial rate %f", root->id,(*it)->destination->id,(*it)->action,penalized_bw, (*it)->init_rate );
+ }
+
+ }
+ XBT_DEBUG("Finished computing IB penalties");
}
- for (std::map<IBNode*, int>::iterator it= root->ActiveCommsDown.begin(); it != root->ActiveCommsDown.end(); ++it) {
- if(updatedlist[it->first->id]!=1)
- updateIBfactors_rec(it->first, updatedlist);
+
+ void NetworkIBModel::updateIBfactors_rec(IBNode *root, bool* updatedlist) {
+ if(updatedlist[root->id]==0){
+ XBT_DEBUG("IB - Updating rec %d", root->id);
+ computeIBfactors(root);
+ updatedlist[root->id]=1;
+ for (std::vector<ActiveComm*>::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) {
+ if(updatedlist[(*it)->destination->id]!=1)
+ updateIBfactors_rec((*it)->destination, updatedlist);
+ }
+ for (std::map<IBNode*, int>::iterator it= root->ActiveCommsDown.begin(); it != root->ActiveCommsDown.end(); ++it) {
+ if(updatedlist[it->first->id]!=1)
+ updateIBfactors_rec(it->first, updatedlist);
+ }
+ }
}
- }
-}
-void NetworkIBModel::updateIBfactors(NetworkAction *action, IBNode *from, IBNode * to, int remove) {
- if (from == to)//disregard local comms (should use loopback)
- return;
-
- bool* updated=(bool*)xbt_malloc0(xbt_dict_size(active_nodes)*sizeof(bool));
- ActiveComm* comm=NULL;
- if(remove){
- if(to->ActiveCommsDown[from]==1)
- to->ActiveCommsDown.erase(from);
- else
- to->ActiveCommsDown[from]-=1;
-
- to->nbActiveCommsDown--;
- for (std::vector<ActiveComm*>::iterator it= from->ActiveCommsUp.begin();
- it != from->ActiveCommsUp.end(); ++it) {
- if((*it)->action==action){
- comm=(*it);
- from->ActiveCommsUp.erase(it);
- break;
+ void NetworkIBModel::updateIBfactors(NetworkAction *action, IBNode *from, IBNode * to, int remove) {
+ if (from == to)//disregard local comms (should use loopback)
+ return;
+
+ bool* updated=(bool*)xbt_malloc0(xbt_dict_size(active_nodes)*sizeof(bool));
+ ActiveComm* comm=NULL;
+ if(remove){
+ if(to->ActiveCommsDown[from]==1)
+ to->ActiveCommsDown.erase(from);
+ else
+ to->ActiveCommsDown[from]-=1;
+
+ to->nbActiveCommsDown--;
+ for (std::vector<ActiveComm*>::iterator it= from->ActiveCommsUp.begin();
+ it != from->ActiveCommsUp.end(); ++it) {
+ if((*it)->action==action){
+ comm=(*it);
+ from->ActiveCommsUp.erase(it);
+ break;
+ }
+ }
+ action->unref();
+
+ }else{
+ action->ref();
+ ActiveComm* comm=new ActiveComm();
+ comm->action=action;
+ comm->destination=to;
+ from->ActiveCommsUp.push_back(comm);
+
+ to->ActiveCommsDown[from]+=1;
+ to->nbActiveCommsDown++;
}
+ XBT_DEBUG("IB - Updating %d", from->id);
+ updateIBfactors_rec(from, updated);
+ XBT_DEBUG("IB - Finished updating %d", from->id);
+ if(comm)
+ delete comm;
+ xbt_free(updated);
}
- action->unref();
- }else{
- action->ref();
- ActiveComm* comm=new ActiveComm();
- comm->action=action;
- comm->destination=to;
- from->ActiveCommsUp.push_back(comm);
-
- to->ActiveCommsDown[from]+=1;
- to->nbActiveCommsDown++;
}
- XBT_DEBUG("IB - Updating %d", from->id);
- updateIBfactors_rec(from, updated);
- XBT_DEBUG("IB - Finished updating %d", from->id);
- if(comm)
- delete comm;
- xbt_free(updated);
-}
-
-}
}
#include "network_smpi.hpp"
namespace simgrid {
-namespace surf {
+ namespace surf {
-class XBT_PRIVATE IBNode;
+ class XBT_PRIVATE IBNode;
-class XBT_PRIVATE ActiveComm{
-public :
- //IBNode* origin;
- IBNode* destination;
- NetworkAction *action;
- double init_rate;
- ActiveComm() : destination(NULL),action(NULL),init_rate(-1){};
- ~ActiveComm(){};
-};
+ class XBT_PRIVATE ActiveComm{
+ public :
+ //IBNode* origin;
+ IBNode* destination;
+ NetworkAction *action;
+ double init_rate;
+ ActiveComm() : destination(NULL),action(NULL),init_rate(-1){};
+ ~ActiveComm(){};
+ };
-class IBNode{
-public :
- int id;
- //store related links, to ease computation of the penalties
- std::vector<ActiveComm*> ActiveCommsUp;
- //store the number of comms received from each node
- std::map<IBNode*, int> ActiveCommsDown;
- //number of comms the node is receiving
- int nbActiveCommsDown;
- IBNode(int id) : id(id),nbActiveCommsDown(0){};
- ~IBNode(){};
-};
+ class IBNode{
+ public :
+ int id;
+ //store related links, to ease computation of the penalties
+ std::vector<ActiveComm*> ActiveCommsUp;
+ //store the number of comms received from each node
+ std::map<IBNode*, int> ActiveCommsDown;
+ //number of comms the node is receiving
+ int nbActiveCommsDown;
+ IBNode(int id) : id(id),nbActiveCommsDown(0){};
+ ~IBNode(){};
+ };
-class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel {
-private:
- void updateIBfactors_rec(IBNode *root, bool* updatedlist);
- void computeIBfactors(IBNode *root);
-public:
- NetworkIBModel();
- NetworkIBModel(const char *name);
- ~NetworkIBModel();
- void updateIBfactors(NetworkAction *action, IBNode *from, IBNode * to, int remove);
-
- xbt_dict_t active_nodes;
- std::map<NetworkAction *, std::pair<IBNode*,IBNode*> > active_comms;
-
- double Bs;
- double Be;
- double ys;
+ class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel {
+ private:
+ void updateIBfactors_rec(IBNode *root, bool* updatedlist);
+ void computeIBfactors(IBNode *root);
+ public:
+ NetworkIBModel();
+ NetworkIBModel(const char *name);
+ ~NetworkIBModel();
+ void updateIBfactors(NetworkAction *action, IBNode *from, IBNode * to, int remove);
-};
+ xbt_dict_t active_nodes;
+ std::map<NetworkAction *, std::pair<IBNode*,IBNode*> > active_comms;
-}
+ double Bs;
+ double Be;
+ double ys;
+
+ };
+
+ }
}
#endif
#define NETWORK_INTERFACE_CPP_
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf,
- "Logging specific to the SURF network module");
+ "Logging specific to the SURF network module");
/*********
* C API *
extern "C" {
-const char* sg_link_name(Link *link) {
- return link->getName();
-}
-Link * sg_link_by_name(const char* name) {
- return Link::byName(name);
-}
+ const char* sg_link_name(Link *link) {
+ return link->getName();
+ }
+ Link * sg_link_by_name(const char* name) {
+ return Link::byName(name);
+ }
-int sg_link_is_shared(Link *link){
- return link->sharingPolicy();
-}
-double sg_link_bandwidth(Link *link){
- return link->getBandwidth();
-}
-double sg_link_latency(Link *link){
- return link->getLatency();
-}
-void* sg_link_data(Link *link) {
- return link->getData();
-}
-void sg_link_data_set(Link *link,void *data) {
- link->setData(data);
-}
-int sg_link_count(void) {
- return Link::linksCount();
-}
-Link** sg_link_list(void) {
- return Link::linksList();
-}
-void sg_link_exit(void) {
- Link::linksExit();
-}
+ int sg_link_is_shared(Link *link){
+ return link->sharingPolicy();
+ }
+ double sg_link_bandwidth(Link *link){
+ return link->getBandwidth();
+ }
+ double sg_link_latency(Link *link){
+ return link->getLatency();
+ }
+ void* sg_link_data(Link *link) {
+ return link->getData();
+ }
+ void sg_link_data_set(Link *link,void *data) {
+ link->setData(data);
+ }
+ int sg_link_count(void) {
+ return Link::linksCount();
+ }
+ Link** sg_link_list(void) {
+ return Link::linksList();
+ }
+ void sg_link_exit(void) {
+ Link::linksExit();
+ }
}
*****************/
namespace simgrid {
-namespace surf {
+ namespace surf {
-boost::unordered_map<std::string,Link *> *Link::links = new boost::unordered_map<std::string,Link *>();
-Link *Link::byName(const char* name) {
- Link * res = NULL;
- try {
- res = links->at(name);
- } catch (std::out_of_range& e) {}
+ boost::unordered_map<std::string,Link *> *Link::links = new boost::unordered_map<std::string,Link *>();
+ Link *Link::byName(const char* name) {
+ Link * res = NULL;
+ try {
+ res = links->at(name);
+ } catch (std::out_of_range& e) {}
- return res;
-}
-/** @brief Returns the amount of links in the platform */
-int Link::linksCount() {
- return links->size();
-}
-/** @brief Returns a list of all existing links */
-Link **Link::linksList() {
- Link **res = xbt_new(Link*, (int)links->size());
- int i=0;
- for (auto kv : *links) {
- res[i++] = kv.second;
+ return res;
+ }
+ /** @brief Returns the amount of links in the platform */
+ int Link::linksCount() {
+ return links->size();
+ }
+ /** @brief Returns a list of all existing links */
+ Link **Link::linksList() {
+ Link **res = xbt_new(Link*, (int)links->size());
+ int i=0;
+ for (auto kv : *links) {
+ res[i++] = kv.second;
+ }
+ return res;
+ }
+ /** @brief destructor of the static data */
+ void Link::linksExit() {
+ for (auto kv : *links)
+ (kv.second)->destroy();
+ delete links;
}
- return res;
-}
-/** @brief destructor of the static data */
-void Link::linksExit() {
- for (auto kv : *links)
- (kv.second)->destroy();
- delete links;
-}
-/*************
- * Callbacks *
- *************/
+ /*************
+ * Callbacks *
+ *************/
-simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onCreation;
-simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onDestruction;
-simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onStateChange;
+ simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onCreation;
+ simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onDestruction;
+ simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onStateChange;
-simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, e_surf_action_state_t, e_surf_action_state_t)> networkActionStateChangedCallbacks;
-simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst, double size, double rate)> networkCommunicateCallbacks;
+ simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, e_surf_action_state_t, e_surf_action_state_t)> networkActionStateChangedCallbacks;
+ simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst, double size, double rate)> networkCommunicateCallbacks;
-}
+ }
}
void netlink_parse_init(sg_platf_link_cbarg_t link){
char *link_id;
link_id = bprintf("%s_UP", link->id);
surf_network_model->createLink(link_id,
- link->bandwidth,
- link->bandwidth_trace,
- link->latency,
- link->latency_trace,
- link->state_trace, link->policy, link->properties);
+ link->bandwidth,
+ link->bandwidth_trace,
+ link->latency,
+ link->latency_trace,
+ link->state_trace, link->policy, link->properties);
xbt_free(link_id);
link_id = bprintf("%s_DOWN", link->id);
surf_network_model->createLink(link_id,
- link->bandwidth,
- link->bandwidth_trace,
- link->latency,
- link->latency_trace,
- link->state_trace, link->policy, link->properties);
+ link->bandwidth,
+ link->bandwidth_trace,
+ link->latency,
+ link->latency_trace,
+ link->state_trace, link->policy, link->properties);
xbt_free(link_id);
} else {
surf_network_model->createLink(link->id,
simgrid::surf::NetworkModel *surf_network_model = NULL;
namespace simgrid {
-namespace surf {
+ namespace surf {
-double NetworkModel::latencyFactor(double /*size*/) {
- return sg_latency_factor;
-}
+ double NetworkModel::latencyFactor(double /*size*/) {
+ return sg_latency_factor;
+ }
-double NetworkModel::bandwidthFactor(double /*size*/) {
- return sg_bandwidth_factor;
-}
+ double NetworkModel::bandwidthFactor(double /*size*/) {
+ return sg_bandwidth_factor;
+ }
-double NetworkModel::bandwidthConstraint(double rate, double /*bound*/, double /*size*/) {
- return rate;
-}
+ double NetworkModel::bandwidthConstraint(double rate, double /*bound*/, double /*size*/) {
+ return rate;
+ }
-double NetworkModel::next_occuring_event_full(double now)
-{
- NetworkAction *action = NULL;
- ActionList *runningActions = surf_network_model->getRunningActionSet();
- double minRes;
+ double NetworkModel::next_occuring_event_full(double now)
+ {
+ NetworkAction *action = NULL;
+ ActionList *runningActions = surf_network_model->getRunningActionSet();
+ double minRes;
- minRes = shareResourcesMaxMin(runningActions, surf_network_model->p_maxminSystem, surf_network_model->f_networkSolve);
+ minRes = shareResourcesMaxMin(runningActions, surf_network_model->p_maxminSystem, surf_network_model->f_networkSolve);
- for(ActionList::iterator it(runningActions->begin()), itend(runningActions->end())
- ; it != itend ; ++it) {
- action = static_cast<NetworkAction*>(&*it);
+ for(ActionList::iterator it(runningActions->begin()), itend(runningActions->end())
+ ; it != itend ; ++it) {
+ action = static_cast<NetworkAction*>(&*it);
#ifdef HAVE_LATENCY_BOUND_TRACKING
- if (lmm_is_variable_limited_by_latency(action->getVariable())) {
- action->m_latencyLimited = 1;
- } else {
- action->m_latencyLimited = 0;
- }
+ if (lmm_is_variable_limited_by_latency(action->getVariable())) {
+ action->m_latencyLimited = 1;
+ } else {
+ action->m_latencyLimited = 0;
+ }
#endif
- if (action->m_latency > 0) {
- minRes = (minRes < 0) ? action->m_latency : std::min(minRes, action->m_latency);
- }
- }
+ if (action->m_latency > 0) {
+ minRes = (minRes < 0) ? action->m_latency : std::min(minRes, action->m_latency);
+ }
+ }
- XBT_DEBUG("Min of share resources %f", minRes);
+ XBT_DEBUG("Min of share resources %f", minRes);
- return minRes;
-}
+ return minRes;
+ }
-/************
- * Resource *
- ************/
+ /************
+ * Resource *
+ ************/
-Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props)
-: Resource(model, name),
- PropertyHolder(props)
-{
- links->insert({name, this});
+ Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props)
+ : Resource(model, name),
+ PropertyHolder(props)
+ {
+ links->insert({name, this});
- m_latency.scale = 1;
- m_bandwidth.scale = 1;
- XBT_DEBUG("Create link '%s'",name);
-}
+ m_latency.scale = 1;
+ m_bandwidth.scale = 1;
+ XBT_DEBUG("Create link '%s'",name);
+ }
-Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props,
- lmm_constraint_t constraint,
- tmgr_trace_t state_trace)
-: Resource(model, name, constraint),
- PropertyHolder(props)
-{
- m_latency.scale = 1;
- m_bandwidth.scale = 1;
- if (state_trace)
- m_stateEvent = future_evt_set->add_trace(state_trace, 0.0, this);
+ Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props,
+ lmm_constraint_t constraint,
+ tmgr_trace_t state_trace)
+ : Resource(model, name, constraint),
+ PropertyHolder(props)
+ {
+ m_latency.scale = 1;
+ m_bandwidth.scale = 1;
+ if (state_trace)
+ m_stateEvent = future_evt_set->add_trace(state_trace, 0.0, this);
- links->insert({name, this});
- XBT_DEBUG("Create link '%s'",name);
+ links->insert({name, this});
+ XBT_DEBUG("Create link '%s'",name);
-}
+ }
-/** @brief use destroy() instead of this destructor */
-Link::~Link() {
- xbt_assert(currentlyDestroying_, "Don't delete Links directly. Call destroy() instead.");
-}
-/** @brief Fire the require callbacks and destroy the object
- *
- * Don't delete directly an Link, call l->destroy() instead.
- */
-void Link::destroy()
-{
- if (!currentlyDestroying_) {
- currentlyDestroying_ = true;
- onDestruction(this);
- delete this;
- }
-}
+ /** @brief use destroy() instead of this destructor */
+ Link::~Link() {
+ xbt_assert(currentlyDestroying_, "Don't delete Links directly. Call destroy() instead.");
+ }
+ /** @brief Fire the require callbacks and destroy the object
+ *
+ * Don't delete directly an Link, call l->destroy() instead.
+ */
+ void Link::destroy()
+ {
+ if (!currentlyDestroying_) {
+ currentlyDestroying_ = true;
+ onDestruction(this);
+ delete this;
+ }
+ }
-bool Link::isUsed()
-{
- return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint());
-}
+ bool Link::isUsed()
+ {
+ return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint());
+ }
-double Link::getLatency()
-{
- return m_latency.peak * m_latency.scale;
-}
+ double Link::getLatency()
+ {
+ return m_latency.peak * m_latency.scale;
+ }
-double Link::getBandwidth()
-{
- return m_bandwidth.peak * m_bandwidth.scale;
-}
+ double Link::getBandwidth()
+ {
+ return m_bandwidth.peak * m_bandwidth.scale;
+ }
-int Link::sharingPolicy()
-{
- return lmm_constraint_sharing_policy(getConstraint());
-}
+ int Link::sharingPolicy()
+ {
+ return lmm_constraint_sharing_policy(getConstraint());
+ }
-void Link::turnOn(){
- if (isOff()) {
- Resource::turnOn();
- onStateChange(this);
- }
-}
-void Link::turnOff(){
- if (isOn()) {
- Resource::turnOff();
- onStateChange(this);
- }
-}
-void Link::set_state_trace(tmgr_trace_t trace)
-{
- xbt_assert(m_stateEvent==NULL,"Cannot set a second state trace to Link %s", getName());
+ void Link::turnOn(){
+ if (isOff()) {
+ Resource::turnOn();
+ onStateChange(this);
+ }
+ }
+ void Link::turnOff(){
+ if (isOn()) {
+ Resource::turnOff();
+ onStateChange(this);
+ }
+ }
+ void Link::set_state_trace(tmgr_trace_t trace)
+ {
+ xbt_assert(m_stateEvent==NULL,"Cannot set a second state trace to Link %s", getName());
- m_stateEvent = future_evt_set->add_trace(trace, 0.0, this);
-}
-void Link::set_bandwidth_trace(tmgr_trace_t trace)
-{
- xbt_assert(m_bandwidth.event==NULL,"Cannot set a second bandwidth trace to Link %s", getName());
+ m_stateEvent = future_evt_set->add_trace(trace, 0.0, this);
+ }
+ void Link::set_bandwidth_trace(tmgr_trace_t trace)
+ {
+ xbt_assert(m_bandwidth.event==NULL,"Cannot set a second bandwidth trace to Link %s", getName());
- m_bandwidth.event = future_evt_set->add_trace(trace, 0.0, this);
-}
-void Link::set_latency_trace(tmgr_trace_t trace)
-{
- xbt_assert(m_latency.event==NULL,"Cannot set a second latency trace to Link %s", getName());
+ m_bandwidth.event = future_evt_set->add_trace(trace, 0.0, this);
+ }
+ void Link::set_latency_trace(tmgr_trace_t trace)
+ {
+ xbt_assert(m_latency.event==NULL,"Cannot set a second latency trace to Link %s", getName());
- m_latency.event = future_evt_set->add_trace(trace, 0.0, this);
-}
+ m_latency.event = future_evt_set->add_trace(trace, 0.0, this);
+ }
-/**********
- * Action *
- **********/
+ /**********
+ * Action *
+ **********/
-void NetworkAction::setState(e_surf_action_state_t state){
- e_surf_action_state_t old = getState();
- Action::setState(state);
- networkActionStateChangedCallbacks(this, old, state);
-}
+ void NetworkAction::setState(e_surf_action_state_t state){
+ e_surf_action_state_t old = getState();
+ Action::setState(state);
+ networkActionStateChangedCallbacks(this, old, state);
+ }
-}
+ }
}
#endif /* NETWORK_INTERFACE_CPP_ */
***********/
namespace simgrid {
-namespace surf {
+ namespace surf {
-class NetworkModel;
-class NetworkAction;
+ class NetworkModel;
+ class NetworkAction;
-/*************
- * Callbacks *
- *************/
+ /*************
+ * Callbacks *
+ *************/
-/** @brief Callback signal fired when the state of a NetworkAction changes
- * Signature: `void(NetworkAction *action, e_surf_action_state_t old, e_surf_action_state_t current)` */
-XBT_PUBLIC_DATA(simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, e_surf_action_state_t, e_surf_action_state_t)>) networkActionStateChangedCallbacks;
+ /** @brief Callback signal fired when the state of a NetworkAction changes
+ * Signature: `void(NetworkAction *action, e_surf_action_state_t old, e_surf_action_state_t current)` */
+ XBT_PUBLIC_DATA(simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, e_surf_action_state_t, e_surf_action_state_t)>) networkActionStateChangedCallbacks;
-/** @brief Callback signal fired when a NetworkAction is created (when a communication starts)
- * Signature: `void(NetworkAction *action, RoutingEdge *src, RoutingEdge *dst, double size, double rate)` */
-XBT_PUBLIC_DATA(simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst, double size, double rate)>) networkCommunicateCallbacks;
+ /** @brief Callback signal fired when a NetworkAction is created (when a communication starts)
+ * Signature: `void(NetworkAction *action, RoutingEdge *src, RoutingEdge *dst, double size, double rate)` */
+ XBT_PUBLIC_DATA(simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst, double size, double rate)>) networkCommunicateCallbacks;
-}
+ }
}
/*********
*********/
namespace simgrid {
-namespace surf {
-
-/** @ingroup SURF_network_interface
- * @brief SURF network model interface class
- * @details A model is an object which handles the interactions between its Resources and its Actions
- */
-class NetworkModel : public Model {
-public:
- /** @brief Constructor */
- NetworkModel() : Model() { }
-
- /** @brief Destructor */
- ~NetworkModel() {
- if (p_maxminSystem)
- lmm_system_free(p_maxminSystem);
- if (p_actionHeap)
- xbt_heap_free(p_actionHeap);
- if (p_modifiedSet)
- delete p_modifiedSet;
- }
-
- /**
- * @brief Create a Link
- *
- * @param name The name of the Link
- * @param bw_initial The initial bandwidth of the Link in bytes per second
- * @param bw_trace The trace associated to the Link bandwidth
- * @param lat_initial The initial latency of the Link in seconds
- * @param lat_trace The trace associated to the Link latency
- * @param state_trace The trace associated to the Link (state)[e_surf_resource_state_t]
- * @param policy The sharing policy of the Link
- * @param properties Dictionary of properties associated to this Resource
- * @return The created Link
- */
- virtual Link* createLink(const char *name,
- double bw_initial,
- tmgr_trace_t bw_trace,
- double lat_initial,
- tmgr_trace_t lat_trace,
- tmgr_trace_t state_trace,
- e_surf_link_sharing_policy_t policy,
- xbt_dict_t properties)=0;
-
- /**
- * @brief Create a communication between two hosts.
- * @details It makes calls to the routing part, and execute the communication
- * between the two end points.
- *
- * @param src The source of the communication
- * @param dst The destination of the communication
- * @param size The size of the communication in bytes
- * @param rate Allows to limit the transfer rate. Negative value means
- * unlimited.
- * @return The action representing the communication
- */
- virtual Action *communicate(NetCard *src, NetCard *dst,
- double size, double rate)=0;
-
- /** @brief Function pointer to the function to use to solve the lmm_system_t
- *
- * @param system The lmm_system_t to solve
- */
- void (*f_networkSolve)(lmm_system_t) = lmm_solve;
-
- /**
- * @brief Get the right multiplicative factor for the latency.
- * @details Depending on the model, the effective latency when sending
- * a message might be different from the theoretical latency of the link,
- * in function of the message size. In order to account for this, this
- * function gets this factor.
- *
- * @param size The size of the message.
- * @return The latency factor.
- */
- virtual double latencyFactor(double size);
-
- /**
- * @brief Get the right multiplicative factor for the bandwidth.
- * @details Depending on the model, the effective bandwidth when sending
- * a message might be different from the theoretical bandwidth of the link,
- * in function of the message size. In order to account for this, this
- * function gets this factor.
- *
- * @param size The size of the message.
- * @return The bandwidth factor.
- */
- virtual double bandwidthFactor(double size);
-
- /**
- * @brief Get definitive bandwidth.
- * @details It gives the minimum bandwidth between the one that would
- * occur if no limitation was enforced, and the one arbitrary limited.
- * @param rate The desired maximum bandwidth.
- * @param bound The bandwidth with only the network taken into account.
- * @param size The size of the message.
- * @return The new bandwidth.
- */
- virtual double bandwidthConstraint(double rate, double bound, double size);
- double next_occuring_event_full(double now) override;
-};
-
-/************
- * Resource *
- ************/
- /** @ingroup SURF_network_interface
- * @brief SURF network link interface class
- * @details A Link represents the link between two [hosts](\ref Host)
- */
-class Link :
- public simgrid::surf::Resource,
- public simgrid::surf::PropertyHolder {
-public:
- /**
- * @brief Link constructor
- *
- * @param model The NetworkModel associated to this Link
- * @param name The name of the Link
- * @param props Dictionary of properties associated to this Link
- */
- Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props);
-
- /**
- * @brief Link constructor
- *
- * @param model The NetworkModel associated to this Link
- * @param name The name of the Link
- * @param props Dictionary of properties associated to this Link
- * @param constraint The lmm constraint associated to this Cpu if it is part of a LMM component
- * @param state_trace [TODO]
- */
- Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props,
- lmm_constraint_t constraint,
- tmgr_trace_t state_trace);
-
- /* Link destruction logic */
- /**************************/
-protected:
- ~Link();
-public:
- void destroy(); // Must be called instead of the destructor
-private:
- bool currentlyDestroying_ = false;
-
-public:
- /** @brief Callback signal fired when a new Link is created.
- * Signature: void(Link*) */
- static simgrid::xbt::signal<void(simgrid::surf::Link*)> onCreation;
-
- /** @brief Callback signal fired when a Link is destroyed.
- * Signature: void(Link*) */
- static simgrid::xbt::signal<void(simgrid::surf::Link*)> onDestruction;
-
- /** @brief Callback signal fired when the state of a Link changes (when it is turned on or off)
- * Signature: `void(Link*)` */
- static simgrid::xbt::signal<void(simgrid::surf::Link*)> onStateChange;
-
-
- /** @brief Get the bandwidth in bytes per second of current Link */
- virtual double getBandwidth();
-
- /** @brief Update the bandwidth in bytes per second of current Link */
- virtual void updateBandwidth(double value)=0;
-
- /** @brief Get the latency in seconds of current Link */
- virtual double getLatency();
-
- /** @brief Update the latency in seconds of current Link */
- virtual void updateLatency(double value)=0;
-
- /** @brief The sharing policy is a @{link e_surf_link_sharing_policy_t::EType} (0: FATPIPE, 1: SHARED, 2: FULLDUPLEX) */
- virtual int sharingPolicy();
-
- /** @brief Check if the Link is used */
- bool isUsed() override;
-
- void turnOn() override;
- void turnOff() override;
-
- virtual void set_state_trace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF). Trace must contain boolean values. */
- virtual void set_bandwidth_trace(tmgr_trace_t trace); /*< setup the trace file with bandwidth events (peak speed changes due to external load). Trace must contain percentages (value between 0 and 1). */
- virtual void set_latency_trace(tmgr_trace_t trace); /*< setup the trace file with latency events (peak latency changes due to external load). Trace must contain absolute values */
-
- tmgr_trace_iterator_t m_stateEvent = NULL;
- s_surf_metric_t m_latency = {1.0,0,NULL};
- s_surf_metric_t m_bandwidth = {1.0,0,NULL};
-
- /* User data */
-public:
- void *getData() { return userData;}
- void setData(void *d) { userData=d;}
-private:
- void *userData = NULL;
-
- /* List of all links */
-private:
- static boost::unordered_map<std::string, Link *> *links;
-public:
- static Link *byName(const char* name);
- static int linksCount();
- static Link **linksList();
- static void linksExit();
-};
-
-/**********
- * Action *
- **********/
-/** @ingroup SURF_network_interface
- * @brief SURF network action interface class
- * @details A NetworkAction represents a communication between two [hosts](\ref Host)
- */
-class NetworkAction : public simgrid::surf::Action {
-public:
- /** @brief Constructor
- *
- * @param model The NetworkModel associated to this NetworkAction
- * @param cost The cost of this NetworkAction in [TODO]
- * @param failed [description]
- */
- NetworkAction(simgrid::surf::Model *model, double cost, bool failed)
- : simgrid::surf::Action(model, cost, failed) {}
-
- /**
- * @brief NetworkAction constructor
- *
- * @param model The NetworkModel associated to this NetworkAction
- * @param cost The cost of this NetworkAction in [TODO]
- * @param failed [description]
- * @param var The lmm variable associated to this Action if it is part of a
- * LMM component
- */
- NetworkAction(simgrid::surf::Model *model, double cost, bool failed, lmm_variable_t var)
- : simgrid::surf::Action(model, cost, failed, var) {};
-
- void setState(e_surf_action_state_t state);
+ namespace surf {
+
+ /** @ingroup SURF_network_interface
+ * @brief SURF network model interface class
+ * @details A model is an object which handles the interactions between its Resources and its Actions
+ */
+ class NetworkModel : public Model {
+ public:
+ /** @brief Constructor */
+ NetworkModel() : Model() { }
+
+ /** @brief Destructor */
+ ~NetworkModel() {
+ if (p_maxminSystem)
+ lmm_system_free(p_maxminSystem);
+ if (p_actionHeap)
+ xbt_heap_free(p_actionHeap);
+ if (p_modifiedSet)
+ delete p_modifiedSet;
+ }
+
+ /**
+ * @brief Create a Link
+ *
+ * @param name The name of the Link
+ * @param bw_initial The initial bandwidth of the Link in bytes per second
+ * @param bw_trace The trace associated to the Link bandwidth
+ * @param lat_initial The initial latency of the Link in seconds
+ * @param lat_trace The trace associated to the Link latency
+ * @param state_trace The trace associated to the Link (state)[e_surf_resource_state_t]
+ * @param policy The sharing policy of the Link
+ * @param properties Dictionary of properties associated to this Resource
+ * @return The created Link
+ */
+ virtual Link* createLink(const char *name,
+ double bw_initial,
+ tmgr_trace_t bw_trace,
+ double lat_initial,
+ tmgr_trace_t lat_trace,
+ tmgr_trace_t state_trace,
+ e_surf_link_sharing_policy_t policy,
+ xbt_dict_t properties)=0;
+
+ /**
+ * @brief Create a communication between two hosts.
+ * @details It makes calls to the routing part, and execute the communication
+ * between the two end points.
+ *
+ * @param src The source of the communication
+ * @param dst The destination of the communication
+ * @param size The size of the communication in bytes
+ * @param rate Allows to limit the transfer rate. Negative value means
+ * unlimited.
+ * @return The action representing the communication
+ */
+ virtual Action *communicate(NetCard *src, NetCard *dst,
+ double size, double rate)=0;
+
+ /** @brief Function pointer to the function to use to solve the lmm_system_t
+ *
+ * @param system The lmm_system_t to solve
+ */
+ void (*f_networkSolve)(lmm_system_t) = lmm_solve;
+
+ /**
+ * @brief Get the right multiplicative factor for the latency.
+ * @details Depending on the model, the effective latency when sending
+ * a message might be different from the theoretical latency of the link,
+ * in function of the message size. In order to account for this, this
+ * function gets this factor.
+ *
+ * @param size The size of the message.
+ * @return The latency factor.
+ */
+ virtual double latencyFactor(double size);
+
+ /**
+ * @brief Get the right multiplicative factor for the bandwidth.
+ * @details Depending on the model, the effective bandwidth when sending
+ * a message might be different from the theoretical bandwidth of the link,
+ * in function of the message size. In order to account for this, this
+ * function gets this factor.
+ *
+ * @param size The size of the message.
+ * @return The bandwidth factor.
+ */
+ virtual double bandwidthFactor(double size);
+
+ /**
+ * @brief Get definitive bandwidth.
+ * @details It gives the minimum bandwidth between the one that would
+ * occur if no limitation was enforced, and the one arbitrary limited.
+ * @param rate The desired maximum bandwidth.
+ * @param bound The bandwidth with only the network taken into account.
+ * @param size The size of the message.
+ * @return The new bandwidth.
+ */
+ virtual double bandwidthConstraint(double rate, double bound, double size);
+ double next_occuring_event_full(double now) override;
+ };
+
+ /************
+ * Resource *
+ ************/
+ /** @ingroup SURF_network_interface
+ * @brief SURF network link interface class
+ * @details A Link represents the link between two [hosts](\ref Host)
+ */
+ class Link :
+ public simgrid::surf::Resource,
+ public simgrid::surf::PropertyHolder {
+ public:
+ /**
+ * @brief Link constructor
+ *
+ * @param model The NetworkModel associated to this Link
+ * @param name The name of the Link
+ * @param props Dictionary of properties associated to this Link
+ */
+ Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props);
+
+ /**
+ * @brief Link constructor
+ *
+ * @param model The NetworkModel associated to this Link
+ * @param name The name of the Link
+ * @param props Dictionary of properties associated to this Link
+ * @param constraint The lmm constraint associated to this Cpu if it is part of a LMM component
+ * @param state_trace [TODO]
+ */
+ Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props,
+ lmm_constraint_t constraint,
+ tmgr_trace_t state_trace);
+
+ /* Link destruction logic */
+ /**************************/
+ protected:
+ ~Link();
+ public:
+ void destroy(); // Must be called instead of the destructor
+ private:
+ bool currentlyDestroying_ = false;
+
+ public:
+ /** @brief Callback signal fired when a new Link is created.
+ * Signature: void(Link*) */
+ static simgrid::xbt::signal<void(simgrid::surf::Link*)> onCreation;
+
+ /** @brief Callback signal fired when a Link is destroyed.
+ * Signature: void(Link*) */
+ static simgrid::xbt::signal<void(simgrid::surf::Link*)> onDestruction;
+
+ /** @brief Callback signal fired when the state of a Link changes (when it is turned on or off)
+ * Signature: `void(Link*)` */
+ static simgrid::xbt::signal<void(simgrid::surf::Link*)> onStateChange;
+
+
+ /** @brief Get the bandwidth in bytes per second of current Link */
+ virtual double getBandwidth();
+
+ /** @brief Update the bandwidth in bytes per second of current Link */
+ virtual void updateBandwidth(double value)=0;
+
+ /** @brief Get the latency in seconds of current Link */
+ virtual double getLatency();
+
+ /** @brief Update the latency in seconds of current Link */
+ virtual void updateLatency(double value)=0;
+
+ /** @brief The sharing policy is a @{link e_surf_link_sharing_policy_t::EType} (0: FATPIPE, 1: SHARED, 2: FULLDUPLEX) */
+ virtual int sharingPolicy();
+
+ /** @brief Check if the Link is used */
+ bool isUsed() override;
+
+ void turnOn() override;
+ void turnOff() override;
+
+ virtual void set_state_trace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF). Trace must contain boolean values. */
+ virtual void set_bandwidth_trace(tmgr_trace_t trace); /*< setup the trace file with bandwidth events (peak speed changes due to external load). Trace must contain percentages (value between 0 and 1). */
+ virtual void set_latency_trace(tmgr_trace_t trace); /*< setup the trace file with latency events (peak latency changes due to external load). Trace must contain absolute values */
+
+ tmgr_trace_iterator_t m_stateEvent = NULL;
+ s_surf_metric_t m_latency = {1.0,0,NULL};
+ s_surf_metric_t m_bandwidth = {1.0,0,NULL};
+
+ /* User data */
+ public:
+ void *getData() { return userData;}
+ void setData(void *d) { userData=d;}
+ private:
+ void *userData = NULL;
+
+ /* List of all links */
+ private:
+ static boost::unordered_map<std::string, Link *> *links;
+ public:
+ static Link *byName(const char* name);
+ static int linksCount();
+ static Link **linksList();
+ static void linksExit();
+ };
+
+ /**********
+ * Action *
+ **********/
+ /** @ingroup SURF_network_interface
+ * @brief SURF network action interface class
+ * @details A NetworkAction represents a communication between two [hosts](\ref Host)
+ */
+ class NetworkAction : public simgrid::surf::Action {
+ public:
+ /** @brief Constructor
+ *
+ * @param model The NetworkModel associated to this NetworkAction
+ * @param cost The cost of this NetworkAction in [TODO]
+ * @param failed [description]
+ */
+ NetworkAction(simgrid::surf::Model *model, double cost, bool failed)
+ : simgrid::surf::Action(model, cost, failed) {}
+
+ /**
+ * @brief NetworkAction constructor
+ *
+ * @param model The NetworkModel associated to this NetworkAction
+ * @param cost The cost of this NetworkAction in [TODO]
+ * @param failed [description]
+ * @param var The lmm variable associated to this Action if it is part of a
+ * LMM component
+ */
+ NetworkAction(simgrid::surf::Model *model, double cost, bool failed, lmm_variable_t var)
+ : simgrid::surf::Action(model, cost, failed, var) {};
+
+ void setState(e_surf_action_state_t state);
#ifdef HAVE_LATENCY_BOUND_TRACKING
- /**
- * @brief Check if the action is limited by latency.
- *
- * @return 1 if action is limited by latency, 0 otherwise
- */
- virtual int getLatencyLimited() {return m_latencyLimited;}
+ /**
+ * @brief Check if the action is limited by latency.
+ *
+ * @return 1 if action is limited by latency, 0 otherwise
+ */
+ virtual int getLatencyLimited() {return m_latencyLimited;}
#endif
- double m_latency;
- double m_latCurrent;
- double m_weight;
- double m_rate;
- const char* p_senderLinkName;
- double m_senderSize;
- xbt_fifo_item_t p_senderFifoItem;
+ double m_latency;
+ double m_latCurrent;
+ double m_weight;
+ double m_rate;
+ const char* p_senderLinkName;
+ double m_senderSize;
+ xbt_fifo_item_t p_senderFifoItem;
#ifdef HAVE_LATENCY_BOUND_TRACKING
- int m_latencyLimited;
+ int m_latencyLimited;
#endif
-};
+ };
-}
+ }
}
#endif /* SURF_NETWORK_INTERFACE_HPP_ */
return link;
}
-xbt_dynar_t NetworkNS3Model::getRoute(NetCard *src, NetCard *dst)
-{
- xbt_dynar_t route = NULL;
- routing_platf->getRouteAndLatency(src, dst, &route, NULL);
- return route;
-}
-
Action *NetworkNS3Model::communicate(NetCard *src, NetCard *dst,
double size, double rate)
{
double data_sent = ns3_get_socket_sent(data);
double data_delta_sent = data_sent - action->m_lastSent;
- xbt_dynar_t route = NULL;
-
- routing_platf->getRouteAndLatency (action->p_srcElm, action->p_dstElm, &route, NULL);
- unsigned int i;
- for (i = 0; i < xbt_dynar_length (route); i++){
- NetworkNS3Link* link = ((NetworkNS3Link*)xbt_dynar_get_ptr(route, i));
- TRACE_surf_link_set_utilization (link->getName(),
- action->getCategory(),
- (data_delta_sent)/delta,
- now-delta,
- delta);
- }
+ std::vector<Link*> *route = new std::vector<Link*>();
+
+ routing_platf->getRouteAndLatency (action->p_srcElm, action->p_dstElm, route, NULL);
+ for (auto link : *route)
+ TRACE_surf_link_set_utilization (link->getName(), action->getCategory(), (data_delta_sent)/delta, now-delta, delta);
+ delete route;
+
action->m_lastSent = data_sent;
}
tmgr_trace_t state_trace,
e_surf_link_sharing_policy_t policy,
xbt_dict_t properties) override;
- xbt_dynar_t getRoute(NetCard *src, NetCard *dst);
Action *communicate(NetCard *src, NetCard *dst, double size, double rate);
double next_occuring_event(double now) override;
bool next_occuring_event_isIdempotent() {return false;}
#include "network_cm02.hpp"
namespace simgrid {
-namespace surf {
+ namespace surf {
-/***********
- * Classes *
- ***********/
+ class XBT_PRIVATE NetworkSmpiModel : public NetworkCm02Model {
+ public:
+ NetworkSmpiModel();
+ ~NetworkSmpiModel();
-class XBT_PRIVATE NetworkSmpiModel;
+ using NetworkCm02Model::gapAppend; // Explicit about overloaded method (silence Woverloaded-virtual from clang)
+ void gapAppend(double size, Link* link, NetworkAction *action);
+ void gapRemove(Action *action);
+ double latencyFactor(double size);
+ double bandwidthFactor(double size);
+ double bandwidthConstraint(double rate, double bound, double size);
+ void communicateCallBack() {};
+ };
-/*********
- * Tools *
- *********/
-/*********
- * Model *
- *********/
+ /************
+ * Resource *
+ ************/
-class NetworkSmpiModel : public NetworkCm02Model {
-public:
- NetworkSmpiModel();
- ~NetworkSmpiModel();
- using NetworkCm02Model::gapAppend; // Explicit about overloaded method (silence Woverloaded-virtual from clang)
- void gapAppend(double size, Link* link, NetworkAction *action);
- void gapRemove(Action *action);
- double latencyFactor(double size);
- double bandwidthFactor(double size);
- double bandwidthConstraint(double rate, double bound, double size);
- void communicateCallBack() {};
-};
+ /**********
+ * Action *
+ **********/
-
-/************
- * Resource *
- ************/
-
-
-/**********
- * Action *
- **********/
-
-}
+ }
}
}
-L07Action::L07Action(Model *model, int host_nb,
- sg_host_t*host_list,
- double *flops_amount,
- double *bytes_amount,
- double rate)
+L07Action::L07Action(Model *model, int host_nb, sg_host_t*host_list,
+ double *flops_amount, double *bytes_amount, double rate)
: CpuAction(model, 1, 0)
{
- unsigned int cpt;
int nb_link = 0;
int nb_used_host = 0; /* Only the hosts with something to compute (>0 flops) are counted) */
double latency = 0.0;
if (bytes_amount[i * host_nb + j] > 0) {
double lat=0.0;
- xbt_dynar_t route=NULL;
+ std::vector<Link*> *route = new std::vector<Link*>();
- routing_platf->getRouteAndLatency((*p_netcardList)[i], (*p_netcardList)[j], &route, &lat);
+ routing_platf->getRouteAndLatency((*p_netcardList)[i], (*p_netcardList)[j], route, &lat);
latency = MAX(latency, lat);
- void *_link;
- xbt_dynar_foreach(route, cpt, _link) {
- LinkL07 *link = static_cast<LinkL07*>(_link);
+ for (auto link : *route)
xbt_dict_set(ptask_parallel_task_link_set, link->getName(), link, NULL);
- }
+ delete route;
}
}
}
for (int i = 0; i < host_nb; i++) {
for (int j = 0; j < host_nb; j++) {
- xbt_dynar_t route=NULL;
if (bytes_amount[i * host_nb + j] == 0.0)
continue;
+ std::vector<Link*> *route = new std::vector<Link*>();
- routing_platf->getRouteAndLatency((*p_netcardList)[i], (*p_netcardList)[j],
- &route, NULL);
+ routing_platf->getRouteAndLatency((*p_netcardList)[i], (*p_netcardList)[j], route, NULL);
- void *_link;
- xbt_dynar_foreach(route, cpt, _link) {
- LinkL07 *link = static_cast<LinkL07*>(_link);
- lmm_expand_add(model->getMaxminSystem(), link->getConstraint(),
- this->getVariable(), bytes_amount[i * host_nb + j]);
- }
+ for (auto link : *route)
+ lmm_expand_add(model->getMaxminSystem(), link->getConstraint(), this->getVariable(), bytes_amount[i * host_nb + j]);
+
+ delete route;
}
}
}
if (p_communicationAmount != NULL) {
for (i = 0; i < hostNb; i++) {
for (j = 0; j < hostNb; j++) {
- xbt_dynar_t route=NULL;
if (p_communicationAmount[i * hostNb + j] > 0) {
double lat = 0.0;
- routing_platf->getRouteAndLatency((*p_netcardList)[i], (*p_netcardList)[j],
- &route, &lat);
+ std::vector<Link*> *route = new std::vector<Link*>();
+ routing_platf->getRouteAndLatency((*p_netcardList)[i], (*p_netcardList)[j], route, &lat);
lat_current = MAX(lat_current, lat * p_communicationAmount[i * hostNb + j]);
+ delete route;
}
}
}
extern XBT_PRIVATE simgrid::trace_mgr::future_evt_set *future_evt_set;
-XBT_PUBLIC(void) routing_model_create(void *loopback);
XBT_PUBLIC(void) routing_exit(void);
XBT_PUBLIC(void) storage_register_callbacks(void);
if (e_route->gw_dst) {
XBT_DEBUG("Load bypassASroute from %s@%s to %s@%s",
src, e_route->gw_src->name(), dst, e_route->gw_dst->name());
- xbt_assert(!xbt_dynar_is_empty(e_route->link_list), "Bypass route between %s@%s and %s@%s cannot be empty.",
+ xbt_assert(!e_route->link_list->empty(), "Bypass route between %s@%s and %s@%s cannot be empty.",
src, e_route->gw_src->name(), dst, e_route->gw_dst->name());
xbt_assert(bypassRoutes_->find(route_name) == bypassRoutes_->end(),
"The bypass route between %s@%s and %s@%s already exists.",
src, e_route->gw_src->name(), dst, e_route->gw_dst->name());
} else {
XBT_DEBUG("Load bypassRoute from %s to %s", src, dst);
- xbt_assert(!xbt_dynar_is_empty(e_route->link_list), "Bypass route between %s and %s cannot be empty.", src, dst);
+ xbt_assert(!e_route->link_list->empty(), "Bypass route between %s and %s cannot be empty.", src, dst);
xbt_assert(bypassRoutes_->find(route_name) == bypassRoutes_->end(), "The bypass route between %s and %s already exists.", src, dst);
}
- /* Build the value that will be stored in the dict */
+ /* Build a copy that will be stored in the dict */
std::vector<Link*> *newRoute = new std::vector<Link*>();
- char *linkName;
- unsigned int cpt;
- xbt_dynar_foreach(e_route->link_list, cpt, linkName) {
- Link *link = Link::byName(linkName);
- if (link)
- newRoute->push_back(link);
- else
- THROWF(mismatch_error, 0, "Link '%s' not found", linkName);
- }
+ for (auto link: *e_route->link_list)
+ newRoute->push_back(link);
/* Store it */
bypassRoutes_->insert({route_name, newRoute});
* \param *latency the latency, if needed
*/
static void _get_route_and_latency(simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst,
- xbt_dynar_t * links, double *latency)
+ std::vector<Link*> * links, double *latency)
{
s_sg_platf_route_cbarg_t route = SG_PLATF_ROUTE_INITIALIZER;
memset(&route,0,sizeof(route));
std::vector<Link*> *bypassed_route = common_father->getBypassRoute(src, dst);
if (nullptr != bypassed_route) {
for (Link *link : *bypassed_route) {
- xbt_dynar_push(*links,&link);
+ links->push_back(link);
if (latency)
*latency += link->getLatency();
}
/* If src and dst are in the same AS, life is good */
if (src_father == dst_father) { /* SURF_ROUTING_BASE */
- route.link_list = *links;
+ route.link_list = links;
common_father->getRouteAndLatency(src, dst, &route, latency);
return;
}
/* Not in the same AS, no bypass. We'll have to find our path between the ASes recursively*/
- route.link_list = xbt_dynar_new(sizeof(Link*), NULL);
+ route.link_list = new std::vector<Link*>();
common_father->getRouteAndLatency(src_father->netcard_, dst_father->netcard_, &route, latency);
xbt_assert((route.gw_src != NULL) && (route.gw_dst != NULL),
/* If source gateway is not our source, we have to recursively find our way up to this point */
if (src != route.gw_src)
_get_route_and_latency(src, route.gw_src, links, latency);
- xbt_dynar_merge(links, &route.link_list);
+ for (auto link: *route.link_list)
+ links->push_back(link);
/* If dest gateway is not our destination, we have to recursively find our way from this point */
if (route.gw_dst != dst)
* walk through the routing components tree and find a route between hosts
* by calling each "get_route" function in each routing component.
*/
-void RoutingPlatf::getRouteAndLatency(NetCard *src, NetCard *dst, xbt_dynar_t* route, double *latency)
+void RoutingPlatf::getRouteAndLatency(NetCard *src, NetCard *dst, std::vector<Link*> * route, double *latency)
{
XBT_DEBUG("getRouteAndLatency from %s to %s", src->name(), dst->name());
- if (NULL == *route) {
- xbt_dynar_reset(routing_platf->lastRoute_);
- *route = routing_platf->lastRoute_;
- }
_get_route_and_latency(src, dst, route, latency);
}
}
/** @brief create the root AS */
-void routing_model_create( void *loopback)
+void routing_model_create(Link *loopback)
{
routing_platf = new simgrid::surf::RoutingPlatf(loopback);
}
namespace simgrid {
namespace surf {
- RoutingPlatf::RoutingPlatf(void *loopback)
+ RoutingPlatf::RoutingPlatf(Link *loopback)
: loopback_(loopback)
{
}
#include <map>
SG_BEGIN_DECL()
-XBT_PUBLIC(void) routing_model_create( void *loopback);
+XBT_PUBLIC(void) routing_model_create(Link *loopback);
XBT_PRIVATE xbt_node_t new_xbt_graph_node (xbt_graph_t graph, const char *name, xbt_dict_t nodes);
XBT_PRIVATE xbt_edge_t new_xbt_graph_edge (xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xbt_dict_t edges);
SG_END_DECL()
virtual void setId(int id)=0;
virtual char *name()=0;
virtual As *containingAS()=0; // This is the AS in which I am
- virtual e_surf_network_element_type_t getRcType()=0;
+ virtual bool isAS()=0;
+ virtual bool isHost()=0;
+ virtual bool isRouter()=0;
};
/** @ingroup SURF_routing_interface
* @brief Network Autonomous System (AS)
- * @details [TODO]
*/
class As {
public:
void setId(int id) override {id_ = id;}
char *name() override {return name_;}
As *containingAS() override {return containingAS_;}
- e_surf_network_element_type_t getRcType() override {return componentType_;}
+
+ bool isAS() override {return componentType_ == SURF_NETWORK_ELEMENT_AS;}
+ bool isHost() override {return componentType_ == SURF_NETWORK_ELEMENT_HOST;}
+ bool isRouter() override {return componentType_ == SURF_NETWORK_ELEMENT_ROUTER;}
+
private:
int id_ = -1;
char *name_;
*/
XBT_PUBLIC_CLASS RoutingPlatf {
public:
- RoutingPlatf(void *loopback);
+ RoutingPlatf(Link *loopback);
~RoutingPlatf();
As *root_ = nullptr;
- void *loopback_;
+ Link *loopback_;
xbt_dynar_t lastRoute_ = xbt_dynar_new(sizeof(Link*),NULL);
xbt_dynar_t getOneLinkRoutes(void);
- void getRouteAndLatency(NetCard *src, NetCard *dst, xbt_dynar_t * links, double *latency);
+ void getRouteAndLatency(NetCard *src, NetCard *dst, std::vector<Link*> * links, double *latency);
};
/*************
void routing_route_free(sg_platf_route_cbarg_t route)
{
if (route) {
- xbt_dynar_free(&route->link_list);
+ delete route->link_list;
xbt_free(route);
}
}
return str;
}
-xbt_node_t new_xbt_graph_node(xbt_graph_t graph, const char *name,
- xbt_dict_t nodes)
+xbt_node_t new_xbt_graph_node(xbt_graph_t graph, const char *name, xbt_dict_t nodes)
{
xbt_node_t ret = (xbt_node_t) xbt_dict_get_or_null(nodes, name);
if (ret)
return ret;
}
-xbt_edge_t new_xbt_graph_edge(xbt_graph_t graph, xbt_node_t s, xbt_node_t d,
- xbt_dict_t edges)
+xbt_edge_t new_xbt_graph_edge(xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xbt_dict_t edges)
{
- xbt_edge_t ret;
-
const char *sn = instr_node_name(s);
const char *dn = instr_node_name(d);
int len = strlen(sn) + strlen(dn) + 1;
snprintf(name, len, "%s%s", sn, dn);
- ret = (xbt_edge_t) xbt_dict_get_or_null(edges, name);
+ xbt_edge_t ret = (xbt_edge_t) xbt_dict_get_or_null(edges, name);
if (ret == NULL) {
snprintf(name, len, "%s%s", dn, sn);
ret = (xbt_edge_t) xbt_dict_get_or_null(edges, name);
xbt_dynar_get_as(vertices_, dst, NetCard*);
sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
- route->link_list = xbt_dynar_new(sizeof(Link*), NULL);
+ route->link_list = new std::vector<Link*>();
getRouteAndLatency(my_src, my_dst, route, NULL);
XBT_DEBUG ("get_route_and_latency %s -> %s", my_src->name(), my_dst->name());
- unsigned int cpt;
- void *link;
-
xbt_node_t current, previous;
const char *previous_name, *current_name;
previous_name = my_src->name();
}
- xbt_dynar_foreach(route->link_list, cpt, link) {
- const char *link_name = static_cast<simgrid::surf::Resource*>(
- link)->getName();
+ for (auto link: *route->link_list) {
+ const char *link_name = link->getName();
current = new_xbt_graph_node(graph, link_name, nodes);
current_name = link_name;
new_xbt_graph_edge(graph, previous, current, edges);
new_xbt_graph_edge(graph, previous, current, edges);
XBT_DEBUG (" %s -> %s", previous_name, current_name);
- xbt_dynar_free (&(route->link_list));
+ delete route->link_list;
xbt_free (route);
}
}
/* ************************* GENERIC AUX FUNCTIONS ************************** */
/* change a route containing link names into a route containing link entities */
sg_platf_route_cbarg_t AsRoutedGraph::newExtendedRoute(e_surf_routing_hierarchy_t hierarchy,
- sg_platf_route_cbarg_t routearg, int change_order) {
+ sg_platf_route_cbarg_t routearg, int change_order)
+{
sg_platf_route_cbarg_t result;
- char *link_name;
- unsigned int cpt;
result = xbt_new0(s_sg_platf_route_cbarg_t, 1);
- result->link_list = xbt_dynar_new(sizeof(Link*), NULL);
+ result->link_list = new std::vector<Link*>();
xbt_assert(hierarchy == SURF_ROUTING_BASE
|| hierarchy == SURF_ROUTING_RECURSIVE,
result->gw_dst = routearg->gw_dst;
}
- xbt_dynar_foreach(routearg->link_list, cpt, link_name) {
-
- Link *link = Link::byName(link_name);
- if (link) {
- if (change_order)
- xbt_dynar_push(result->link_list, &link);
- else
- xbt_dynar_unshift(result->link_list, &link);
- } else
- THROWF(mismatch_error, 0, "Link '%s' not found", link_name);
+ for (auto link : *routearg->link_list) {
+ if (change_order)
+ result->link_list->push_back(link);
+ else
+ result->link_list->insert(result->link_list->begin(), link);
}
return result;
XBT_DEBUG("Load Route from \"%s\" to \"%s\"", srcName, dstName);
xbt_assert(src, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, srcName);
xbt_assert(dst, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, dstName);
- xbt_assert(!xbt_dynar_is_empty(route->link_list), "Empty route (between %s and %s) forbidden.", srcName, dstName);
- xbt_assert(src->getRcType()==SURF_NETWORK_ELEMENT_HOST || src->getRcType()==SURF_NETWORK_ELEMENT_ROUTER,
- "When defining a route, src must be an host or a router but '%s' is not. Did you meant to have an ASroute?", srcName);
- xbt_assert(dst->getRcType()==SURF_NETWORK_ELEMENT_HOST || dst->getRcType()==SURF_NETWORK_ELEMENT_ROUTER,
- "When defining a route, dst must be an host or a router but '%s' is not. Did you meant to have an ASroute?", dstName);
+ xbt_assert(! route->link_list->empty(), "Empty route (between %s and %s) forbidden.", srcName, dstName);
+ xbt_assert(! src->isAS(), "When defining a route, src cannot be an AS such as '%s'. Did you meant to have an ASroute?", srcName);
+ xbt_assert(! dst->isAS(), "When defining a route, dst cannot be an AS such as '%s'. Did you meant to have an ASroute?", dstName);
} else {
XBT_DEBUG("Load ASroute from %s@%s to %s@%s", srcName, route->gw_src->name(), dstName, route->gw_dst->name());
- xbt_assert(src->getRcType()==SURF_NETWORK_ELEMENT_AS,
- "When defining an ASroute, src must be an AS but '%s' is not", srcName);
- xbt_assert(dst->getRcType()==SURF_NETWORK_ELEMENT_AS,
- "When defining an ASroute, dst must be an AS but '%s' is not", dstName);
+ xbt_assert(src->isAS(), "When defining an ASroute, src must be an AS but '%s' is not", srcName);
+ xbt_assert(dst->isAS(), "When defining an ASroute, dst must be an AS but '%s' is not", dstName);
- xbt_assert(route->gw_src->getRcType()==SURF_NETWORK_ELEMENT_HOST || route->gw_src->getRcType()==SURF_NETWORK_ELEMENT_ROUTER,
+ xbt_assert(route->gw_src->isHost() || route->gw_src->isRouter(),
"When defining an ASroute, gw_src must be an host or a router but '%s' is not.", srcName);
- xbt_assert(route->gw_dst->getRcType()==SURF_NETWORK_ELEMENT_HOST || route->gw_dst->getRcType()==SURF_NETWORK_ELEMENT_ROUTER,
+ xbt_assert(route->gw_dst->isHost() || route->gw_dst->isRouter(),
"When defining an ASroute, gw_dst must be an host or a router but '%s' is not.", dstName);
xbt_assert(route->gw_src != route->gw_dst, "Cannot define an ASroute from '%s' to itself", route->gw_src->name());
srcName,route->gw_src->name(), dstName,route->gw_dst->name(), srcName);
xbt_assert(dst, "Cannot add a route from %s@%s to %s@%s: %s does not exist.",
srcName,route->gw_src->name(), dstName,route->gw_dst->name(), dstName);
- xbt_assert(!xbt_dynar_is_empty(route->link_list), "Empty route (between %s@%s and %s@%s) forbidden.",
+ xbt_assert(! route->link_list->empty(), "Empty route (between %s@%s and %s@%s) forbidden.",
srcName,route->gw_src->name(), dstName,route->gw_dst->name());
}
}
XBT_VERB("cluster_get_route_and_latency from '%s'[%d] to '%s'[%d]",
src->name(), src->id(), dst->name(), dst->id());
- if (src->getRcType() != SURF_NETWORK_ELEMENT_ROUTER) { // No specific link for router
+ if (! src->isRouter()) { // No specific link for router
if((src->id() == dst->id()) && has_loopback_ ){
info = xbt_dynar_get_as(upDownLinks, src->id() * nb_links_per_node_, s_surf_parsing_link_up_down_t);
- xbt_dynar_push_as(route->link_list, void *, info.link_up);
+ route->link_list->push_back(info.link_up);
if (lat)
- *lat += static_cast<Link*>(info.link_up)->getLatency();
+ *lat += info.link_up->getLatency();
return;
}
if (has_limiter_){ // limiter for sender
info = xbt_dynar_get_as(upDownLinks, src->id() * nb_links_per_node_ + has_loopback_, s_surf_parsing_link_up_down_t);
- xbt_dynar_push_as(route->link_list, void *, info.link_up);
+ route->link_list->push_back((Link*)info.link_up);
}
info = xbt_dynar_get_as(upDownLinks, src->id() * nb_links_per_node_ + has_loopback_ + has_limiter_, s_surf_parsing_link_up_down_t);
if (info.link_up) { // link up
- xbt_dynar_push_as(route->link_list, void *, info.link_up);
+ route->link_list->push_back(info.link_up);
if (lat)
- *lat += static_cast<Link*>(info.link_up)->getLatency();
+ *lat += info.link_up->getLatency();
}
}
if (backbone_) {
- xbt_dynar_push_as(route->link_list, void *,
- static_cast<simgrid::surf::Resource*>(backbone_));
+ route->link_list->push_back(backbone_);
if (lat)
*lat += backbone_->getLatency();
}
- if (dst->getRcType() != SURF_NETWORK_ELEMENT_ROUTER) { // No specific link for router
+ if (! dst->isRouter()) { // No specific link for router
info = xbt_dynar_get_as(upDownLinks, dst->id() * nb_links_per_node_ + has_loopback_ + has_limiter_, s_surf_parsing_link_up_down_t);
if (info.link_down) { // link down
- xbt_dynar_push_as(route->link_list, void *, info.link_down);
+ route->link_list->push_back(info.link_down);
if (lat)
- *lat += static_cast<Link*>(info.link_down)->getLatency();
+ *lat += info.link_down->getLatency();
}
if (has_limiter_){ // limiter for receiver
info = xbt_dynar_get_as(upDownLinks, dst->id() * nb_links_per_node_ + has_loopback_, s_surf_parsing_link_up_down_t);
- xbt_dynar_push_as(route->link_list, void *, info.link_up);
+ route->link_list->push_back(info.link_up);
}
}
}
for (isrc = 0; isrc < table_size; isrc++) {
src = xbt_dynar_get_as(vertices_, isrc, NetCard*);
- if (src->getRcType() != SURF_NETWORK_ELEMENT_ROUTER) {
+ if (! src->isRouter()) {
previous = new_xbt_graph_node(graph, src->name(), nodes);
info = xbt_dynar_get_as(upDownLinks, src->id(), s_surf_parsing_link_up_down_t);
std::map<int, FatTreeNode*>::const_iterator tempIter;
-if (dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_NETWORK_ELEMENT_ROUTER) return;
+ if (dst->isRouter() || src->isRouter())
+ return;
/* Let's find the source and the destination in our internal structure */
tempIter = this->computeNodes_.find(src->id());
/* In case destination is the source, and there is a loopback, let's get
through it instead of going up to a switch*/
if(source->id == destination->id && this->has_loopback_) {
- xbt_dynar_push_as(into->link_list, void*, source->loopback);
+ into->link_list->push_back(source->loopback);
if(latency) {
*latency += source->loopback->getLatency();
}
}
k = this->upperLevelNodesNumber_[currentNode->level];
d = d % k;
- xbt_dynar_push_as(into->link_list, void*,currentNode->parents[d]->upLink);
+ into->link_list->push_back(currentNode->parents[d]->upLink);
if(latency) {
*latency += currentNode->parents[d]->upLink->getLatency();
}
if (this->has_limiter_) {
- xbt_dynar_push_as(into->link_list, void*,currentNode->limiterLink);
+ into->link_list->push_back(currentNode->limiterLink);
}
currentNode = currentNode->parents[d]->upNode;
}
for(unsigned int i = 0 ; i < currentNode->children.size() ; i++) {
if(i % this->lowerLevelNodesNumber_[currentNode->level - 1] ==
destination->label[currentNode->level - 1]) {
- xbt_dynar_push_as(into->link_list, void*,currentNode->children[i]->downLink);
+ into->link_list->push_back(currentNode->children[i]->downLink);
if(latency) {
*latency += currentNode->children[i]->downLink->getLatency();
}
currentNode = currentNode->children[i]->downNode;
if (this->has_limiter_) {
- xbt_dynar_push_as(into->link_list, void*,currentNode->limiterLink);
+ into->link_list->push_back(currentNode->limiterLink);
}
XBT_DEBUG("%d(%u,%u) is accessible through %d(%u,%u)", destination->id,
destination->level, destination->position, currentNode->id,
XBT_VERB("torus_get_route_and_latency from '%s'[%d] to '%s'[%d]",
src->name(), src->id(), dst->name(), dst->id());
- if (dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_NETWORK_ELEMENT_ROUTER)
+ if (dst->isRouter() || src->isRouter())
return;
if ((src->id() == dst->id()) && has_loopback_) {
- s_surf_parsing_link_up_down_t info =
- xbt_dynar_get_as(upDownLinks, src->id() * nb_links_per_node_, s_surf_parsing_link_up_down_t);
- xbt_dynar_push_as(route->link_list, void *, info.link_up);
+ s_surf_parsing_link_up_down_t info = xbt_dynar_get_as(upDownLinks, src->id() * nb_links_per_node_, s_surf_parsing_link_up_down_t);
+ route->link_list->push_back(info.link_up);
if (lat)
- *lat += static_cast < Link * >(info.link_up)->getLatency();
+ *lat += info.link_up->getLatency();
return;
}
if (has_limiter_) { // limiter for sender
info = xbt_dynar_get_as(upDownLinks, nodeOffset + has_loopback_, s_surf_parsing_link_up_down_t);
- xbt_dynar_push_as(route->link_list, void *, info.link_up);
+ route->link_list->push_back(info.link_up);
}
info = xbt_dynar_get_as(upDownLinks, linkOffset, s_surf_parsing_link_up_down_t);
if (use_lnk_up == false) {
- xbt_dynar_push_as(route->link_list, void *, info.link_down);
-
+ route->link_list->push_back(info.link_down);
if (lat)
- *lat += static_cast < Link * >(info.link_down)->getLatency();
+ *lat += info.link_down->getLatency();
} else {
- xbt_dynar_push_as(route->link_list, void *, info.link_up);
-
+ route->link_list->push_back(info.link_up);
if (lat)
- *lat += static_cast < Link * >(info.link_up)->getLatency();
+ *lat += info.link_up->getLatency();
}
current_node = next_node;
next_node = 0;
free(myCoords);
free(targetCoords);
-
-
return;
}
{
sg_platf_route_cbarg_t e_route = (sg_platf_route_cbarg_t) e;
if (e_route) {
- xbt_dynar_free(&(e_route->link_list));
+ delete e_route->link_list;
xbt_free(e_route);
}
}
if (!found) {
sg_platf_route_cbarg_t e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
- e_route->link_list = xbt_dynar_new(sizeof(Link*), NULL);
- xbt_dynar_push(e_route->link_list, &routing_platf->loopback_);
+ e_route->link_list = new std::vector<Link*>();
+ e_route->link_list->push_back(routing_platf->loopback_);
xbt_graph_new_edge(routeGraph_, node, node, e_route);
}
}
{
xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1);
- route->link_list = xbt_dynar_new(sizeof(Link*),NULL);
+ route->link_list = new std::vector<Link*>();
int table_size = (int)xbt_dynar_length(vertices_);
for(int src=0; src < table_size; src++) {
for(int dst=0; dst< table_size; dst++) {
- xbt_dynar_reset(route->link_list);
+ route->link_list->clear();
NetCard *src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
NetCard *dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*);
this->getRouteAndLatency(src_elm, dst_elm,route, NULL);
- if (xbt_dynar_length(route->link_list) == 1) {
- void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0);
+ if (route->link_list->size() == 1) {
+ Link *link = route->link_list->at(0);
Onelink *onelink;
if (hierarchy_ == SURF_ROUTING_BASE)
onelink = new Onelink(link, src_elm, dst_elm);
int *pred_arr = NULL;
sg_platf_route_cbarg_t e_route;
int size = 0;
- unsigned int cpt;
- void *link;
xbt_dynar_t nodes = xbt_graph_get_nodes(routeGraph_);
/* Use the graph_node id mapping set to quickly find the nodes */
e_route = (sg_platf_route_cbarg_t) xbt_graph_edge_get_data(edge);
- xbt_dynar_foreach(e_route->link_list, cpt, link) {
- xbt_dynar_unshift(route->link_list, &link);
+ for (auto link: *e_route->link_list) {
+ route->link_list->insert(route->link_list->begin(), link);
if (lat)
*lat += static_cast<Link*>(link)->getLatency();
}
route_cache_element_t elm = NULL;
if (routeCache_) { /* cache mode */
- elm = (route_cache_element_t)
- xbt_dict_get_or_null_ext(routeCache_, (char *) (&src_id), sizeof(int));
+ elm = (route_cache_element_t) xbt_dict_get_or_null_ext(routeCache_, (char *) (&src_id), sizeof(int));
}
if (elm) { /* cached mode and cache hit */
graph_node_data_t data = (graph_node_data_t) xbt_graph_node_get_data(u_node);
int u_id = data->graph_id;
sg_platf_route_cbarg_t tmp_e_route = (sg_platf_route_cbarg_t) xbt_graph_edge_get_data(edge);
- int cost_v_u = (tmp_e_route->link_list)->used; /* count of links, old model assume 1 */
+ int cost_v_u = tmp_e_route->link_list->size(); /* count of links, old model assume 1 */
if (cost_v_u + cost_arr[*v_id] < cost_arr[u_id]) {
pred_arr[u_id] = *v_id;
first_gw = gw_dst;
if (hierarchy_ == SURF_ROUTING_RECURSIVE && v != dst_node_id && strcmp(gw_dst->name(), prev_gw_src->name())) {
- xbt_dynar_t e_route_as_to_as=NULL;
-
- routing_platf->getRouteAndLatency(gw_dst_net_elm, prev_gw_src_net_elm, &e_route_as_to_as, NULL);
- if (edge == NULL)
- THROWF(arg_error,0,"No route from '%s' to '%s'", src->name(), dst->name());
- int pos = 0;
- xbt_dynar_foreach(e_route_as_to_as, cpt, link) {
- xbt_dynar_insert_at(route->link_list, pos, &link);
+ std::vector<Link*> *e_route_as_to_as = new std::vector<Link*>();
+
+ routing_platf->getRouteAndLatency(gw_dst_net_elm, prev_gw_src_net_elm, e_route_as_to_as, NULL);
+ auto pos = route->link_list->begin();
+ for (auto link : *e_route_as_to_as) {
+ route->link_list->insert(pos, link);
if (lat)
- *lat += static_cast<Link*>(link)->getLatency();
+ *lat += link->getLatency();
pos++;
}
}
- xbt_dynar_foreach(e_route->link_list, cpt, link) {
- xbt_dynar_unshift(route->link_list, &link);
+ for (auto link: *e_route->link_list) {
+ route->link_list->insert(route->link_list->begin(), link);
if (lat)
*lat += static_cast<Link*>(link)->getLatency();
}
sg_platf_route_cbarg_t link_route_back = newExtendedRoute(hierarchy_, route, 0);
newRoute(dst->id(), src->id(), link_route_back);
}
- xbt_dynar_free(&route->link_list);
+ delete route->link_list;
}
}
xbt_dynar_t AsFloyd::getOneLinkRoutes()
{
xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
- sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
- route->link_list = xbt_dynar_new(sizeof(Link*), NULL);
+ sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
+ route->link_list = new std::vector<Link*>();
- int src,dst;
- sg_netcard_t src_elm, dst_elm;
int table_size = xbt_dynar_length(vertices_);
- for(src=0; src < table_size; src++) {
- for(dst=0; dst< table_size; dst++) {
- xbt_dynar_reset(route->link_list);
- src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
- dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*);
+ for(int src=0; src < table_size; src++) {
+ for(int dst=0; dst< table_size; dst++) {
+ route->link_list->clear();
+ NetCard *src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
+ NetCard *dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*);
this->getRouteAndLatency(src_elm, dst_elm, route, NULL);
- if (xbt_dynar_length(route->link_list) == 1) {
- void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0);
+ if (route->link_list->size() == 1) {
+ void *link = route->link_list->at(0);
Onelink *onelink;
if (hierarchy_ == SURF_ROUTING_BASE)
onelink = new Onelink(link, src_elm, dst_elm);
return ret;
}
-void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t res, double *lat)
+void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat)
{
size_t table_size = xbt_dynar_length(vertices_);
} while (cur != src->id());
if (hierarchy_ == SURF_ROUTING_RECURSIVE) {
- res->gw_src = xbt_dynar_getlast_as(route_stack, sg_platf_route_cbarg_t)->gw_src;
- res->gw_dst = xbt_dynar_getfirst_as(route_stack, sg_platf_route_cbarg_t)->gw_dst;
+ route->gw_src = xbt_dynar_getlast_as(route_stack, sg_platf_route_cbarg_t)->gw_src;
+ route->gw_dst = xbt_dynar_getfirst_as(route_stack, sg_platf_route_cbarg_t)->gw_dst;
}
sg_netcard_t prev_dst_gw = NULL;
while (!xbt_dynar_is_empty(route_stack)) {
sg_platf_route_cbarg_t e_route = xbt_dynar_pop_as(route_stack, sg_platf_route_cbarg_t);
- xbt_dynar_t links;
- void *link;
- unsigned int cpt;
if (hierarchy_ == SURF_ROUTING_RECURSIVE && prev_dst_gw != NULL && strcmp(prev_dst_gw->name(), e_route->gw_src->name())) {
- routing_platf->getRouteAndLatency(prev_dst_gw, e_route->gw_src, &res->link_list, lat);
+ routing_platf->getRouteAndLatency(prev_dst_gw, e_route->gw_src, route->link_list, lat);
}
- links = e_route->link_list;
- xbt_dynar_foreach(links, cpt, link) {
- xbt_dynar_push_as(res->link_list, Link*, (Link*)link);
+ for (auto link: *e_route->link_list) {
+ route->link_list->push_back(link);
if (lat)
- *lat += static_cast<Link*>(link)->getLatency();
+ *lat += link->getLatency();
}
prev_dst_gw = e_route->gw_dst;
xbt_dynar_free(&route_stack);
}
-static int floyd_pointer_resource_cmp(const void *a, const void *b) {
- return a != b;
-}
-
void AsFloyd::addRoute(sg_platf_route_cbarg_t route)
{
/* set the size of table routing */
TO_FLOYD_LINK(src->id(), dst->id()) = newExtendedRoute(hierarchy_, route, 1);
TO_FLOYD_PRED(src->id(), dst->id()) = src->id();
- TO_FLOYD_COST(src->id(), dst->id()) = ((TO_FLOYD_LINK(src->id(), dst->id()))->link_list)->used;
+ TO_FLOYD_COST(src->id(), dst->id()) = (TO_FLOYD_LINK(src->id(), dst->id()))->link_list->size();
if (route->symmetrical == TRUE) {
- if(TO_FLOYD_LINK(dst->id(), src->id()))
- {
- if(!route->gw_dst && !route->gw_src)
- XBT_DEBUG("See Route from \"%s\" to \"%s\"", dst->name(), src->name());
- else
- XBT_DEBUG("See ASroute from \"%s(%s)\" to \"%s(%s)\"", dst->name(), route->gw_src->name(), src->name(), route->gw_dst->name());
-
- char * link_name;
- xbt_dynar_t link_route_to_test = xbt_dynar_new(sizeof(Link*), NULL);
- for(int i=xbt_dynar_length(route->link_list) ;i>0 ;i--) {
- link_name = xbt_dynar_get_as(route->link_list,i-1,char *);
- void *link = Link::byName(link_name);
- xbt_assert(link,"Link : '%s' doesn't exists.",link_name);
- xbt_dynar_push(link_route_to_test,&link);
- }
- xbt_assert(!xbt_dynar_compare(
- TO_FLOYD_LINK(dst->id(), src->id())->link_list,
- link_route_to_test,
- (int_f_cpvoid_cpvoid_t) floyd_pointer_resource_cmp),
- "The route between \"%s\" and \"%s\" already exists", src->name(),dst->name());
+ if (route->gw_dst) // AS route (to adapt the error message, if any)
+ xbt_assert(nullptr == TO_FLOYD_LINK(dst->id(), src->id()),
+ "The route between %s@%s and %s@%s already exists. You should not declare the reverse path as symmetrical.",
+ dst->name(),route->gw_dst->name(),src->name(),route->gw_src->name());
+ else
+ xbt_assert(nullptr == TO_FLOYD_LINK(dst->id(), src->id()),
+ "The route between %s and %s already exists. You should not declare the reverse path as symmetrical.",
+ dst->name(),src->name());
+
+ if(route->gw_dst && route->gw_src) {
+ NetCard* gw_tmp = route->gw_src;
+ route->gw_src = route->gw_dst;
+ route->gw_dst = gw_tmp;
}
- else {
- if(route->gw_dst && route->gw_src) {
- NetCard* gw_tmp = route->gw_src;
- route->gw_src = route->gw_dst;
- route->gw_dst = gw_tmp;
- }
+ if(!route->gw_src && !route->gw_dst)
+ XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dst->name(), src->name());
+ else
+ XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", dst->name(),
+ route->gw_src->name(), src->name(), route->gw_dst->name());
- if(!route->gw_src && !route->gw_dst)
- XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dst->name(), src->name());
- else
- XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", dst->name(),
- route->gw_src->name(), src->name(), route->gw_dst->name());
-
- TO_FLOYD_LINK(dst->id(), src->id()) =
- newExtendedRoute(hierarchy_, route, 0);
- TO_FLOYD_PRED(dst->id(), src->id()) = dst->id();
- TO_FLOYD_COST(dst->id(), src->id()) =
- ((TO_FLOYD_LINK(dst->id(), src->id()))->link_list)->used; /* count of links, old model assume 1 */
- }
+ TO_FLOYD_LINK(dst->id(), src->id()) = newExtendedRoute(hierarchy_, route, 0);
+ TO_FLOYD_PRED(dst->id(), src->id()) = dst->id();
+ TO_FLOYD_COST(dst->id(), src->id()) = (TO_FLOYD_LINK(dst->id(), src->id()))->link_list->size(); /* count of links, old model assume 1 */
}
- xbt_dynar_free(&route->link_list);
}
void AsFloyd::Seal(){
e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
e_route->gw_src = NULL;
e_route->gw_dst = NULL;
- e_route->link_list = xbt_dynar_new(sizeof(Link*), NULL);
- xbt_dynar_push(e_route->link_list, &routing_platf->loopback_);
+ e_route->link_list = new std::vector<Link*>();
+ e_route->link_list->push_back(routing_platf->loopback_);
TO_FLOYD_LINK(i, i) = e_route;
TO_FLOYD_PRED(i, i) = i;
TO_FLOYD_COST(i, i) = 1;
e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
e_route->gw_src = NULL;
e_route->gw_dst = NULL;
- e_route->link_list = xbt_dynar_new(sizeof(Link*), NULL);
- xbt_dynar_push(e_route->link_list, &routing_platf->loopback_);
+ e_route->link_list = new std::vector<Link*>();
+ e_route->link_list->push_back(routing_platf->loopback_);
TO_ROUTE_FULL(i, i) = e_route;
}
}
for (i = 0; i < table_size; i++)
for (j = 0; j < table_size; j++) {
if (TO_ROUTE_FULL(i,j)){
- xbt_dynar_free(&TO_ROUTE_FULL(i,j)->link_list);
+ delete TO_ROUTE_FULL(i,j)->link_list;
xbt_free(TO_ROUTE_FULL(i,j));
}
}
for(dst=0; dst< table_size; dst++) {
sg_platf_route_cbarg_t route = TO_ROUTE_FULL(src,dst);
if (route) {
- if (xbt_dynar_length(route->link_list) == 1) {
- void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0);
+ if (route->link_list->size() == 1) {
+ Link *link = route->link_list->at(0);
Onelink *onelink;
if (hierarchy_ == SURF_ROUTING_BASE) {
NetCard *tmp_src = xbt_dynar_get_as(vertices_, src, sg_netcard_t);
size_t table_size = xbt_dynar_length(vertices_);
sg_platf_route_cbarg_t e_route = NULL;
- void *link;
- unsigned int cpt = 0;
e_route = TO_ROUTE_FULL(src->id(), dst->id());
if (e_route) {
res->gw_src = e_route->gw_src;
res->gw_dst = e_route->gw_dst;
- xbt_dynar_foreach(e_route->link_list, cpt, link) {
- xbt_dynar_push(res->link_list, &link);
+ for (auto link : *e_route->link_list) {
+ res->link_list->push_back(link);
if (lat)
*lat += static_cast<Link*>(link)->getLatency();
}
}
}
-static int full_pointer_resource_cmp(const void *a, const void *b)
-{
- return a != b;
-}
-
void AsFull::addRoute(sg_platf_route_cbarg_t route)
{
const char *src = route->src;
/* Add the route to the base */
TO_ROUTE_FULL(src_net_elm->id(), dst_net_elm->id()) = newExtendedRoute(hierarchy_, route, 1);
- xbt_dynar_shrink(TO_ROUTE_FULL(src_net_elm->id(), dst_net_elm->id())->link_list, 0);
+ TO_ROUTE_FULL(src_net_elm->id(), dst_net_elm->id())->link_list->shrink_to_fit();
- if (route->symmetrical == TRUE) {
+ if (route->symmetrical == TRUE && src_net_elm != dst_net_elm) {
if (route->gw_dst && route->gw_src) {
NetCard* gw_tmp = route->gw_src;
route->gw_src = route->gw_dst;
route->gw_dst = gw_tmp;
}
- if (TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id())) {
- char *link_name;
- unsigned int i;
- xbt_dynar_t link_route_to_test = xbt_dynar_new(sizeof(Link*), NULL);
- for (i = xbt_dynar_length(route->link_list); i > 0; i--) {
- link_name = xbt_dynar_get_as(route->link_list, i - 1, char *);
- void *link = Link::byName(link_name);
- xbt_assert(link, "Link : '%s' doesn't exists.", link_name);
- xbt_dynar_push(link_route_to_test, &link);
- }
- xbt_assert(!xbt_dynar_compare(TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id())->link_list,
- link_route_to_test,
- full_pointer_resource_cmp),
- "The route between \"%s\" and \"%s\" already exists", src,
- dst);
- } else {
- if (!route->gw_dst && !route->gw_src)
- XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dst, src);
- else
- XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"",
- dst, route->gw_src->name(), src, route->gw_dst->name());
- TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id()) = newExtendedRoute(hierarchy_, route, 0);
- xbt_dynar_shrink(TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id())->link_list, 0);
- }
+ if (route->gw_dst) // AS route (to adapt the error message, if any)
+ xbt_assert(nullptr == TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id()),
+ "The route between %s@%s and %s@%s already exists. You should not declare the reverse path as symmetrical.",
+ dst,route->gw_dst->name(),src,route->gw_src->name());
+ else
+ xbt_assert(nullptr == TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id()),
+ "The route between %s and %s already exists. You should not declare the reverse path as symmetrical.", dst,src);
+
+ TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id()) = newExtendedRoute(hierarchy_, route, 0);
+ TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id())->link_list->shrink_to_fit();
}
- xbt_dynar_free(&route->link_list);
}
}
XBT_DEBUG("vivaldi_get_route_and_latency from '%s'[%d] '%s'[%d]",
src->name(), src->id(), dst->name(), dst->id());
- if(src->getRcType() == SURF_NETWORK_ELEMENT_AS) {
+ if(src->isAS()) {
char *src_name = ROUTER_PEER(src->name());
char *dst_name = ROUTER_PEER(dst->name());
route->gw_src = (sg_netcard_t) xbt_lib_get_or_null(as_router_lib, src_name, ROUTING_ASR_LEVEL);
xbt_dynar_t src_ctn, dst_ctn;
char *tmp_src_name, *tmp_dst_name;
- if(src->getRcType() == SURF_NETWORK_ELEMENT_HOST){
+ if(src->isHost()){
tmp_src_name = HOST_PEER(src->name());
if ((int)xbt_dynar_length(upDownLinks)>src->id()) {
info = xbt_dynar_get_as(upDownLinks, src->id(), s_surf_parsing_link_up_down_t);
if(info.link_up) { // link up
- xbt_dynar_push_as(route->link_list, void*, info.link_up);
+ route->link_list->push_back(info.link_up);
if (lat)
*lat += static_cast<Link*>(info.link_up)->getLatency();
}
if (src_ctn == nullptr)
src_ctn = (xbt_dynar_t) simgrid::s4u::Host::by_name_or_create(src->name())->extension(COORD_HOST_LEVEL);
}
- else if(src->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_NETWORK_ELEMENT_AS){
+ else if(src->isRouter() || src->isAS()){
tmp_src_name = ROUTER_PEER(src->name());
src_ctn = (xbt_dynar_t) xbt_lib_get_or_null(as_router_lib, tmp_src_name, COORD_ASR_LEVEL);
}
THROW_IMPOSSIBLE;
}
- if(dst->getRcType() == SURF_NETWORK_ELEMENT_HOST){
+ if(dst->isHost()){
tmp_dst_name = HOST_PEER(dst->name());
if ((int)xbt_dynar_length(upDownLinks)>dst->id()) {
info = xbt_dynar_get_as(upDownLinks, dst->id(), s_surf_parsing_link_up_down_t);
if(info.link_down) { // link down
- xbt_dynar_push_as(route->link_list,void*,info.link_down);
+ route->link_list->push_back(info.link_down);
if (lat)
*lat += static_cast<Link*>(info.link_down)->getLatency();
}
dst_ctn = (xbt_dynar_t) simgrid::s4u::Host::by_name_or_create(dst->name())
->extension(COORD_HOST_LEVEL);
}
- else if(dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || dst->getRcType() == SURF_NETWORK_ELEMENT_AS){
+ else if(dst->isRouter() || dst->isAS()){
tmp_dst_name = ROUTER_PEER(dst->name());
dst_ctn = (xbt_dynar_t) xbt_lib_get_or_null(as_router_lib, tmp_dst_name, COORD_ASR_LEVEL);
}
const char *dst;
sg_netcard_t gw_src;
sg_netcard_t gw_dst;
- xbt_dynar_t link_list;
+ std::vector<Link*> *link_list;
} s_sg_platf_route_cbarg_t;
#define SG_PLATF_ROUTE_INITIALIZER {1,NULL,NULL,NULL,NULL,NULL}
typedef struct s_surf_parsing_link_up_down *surf_parsing_link_up_down_t;
typedef struct s_surf_parsing_link_up_down {
- void* link_up;
- void* link_down;
+ Link* link_up;
+ Link* link_down;
} s_surf_parsing_link_up_down_t;
#include "xbt/file.h"
#include "xbt/dict.h"
#include "src/surf/surf_private.h"
+#include "src/surf/network_interface.hpp"
#include "simgrid/sg_config.h"
#include "simgrid/link.h"
route.dst = A_surfxml_route_dst;
route.gw_src = NULL;
route.gw_dst = NULL;
- route.link_list = parsed_link_list;
+ route.link_list = new std::vector<Link*>();
+
+ unsigned int cpt;
+ char *link_name;
+ xbt_dynar_foreach(parsed_link_list, cpt, link_name) {
+ simgrid::surf::Link *link = Link::byName(link_name);
+ route.link_list->push_back(link);
+ }
+
switch (A_surfxml_route_symmetrical) {
case AU_surfxml_route_symmetrical:
surf_parse_error("gw_dst=\"%s\" not found for ASroute from \"%s\" to \"%s\"",
A_surfxml_ASroute_gw___dst, ASroute.src, ASroute.dst);
- ASroute.link_list = parsed_link_list;
+ ASroute.link_list = new std::vector<Link*>();
+
+ unsigned int cpt;
+ char *link_name;
+ xbt_dynar_foreach(parsed_link_list, cpt, link_name) {
+ simgrid::surf::Link *link = Link::byName(link_name);
+ ASroute.link_list->push_back(link);
+ }
switch (A_surfxml_ASroute_symmetrical) {
case AU_surfxml_ASroute_symmetrical:
route.dst = A_surfxml_bypassRoute_dst;
route.gw_src = NULL;
route.gw_dst = NULL;
- route.link_list = parsed_link_list;
route.symmetrical = FALSE;
+ route.link_list = new std::vector<Link*>();
- sg_platf_new_bypassRoute(&route);
+ unsigned int cpt;
+ char *link_name;
+ xbt_dynar_foreach(parsed_link_list, cpt, link_name) {
+ simgrid::surf::Link *link = Link::byName(link_name);
+ route.link_list->push_back(link);
+ }
xbt_dynar_free(&parsed_link_list);
+
+ sg_platf_new_bypassRoute(&route);
}
void ETag_surfxml_bypassASroute(void){
ASroute.src = A_surfxml_bypassASroute_src;
ASroute.dst = A_surfxml_bypassASroute_dst;
- ASroute.link_list = parsed_link_list;
+ ASroute.link_list = new std::vector<Link*>();
+ unsigned int cpt;
+ char *link_name;
+ xbt_dynar_foreach(parsed_link_list, cpt, link_name) {
+ simgrid::surf::Link *link = Link::byName(link_name);
+ ASroute.link_list->push_back(link);
+ }
+ xbt_dynar_free(&parsed_link_list);
ASroute.symmetrical = FALSE;
ASroute.gw_src = sg_netcard_by_name_or_null(A_surfxml_bypassASroute_gw___src);
ASroute.gw_dst = sg_netcard_by_name_or_null(A_surfxml_bypassASroute_gw___dst);
sg_platf_new_bypassRoute(&ASroute);
- xbt_dynar_free(&parsed_link_list);
}
void ETag_surfxml_trace(void){
xbt_dict_remove_ext(dict, key, strlen(key));
}
-#ifdef XBT_USE_DEPRECATED
-/**
- * \brief Add data to the dict (arbitrary key)
- * \param dict the container
- * \param key the key to set the new data
- * \param data the data to add in the dict
- *
- * Set the \a data in the structure under the \a key.
- * Both \a data and \a key are considered as uintptr_t.
- */
-XBT_INLINE void xbt_dicti_set(xbt_dict_t dict,
- uintptr_t key, uintptr_t data)
-{
- xbt_dict_set_ext(dict, (void *)&key, sizeof key, (void*)data, NULL);
-}
-
-/**
- * \brief Retrieve data from the dict (key considered as a uintptr_t)
- *
- * \param dict the dealer of data
- * \param key the key to find data
- * \return the data that we are looking for (or 0 if not found)
- *
- * Mixing uintptr_t keys with regular keys in the same dict is discouraged
- */
-XBT_INLINE uintptr_t xbt_dicti_get(xbt_dict_t dict, uintptr_t key)
-{
- return (uintptr_t)xbt_dict_get_or_null_ext(dict, (void *)&key, sizeof key);
-}
-
-/** Remove a uintptr_t key from the dict */
-XBT_INLINE void xbt_dicti_remove(xbt_dict_t dict, uintptr_t key)
-{
- xbt_dict_remove_ext(dict, (void *)&key, sizeof key);
-}
-#endif
-
/** @brief Remove all data from the dict */
void xbt_dict_reset(xbt_dict_t dict)
{
+++ /dev/null
-/* dict_multi - dictionnaries of dictionnaries of ... of data */
-
-/* Copyright (c) 2004-2014. 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. */
-
-#ifdef XBT_USE_DEPRECATED
-
-#include "dict_private.h"
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_dict_multi, xbt_dict,
- "Dictionaries of multiple keys");
-
-static void _free_dict(void *d)
-{
- XBT_VERB("free dict %p", d);
- xbt_dict_free((xbt_dict_t *) & d);
-}
-
-/** \brief Insert \e data under all the keys contained in \e keys, providing their sizes in \e lens.
- *
- * \arg mdict: the multi-dict
- * \arg keys: dynar of (char *) containing all the keys
- * \arg lens: length of each element of \e keys
- * \arg data: what to store in the structure
- * \arg free_ctn: function to use to free the pushed content on need
- *
- * Dynars are not modified during the operation.
- */
-
-void
-xbt_multidict_set_ext(xbt_dict_t mdict,
- xbt_dynar_t keys, xbt_dynar_t lens,
- void *data, void_f_pvoid_t free_ctn)
-{
-
- xbt_dict_t thislevel, nextlevel = NULL;
- int i;
-
- unsigned long int thislen;
- char *thiskey;
- int keys_len = xbt_dynar_length(keys);
-
- xbt_assert(xbt_dynar_length(keys) == xbt_dynar_length(lens));
- xbt_assert(keys_len, "Can't set a zero-long key set in a multidict");
-
- XBT_DEBUG("xbt_multidict_set(%p,%d)", mdict, keys_len);
-
- for (i = 0, thislevel = mdict; i < keys_len - 1;
- i++, thislevel = nextlevel) {
-
- xbt_dynar_get_cpy(keys, i, &thiskey);
- xbt_dynar_get_cpy(lens, i, &thislen);
-
- XBT_DEBUG("multi_set: at level %d, len=%ld, key=%p |%*s|", i, thislen,
- thiskey, (int) thislen, thiskey);
-
- /* search the dict of next level */
- nextlevel = xbt_dict_get_or_null_ext(thislevel, thiskey, thislen);
- if (nextlevel == NULL) {
- /* make sure the dict of next level exists */
- nextlevel = xbt_dict_new();
- XBT_VERB("Create a dict (%p)", nextlevel);
- xbt_dict_set_ext(thislevel, thiskey, thislen, nextlevel,
- &_free_dict);
- }
- }
-
- xbt_dynar_get_cpy(keys, i, &thiskey);
- xbt_dynar_get_cpy(lens, i, &thislen);
-
- xbt_dict_set_ext(thislevel, thiskey, thislen, data, free_ctn);
-}
-
-/** \brief Insert \e data under all the keys contained in \e keys
- *
- * \arg head: the head of dict
- * \arg keys: dynar of null-terminated strings containing all the keys
- * \arg data: what to store in the structure
- * \arg free_ctn: function to use to free the pushed content on need
- */
-void
-xbt_multidict_set(xbt_dict_t mdict,
- xbt_dynar_t keys, void *data, void_f_pvoid_t free_ctn)
-{
- xbt_dynar_t lens = xbt_dynar_new(sizeof(unsigned long int), NULL);
- unsigned long i;
-
- for (i = 0; i < xbt_dynar_length(keys); i++) {
- char *thiskey = xbt_dynar_get_as(keys, i, char *);
- unsigned long int thislen = (unsigned long int) strlen(thiskey);
- XBT_DEBUG("Push %ld as level %lu length", thislen, i);
- xbt_dynar_push(lens, &thislen);
- }
-
- TRY {
- xbt_multidict_set_ext(mdict, keys, lens, data, free_ctn);
- }
- TRY_CLEANUP {
- xbt_dynar_free(&lens);
- }
- CATCH_ANONYMOUS {
- RETHROW;
- }
-}
-
-/** \brief Insert \e data under all the keys contained in \e keys, providing their sizes in \e lens.
- *
- * \arg mdict: the multi-dict
- * \arg keys: dynar of (char *) containing all the keys
- * \arg lens: length of each element of \e keys
- * \arg data: where to put what was found in structure
- * \arg free_ctn: function to use to free the pushed content on need
- *
- * Dynars are not modified during the operation.
- */
-void *xbt_multidict_get_ext(xbt_dict_t mdict,
- xbt_dynar_t keys, xbt_dynar_t lens)
-{
- xbt_dict_t thislevel, nextlevel;
- int i;
-
- unsigned long int thislen;
- char *thiskey;
- int keys_len = xbt_dynar_length(keys);
-
- xbt_assert(xbt_dynar_length(keys) == xbt_dynar_length(lens));
- xbt_assert(!xbt_dynar_is_empty(keys),
- "Can't get a zero-long key set in a multidict");
-
- XBT_DEBUG("xbt_multidict_get(%p, %ld)", mdict, xbt_dynar_length(keys));
-
- for (i = 0, thislevel = mdict; i < keys_len - 1;
- i++, thislevel = nextlevel) {
-
- xbt_dynar_get_cpy(keys, i, &thiskey);
- xbt_dynar_get_cpy(lens, i, &thislen);
-
- XBT_DEBUG("multi_get: at level %d (%p), len=%ld, key=%p |%*s|",
- i, thislevel, thislen, thiskey, (int) thislen, thiskey);
-
- /* search the dict of next level: let mismatch raise if not found */
- nextlevel = xbt_dict_get_ext(thislevel, thiskey, thislen);
- }
-
- xbt_dynar_get_cpy(keys, i, &thiskey);
- xbt_dynar_get_cpy(lens, i, &thislen);
-
- return xbt_dict_get_ext(thislevel, thiskey, thislen);
-}
-
-void *xbt_multidict_get(xbt_dict_t mdict, xbt_dynar_t keys)
-{
- xbt_dynar_t lens = xbt_dynar_new(sizeof(unsigned long int), NULL);
- unsigned long i;
- void *res;
-
- for (i = 0; i < xbt_dynar_length(keys); i++) {
- char *thiskey = xbt_dynar_get_as(keys, i, char *);
- unsigned long int thislen = (unsigned long int) strlen(thiskey);
- xbt_dynar_push(lens, &thislen);
- }
-
- res = xbt_multidict_get_ext(mdict, keys, lens), xbt_dynar_free(&lens);
- return res;
-}
-
-
-/** \brief Remove the entry under all the keys contained in \e keys, providing their sizes in \e lens.
- *
- * \arg mdict: the multi-dict
- * \arg keys: dynar of (char *) containing all the keys
- * \arg lens: length of each element of \e keys
- * \arg data: what to store in the structure
- * \arg free_ctn: function to use to free the pushed content on need
- *
- * Dynars are not modified during the operation.
- *
- * Removing a non-existant key is ok.
- */
-
-void
-xbt_multidict_remove_ext(xbt_dict_t mdict, xbt_dynar_t keys,
- xbt_dynar_t lens)
-{
- volatile xbt_dict_t thislevel;
- volatile xbt_dict_t nextlevel = NULL;
- volatile int i;
- xbt_ex_t e;
-
- unsigned long int thislen;
- char *thiskey;
- int keys_len = xbt_dynar_length(keys);
-
- xbt_assert(xbt_dynar_length(keys) == xbt_dynar_length(lens));
- xbt_assert(xbt_dynar_length(keys),
- "Can't remove a zero-long key set in a multidict");
-
- for (i = 0, thislevel = mdict; i < keys_len - 1;
- i++, thislevel = nextlevel) {
-
- xbt_dynar_get_cpy(keys, i, &thiskey);
- xbt_dynar_get_cpy(lens, i, &thislen);
-
- /* search the dict of next level */
- TRY {
- nextlevel = xbt_dict_get_ext(thislevel, thiskey, thislen);
- }
- CATCH(e) {
- /* If non-existant entry, nothing to do */
- if (e.category == arg_error)
- xbt_ex_free(e);
- else
- RETHROW;
- }
- }
-
- xbt_dynar_get_cpy(keys, i, &thiskey);
- xbt_dynar_get_cpy(lens, i, &thislen);
-
- xbt_dict_remove_ext(thislevel, thiskey, thislen);
-}
-
-void xbt_multidict_remove(xbt_dict_t mdict, xbt_dynar_t keys)
-{
- xbt_dynar_t lens = xbt_dynar_new(sizeof(unsigned long int), NULL);
- unsigned long i;
-
- for (i = 0; i < xbt_dynar_length(keys); i++) {
- char *thiskey = xbt_dynar_get_as(keys, i, char *);
- unsigned long int thislen = strlen(thiskey);
- xbt_dynar_push(lens, &thislen);
- }
-
- TRY {
- xbt_multidict_remove_ext(mdict, keys, lens);
- }
- TRY_CLEANUP {
- xbt_dynar_free(&lens);
- }
- CATCH_ANONYMOUS {
- RETHROW;
- }
-}
-
-#endif
XBT_LOG_CONNECT(xbt_dict);
XBT_LOG_CONNECT(xbt_dict_cursor);
XBT_LOG_CONNECT(xbt_dict_elm);
-#ifdef XBT_USE_DEPRECATED
- XBT_LOG_CONNECT(xbt_dict_multi);
-#endif
XBT_LOG_CONNECT(xbt_dyn);
XBT_LOG_CONNECT(xbt_ex);
XBT_LOG_CONNECT(xbt_fifo);
set(tesh_files
${tesh_files}
${CMAKE_CURRENT_SOURCE_DIR}/bug-17132.tesh
- ${CMAKE_CURRENT_SOURCE_DIR}/bug-17132-surf-debug.tesh
PARENT_SCOPE)
set(teshsuite_src
${teshsuite_src}
set(txt_files
${txt_files}
${CMAKE_CURRENT_SOURCE_DIR}/hostfile.txt
- ${CMAKE_CURRENT_SOURCE_DIR}/README
PARENT_SCOPE)
+
+ADD_TESH_FACTORIES(tesh-smpi-bug-17132 "thread" --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR} --cd ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/bug-17132.tesh)
+++ /dev/null
-This is the bug #17132 described on gforge [1]. This small SMPI code
-triggers an issue in SURF, which is still to be debugged.
-
-The problem seems to be related to the order of events, as changing it
-(with another platform or another message size or a MPI_barrier in
-between) fixes the problem.
-
-[1] https://gforge.inria.fr/tracker/index.php?func=detail&aid=17132&group_id=12&atid=165
\ No newline at end of file
+++ /dev/null
-! output ignore
-$ ../../smpi_script/bin/smpirun -np 16 -platform ${srcdir:=.}/../../examples/platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile.txt ./bug-17132 --cfg=smpi/cpu_threshold:-1 --log=surf.thres:debug
/* 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. */
+/* Bug report: https://gforge.inria.fr/tracker/index.php?func=detail&aid=17132&group_id=12&atid=165 */
+
#include "xbt/log.h"
#include <stdio.h>
#include <mpi.h>
$ ${bindir:=.}/is_router_test ./test_of_is_router.xml
> [0.000000] [xbt_cfg/INFO] Switching to the L07 model to handle parallel tasks.
-> Workstation number: 10, link number: 1, elmts number: 21
-> - Seen: "host01" is type : 1
-> - Seen: "host02" is type : 1
-> - Seen: "host03" is type : 1
-> - Seen: "host04" is type : 1
-> - Seen: "host05" is type : 1
-> - Seen: "host06" is type : 1
-> - Seen: "host07" is type : 1
-> - Seen: "host08" is type : 1
-> - Seen: "host09" is type : 1
-> - Seen: "host10" is type : 1
-> - Seen: "router1" is type : 2
-> - Seen: "router2" is type : 2
-> - Seen: "router3" is type : 2
-> - Seen: "router4" is type : 2
-> - Seen: "router5" is type : 2
-> - Seen: "AS0" is type : 3
-> - Seen: "AS1" is type : 3
-> - Seen: "AS2" is type : 3
-> - Seen: "AS3" is type : 3
-> - Seen: "AS4" is type : 3
-> - Seen: "AS" is type : 3
+> Host number: 10, link number: 1, elmts number: 21
+> - Seen: "host01". Type: host
+> - Seen: "host02". Type: host
+> - Seen: "host03". Type: host
+> - Seen: "host04". Type: host
+> - Seen: "host05". Type: host
+> - Seen: "host06". Type: host
+> - Seen: "host07". Type: host
+> - Seen: "host08". Type: host
+> - Seen: "host09". Type: host
+> - Seen: "host10". Type: host
+> - Seen: "router1". Type: router
+> - Seen: "router2". Type: router
+> - Seen: "router3". Type: router
+> - Seen: "router4". Type: router
+> - Seen: "router5". Type: router
+> - Seen: "AS0". Type: AS
+> - Seen: "AS1". Type: AS
+> - Seen: "AS2". Type: AS
+> - Seen: "AS3". Type: AS
+> - Seen: "AS4". Type: AS
+> - Seen: "AS". Type: AS
// Routers
xbt_lib_foreach(as_router_lib, cursor_src, key, value1) {
value1 = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib, key, ROUTING_ASR_LEVEL);
- if(value1->getRcType() == SURF_NETWORK_ELEMENT_ROUTER) {
+ if(value1->isRouter()) {
printf(" <router id=\"%s\"/>\n",key);
}
}
xbt_dict_foreach(host_list, cursor_src, src, host1){ // Routes from host
value1 = sg_host_by_name(src)->pimpl_netcard;
xbt_dict_foreach(host_list, cursor_dst, dst, host2){ //to host
- xbt_dynar_t route=NULL;
+ std::vector<Link*> *route = new std::vector<Link*>();
value2 = sg_host_by_name(dst)->pimpl_netcard;
- routing_platf->getRouteAndLatency(value1, value2, &route,NULL);
- if (!xbt_dynar_is_empty(route)){
+ routing_platf->getRouteAndLatency(value1, value2, route,NULL);
+ if (! route->empty()){
printf(" <route src=\"%s\" dst=\"%s\">\n ", src, dst);
- for(i=0;i<xbt_dynar_length(route) ;i++){
- void *link = xbt_dynar_get_as(route,i,void *);
-
- char *link_name = xbt_strdup(surf_resource_name((surf_cpp_resource_t)link));
- printf("<%s id=\"%s\"/>",link_ctn,link_name);
- free(link_name);
- }
+ for (auto link: *route)
+ printf("<%s id=\"%s\"/>",link_ctn,link->getName());
printf("\n </route>\n");
}
+ delete route;
}
xbt_lib_foreach(as_router_lib, cursor_dst, dst, value2){ //to router
value2 = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib,dst,ROUTING_ASR_LEVEL);
- if(value2->getRcType() == SURF_NETWORK_ELEMENT_ROUTER){
+ if(value2->isRouter()){
printf(" <route src=\"%s\" dst=\"%s\">\n ", src, dst);
- xbt_dynar_t route=NULL;
- routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,&route,NULL);
- for(i=0;i<xbt_dynar_length(route) ;i++){
- void *link = xbt_dynar_get_as(route,i,void *);
- printf("<%s id=\"%s\"/>",link_ctn,surf_resource_name((surf_cpp_resource_t)link));
- }
+ std::vector<Link*> *route = new std::vector<Link*>();
+ routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,route,NULL);
+ for (auto link : *route)
+ printf("<%s id=\"%s\"/>",link_ctn,link->getName());
+ delete route;
printf("\n </route>\n");
}
}
xbt_lib_foreach(as_router_lib, cursor_src, src, value1){ // Routes from router
value1 = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib,src,ROUTING_ASR_LEVEL);
- if (value1->getRcType() == SURF_NETWORK_ELEMENT_ROUTER){
+ if (value1->isRouter()){
xbt_lib_foreach(as_router_lib, cursor_dst, dst, value2){ //to router
value2 = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib,dst,ROUTING_ASR_LEVEL);
- if(value2->getRcType() == SURF_NETWORK_ELEMENT_ROUTER){
+ if(value2->isRouter()){
printf(" <route src=\"%s\" dst=\"%s\">\n ", src, dst);
- xbt_dynar_t route=NULL;
- routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,&route,NULL);
- for(i=0;i<xbt_dynar_length(route) ;i++){
- void *link = xbt_dynar_get_as(route,i,void *);
-
- char *link_name = xbt_strdup(surf_resource_name((surf_cpp_resource_t)link));
- printf("<%s id=\"%s\"/>",link_ctn,link_name);
- free(link_name);
- }
+ std::vector<Link*> *route = new std::vector<Link*>();
+ routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,route,NULL);
+ for(auto link :*route)
+ printf("<%s id=\"%s\"/>",link_ctn,link->getName());
+ delete route;
printf("\n </route>\n");
}
}
xbt_dict_foreach(host_list, cursor_dst, dst, value2){ //to host
printf(" <route src=\"%s\" dst=\"%s\">\n ",src, dst);
- xbt_dynar_t route=NULL;
+ std::vector<Link*> *route = new std::vector<Link*>();
value2 = sg_host_by_name(dst)->pimpl_netcard;
- routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,&route, NULL);
- for(i=0;i<xbt_dynar_length(route) ;i++){
- void *link = xbt_dynar_get_as(route,i,void *);
-
- char *link_name = xbt_strdup(surf_resource_name((surf_cpp_resource_t)link));
- printf("<%s id=\"%s\"/>",link_ctn,link_name);
- free(link_name);
- }
+ routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,route, NULL);
+ for(auto link : *route)
+ printf("<%s id=\"%s\"/>",link_ctn,link->getName());
+ delete route;
printf("\n </route>\n");
}
}
size = xbt_dict_length(host_list) + xbt_lib_length(as_router_lib);
- printf("Workstation number: %zu, link number: %d, elmts number: %d\n", sg_host_count(), sg_link_count(), size);
+ printf("Host number: %zu, link number: %d, elmts number: %d\n", sg_host_count(), sg_link_count(), size);
- xbt_dict_foreach(host_list, cursor, key, data)
- printf(" - Seen: \"%s\" is type : %d\n", key, (int) sg_netcard_by_name_or_null(key)->getRcType());
+ xbt_dict_foreach(host_list, cursor, key, data) {
+ simgrid::surf::NetCard * nc = sg_netcard_by_name_or_null(key);
+ printf(" - Seen: \"%s\". Type: %s\n", key, nc->isRouter() ? "router" : (nc->isAS()?"AS":"host"));
+ }
- xbt_lib_foreach(as_router_lib, cursor, key, data)
- printf(" - Seen: \"%s\" is type : %d\n", key, (int) sg_netcard_by_name_or_null(key)->getRcType());
+ xbt_lib_foreach(as_router_lib, cursor, key, data) {
+ simgrid::surf::NetCard * nc = sg_netcard_by_name_or_null(key);
+ printf(" - Seen: \"%s\". Type: %s\n", key, nc->isRouter() ? "router" : (nc->isAS()?"AS":"host"));
+ }
SD_exit();
return 0;
src/xbt/dict.c
src/xbt/dict_cursor.c
src/xbt/dict_elm.c
- src/xbt/dict_multi.c
src/xbt/dynar.c
src/xbt/ex.c
src/xbt/fifo.c
ENDIF()
# smpi broken usage
ADD_TESH_FACTORIES(tesh-smpi-broken "thread" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/smpi/pingpong --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/pingpong broken_hostfiles.tesh)
- # https://gforge.inria.fr/tracker/index.php?func=detail&aid=17132&group_id=12&atid=165
- ADD_TESH_FACTORIES(tesh-smpi-bug-17132 "thread" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/bug-17132 --cd ${CMAKE_BINARY_DIR}/teshsuite/bug-17132 ${CMAKE_HOME_DIRECTORY}/teshsuite/bug-17132/bug-17132.tesh)
- IF(enable_debug)
- ADD_TESH_FACTORIES(tesh-smpi-bug-17132-surf-debug "thread" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/bug-17132 --cd ${CMAKE_BINARY_DIR}/teshsuite/bug-17132 ${CMAKE_HOME_DIRECTORY}/teshsuite/bug-17132/bug-17132-surf-debug.tesh)
- ENDIF()
ADD_TESH(tesh-smpi-replay-ti-tracing --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/smpi/pingpong --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/pingpong TI_output.tesh)
FOREACH (GATHER_COLL default ompi mpich ompi_basic_linear ompi_linear_sync ompi_binomial mvapich2 mvapich2_two_level impi)
ADD_TESH(tesh-smpi-gather-coll-${GATHER_COLL} --cfg smpi/gather:${GATHER_COLL} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/smpi/gather --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/gather gather_coll.tesh)