Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
there is no need for a SimDag's link type
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 18 Jul 2015 17:13:29 +0000 (19:13 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 18 Jul 2015 18:07:03 +0000 (20:07 +0200)
include/simgrid/link.h [new file with mode: 0644]
include/simgrid/simdag.h
src/simdag/private.h
src/simdag/sd_global.c
src/simdag/sd_link.c
src/surf/network_interface.cpp
src/surf/network_interface.hpp
teshsuite/simdag/platforms/flatifier.c

diff --git a/include/simgrid/link.h b/include/simgrid/link.h
new file mode 100644 (file)
index 0000000..3d9854d
--- /dev/null
@@ -0,0 +1,27 @@
+/* Public interface to the Link datatype                                    */
+
+/* Copyright (c) 2015. The SimGrid Team. All rights reserved.               */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef INCLUDE_SIMGRID_LINK_H_
+#define INCLUDE_SIMGRID_LINK_H_
+
+#ifdef __cplusplus
+class Link;
+#else
+typedef struct Link Link;
+#endif
+
+/* C interface */
+SG_BEGIN_DECL()
+XBT_PUBLIC(int) surf_network_link_is_shared(Link *link);
+XBT_PUBLIC(double) surf_network_link_get_bandwidth(Link *link);
+XBT_PUBLIC(double) surf_network_link_get_latency(Link *link);
+XBT_PUBLIC(const char*) surf_network_link_get_name(Link *link);
+XBT_PUBLIC(void*) surf_network_link_data(Link *link);
+XBT_PUBLIC(void) surf_network_link_data_set(Link *link,void *data);
+SG_END_DECL()
+
+#endif /* INCLUDE_SIMGRID_LINK_H_ */
index adcc3a0..5e79eeb 100644 (file)
@@ -11,6 +11,7 @@
 #include "xbt/dynar.h"
 #include "xbt/dict.h"
 
+#include "simgrid/link.h"
 
 SG_BEGIN_DECL()
 /** @brief Workstation datatype
@@ -38,11 +39,6 @@ typedef enum {
   SD_WORKSTATION_SEQUENTIAL_ACCESS  /**< @brief Only one task can be executed, the others wait in a FIFO. */
 } e_SD_workstation_access_mode_t;
 
-typedef enum {
-  SD_LINK_SHARED,
-  SD_LINK_FATPIPE
-} e_SD_link_sharing_policy_t;
-
 /** @brief Link datatype
     @ingroup SD_datatypes_management
 
@@ -51,7 +47,7 @@ typedef enum {
     links between two workstations.
 
     @see SD_link_management */
-typedef struct SD_link *SD_link_t;
+typedef Link *SD_link_t;
 
 /** @brief Task datatype
     @ingroup SD_datatypes_management
@@ -122,13 +118,37 @@ XBT_PUBLIC(const char*) SD_as_router_get_property_value(const char * as,
  */
 XBT_PUBLIC(const SD_link_t *) SD_link_get_list(void);
 XBT_PUBLIC(int) SD_link_get_number(void);
-XBT_PUBLIC(void *) SD_link_get_data(SD_link_t link);
-XBT_PUBLIC(void) SD_link_set_data(SD_link_t link, void *data);
-XBT_PUBLIC(const char *) SD_link_get_name(SD_link_t link);
-XBT_PUBLIC(double) SD_link_get_current_bandwidth(SD_link_t link);
-XBT_PUBLIC(double) SD_link_get_current_latency(SD_link_t link);
-XBT_PUBLIC(e_SD_link_sharing_policy_t) SD_link_get_sharing_policy(SD_link_t
-                                                                  link);
+/** @brief Returns the user data of a link */
+static inline void *SD_link_get_data(SD_link_t link) {
+  return surf_network_link_data(link);
+}
+
+/** @brief Sets the user data of a link
+ *
+ * The new data can be \c NULL. The old data should have been freed first
+ * if it was not \c NULL.
+ */
+static inline void SD_link_set_data(SD_link_t link, void *data) {
+       surf_network_link_data_set(link, data);
+}
+/** @Returns the name of a link  */
+static inline const char *SD_link_get_name(SD_link_t link) {
+  return surf_network_link_get_name(link);
+}
+/** @brief Returns the current bandwidth of a link (in bytes per second) */
+static inline double SD_link_get_current_bandwidth(SD_link_t link) {
+  return surf_network_link_get_bandwidth(link);
+}
+/** @brief Returns the current latency of a link (in seconds) */
+static inline double SD_link_get_current_latency(SD_link_t link){
+  return surf_network_link_get_latency(link);
+}
+/** @brief Returns the sharing policy of this workstation.
+ *  @return true if the link is shared, and false if it's a fatpipe
+ */
+static inline int SD_link_is_shared(SD_link_t link) {
+  return surf_network_link_is_shared(link);
+}
 /** @} */
 
 /************************** Workstation handling ****************************/
index 0f1575d..03dc4a4 100644 (file)
@@ -49,13 +49,6 @@ typedef struct SD_global {
 
 extern SD_global_t sd_global;
 
-/* Link */
-typedef struct SD_link {
-  void *surf_link;              /* surf object */
-  void *data;                   /* user data */
-  e_SD_link_sharing_policy_t sharing_policy;
-} s_SD_link_t;
-
 /* Workstation */
 typedef s_xbt_dictelm_t s_SD_workstation_t;
 typedef struct SD_workstation {
@@ -128,9 +121,6 @@ typedef struct SD_dependency {
 XBT_PUBLIC(xbt_swag_t) SD_simulate_swag(double how_long); /* could be public, but you need to see the internals of the SD_task_t to use it */
 
 
-SD_link_t __SD_link_create(void *surf_link, void *data);
-#define __SD_link_destroy xbt_free_f
-
 SD_workstation_t __SD_workstation_create(void *surf_workstation,
                                          void *data);
 void __SD_workstation_destroy(void *workstation);
index b1dcbab..6a1b775 100644 (file)
@@ -87,7 +87,6 @@ void SD_init(int *argc, char **argv)
 #endif
 
   XBT_DEBUG("ADD SD LEVELS");
-  SD_LINK_LEVEL = xbt_lib_add_level(link_lib,__SD_link_destroy);
   SD_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,__SD_storage_destroy);
 
   if (_sg_cfg_exit_asap) {
@@ -202,7 +201,6 @@ void SD_create_environment(const char *platform_file)
   xbt_lib_cursor_t cursor = NULL;
   char *name = NULL;
   void **surf_workstation = NULL;
-  void **surf_link = NULL;
   void **surf_storage = NULL;
 
   parse_platform_file(platform_file);
@@ -213,11 +211,6 @@ void SD_create_environment(const char *platform_file)
       __SD_workstation_create(surf_workstation[SURF_HOST_LEVEL], NULL);
   }
 
-  xbt_lib_foreach(link_lib, cursor, name, surf_link) {
-  if(surf_link[SURF_LINK_LEVEL])
-    __SD_link_create(surf_link[SURF_LINK_LEVEL], NULL);
-  }
-
   xbt_lib_foreach(storage_lib, cursor, name, surf_storage) {
   if(surf_storage[SURF_STORAGE_LEVEL])
     __SD_storage_create(surf_storage[SURF_STORAGE_LEVEL], NULL);
index cda30b4..98dd688 100644 (file)
 #include "surf/surf.h"
 #include "simgrid/link.h"
 
-/* Creates a link and registers it in SD.
- */
-SD_link_t __SD_link_create(void *surf_link, void *data)
-{
-
-  SD_link_t link;
-  const char *name;
-
-  link = xbt_new(s_SD_link_t, 1);
-  link->surf_link = surf_link;
-  link->data = data;            /* user data */
-  if (surf_network_link_is_shared(surf_link))
-    link->sharing_policy = SD_LINK_SHARED;
-  else
-    link->sharing_policy = SD_LINK_FATPIPE;
-
-  name = SD_link_get_name(link);
-  xbt_lib_set(link_lib,name,SD_LINK_LEVEL,link);
-
-  return link;
-}
-
 /**
  * \brief Returns the link list
  *
@@ -71,75 +49,6 @@ int SD_link_get_number(void)
   return xbt_lib_length(link_lib);
 }
 
-/**
- * \brief Returns the user data of a link
- *
- * \param link a link
- * \return the user data associated with this link (can be \c NULL)
- * \see SD_link_set_data()
- */
-void *SD_link_get_data(SD_link_t link)
-{
-  return link->data;
-}
-
-/**
- * \brief Sets the user data of a link
- *
- * The new data can be \c NULL. The old data should have been freed first
- * if it was not \c NULL.
- *
- * \param link a link
- * \param data the new data you want to associate with this link
- * \see SD_link_get_data()
- */
-void SD_link_set_data(SD_link_t link, void *data)
-{
-  link->data = data;
-}
-
-/**
- * \brief Returns the name of a link
- *
- * \param link a link
- * \return the name of this link (cannot be \c NULL)
- */
-const char *SD_link_get_name(SD_link_t link)
-{
-  return surf_resource_name(link->surf_link);
-}
 
-/**
- * \brief Returns the current bandwidth of a link
- *
- * \param link a link
- * \return the current bandwidth of this link, in bytes per second
- */
-double SD_link_get_current_bandwidth(SD_link_t link)
-{
-  return surf_network_link_get_bandwidth(link->surf_link);
-}
 
-/**
- * \brief Returns the current latency of a link
- *
- * \param link a link
- * \return the current latency of this link, in seconds
- */
-double SD_link_get_current_latency(SD_link_t link)
-{
-  return surf_network_link_get_latency(link->surf_link);
-}
 
-/**
- * \brief Returns the sharing policy of this workstation.
- *
- * \param link a link
- * \return the sharing policyfor the flows going through this link:
- * SD_LINK_SHARED or SD_LINK_FATPIPE
- *
- */
-e_SD_link_sharing_policy_t SD_link_get_sharing_policy(SD_link_t link)
-{
-  return link->sharing_policy;
-}
index ce1e2f3..bbe2420 100644 (file)
@@ -20,14 +20,22 @@ SG_BEGIN_DECL()
 int surf_network_link_is_shared(Link *link){
   return link->isShared();
 }
-
 double surf_network_link_get_bandwidth(Link *link){
   return link->getBandwidth();
 }
-
 double surf_network_link_get_latency(Link *link){
   return link->getLatency();
 }
+const char* surf_network_link_get_name(Link *link) {
+  return link->getName();
+}
+void* surf_network_link_data(Link *link) {
+       return link->getData();
+}
+void surf_network_link_data_set(Link *link,void *data) {
+       link->setData(data);
+}
+
 SG_END_DECL()
 
 /*************
index bb6beaa..188539f 100644 (file)
@@ -245,6 +245,12 @@ public:
   /* LMM */
   tmgr_trace_event_t p_stateEvent;
   s_surf_metric_t p_power;
+
+  /* User data */
+  void *getData()        { return userData;}
+  void  setData(void *d) { userData=d;}
+private:
+  void *userData;
 };
 
 /**********
index 2e32367..23b2632 100644 (file)
@@ -183,7 +183,7 @@ int main(int argc, char **argv)
           SD_link_get_name(links[i]),
           SD_link_get_current_bandwidth(links[i]),
           SD_link_get_current_latency(links[i]));
-      if (SD_link_get_sharing_policy(links[i]) == SD_LINK_SHARED) {
+      if (SD_link_is_shared(links[i])) {
         printf("/>\n");
       } else {
         printf(" sharing_policy=\"FATPIPE\"/>\n");