Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 7 Nov 2011 10:35:08 +0000 (11:35 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 7 Nov 2011 10:35:08 +0000 (11:35 +0100)
buildtools/Cmake/DefinePackages.cmake
include/simgrid/platf.h
src/include/simgrid/platf_interface.h [new file with mode: 0644]
src/include/surf/datatypes.h
src/include/surf/surf.h
src/include/surf/surfxml_parse_values.h
src/include/surf/trace_mgr.h
src/surf/sg_platf.c [new file with mode: 0644]
src/surf/surf_routing.c
src/surf/surfxml_parse.c

index ef743ce..c8043df 100644 (file)
@@ -48,6 +48,7 @@ set(EXTRA_DIST
        src/surf/gtnets/gtnets_topology.h
        src/surf/cpu_ti_private.h
        src/surf/surf_routing_private.h
+       src/include/simgrid/platf_interface.h
        src/include/surf/surf_resource.h
        src/include/surf/datatypes.h
        src/include/surf/maxmin.h
@@ -230,6 +231,7 @@ set(SURF_SRC
        src/surf/workstation_ptask_L07.c
        src/surf/cpu_ti.c
        src/surf/cpu_im.c
+       src/surf/sg_platf.c
        src/xbt/xbt_sg_stubs.c
 )
 
index c6ec0f6..8014a9b 100644 (file)
 
 #include <xbt.h>                /* our toolbox */
 
+typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */
+
+/** Defines whether a given resource is working or not */
+typedef enum {
+  SURF_RESOURCE_ON = 1,                   /**< Up & ready        */
+  SURF_RESOURCE_OFF = 0                   /**< Down & broken     */
+} e_surf_resource_state_t;
+
+
+typedef struct s_surf_parsing_host_arg {
+  char* V_host_id;                          //id
+  double V_host_power_peak;                     //power
+  int V_host_core;                          //core
+  double V_host_power_scale;                      //availability
+  tmgr_trace_t V_host_power_trace;                  //availability file
+  e_surf_resource_state_t V_host_state_initial;           //state
+  tmgr_trace_t V_host_state_trace;                  //state file
+  const char* V_host_coord;
+} s_surf_parsing_host_arg_t, *surf_parsing_host_arg_t;
+
+
 XBT_PUBLIC(void) sg_platf_new_AS_open(const char *id, const char *mode);
 XBT_PUBLIC(void) sg_platf_new_AS_close(void);
 
diff --git a/src/include/simgrid/platf_interface.h b/src/include/simgrid/platf_interface.h
new file mode 100644 (file)
index 0000000..a78eb2f
--- /dev/null
@@ -0,0 +1,27 @@
+/* platf_interface.h - Internal interface to the SimGrid platforms          */
+
+/* Copyright (c) 2004, 2005, 2006, 2007, 2009, 2010, 2011. 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 SG_PLATF_INTERFACE_H
+#define SG_PLATF_INTERFACE_H
+
+#include "simgrid/platf.h" /* public interface */
+
+/* Module management functions */
+void sg_platf_init(void);
+void sg_platf_exit(void);
+
+/* Managing the parsing callbacks */
+
+typedef void (*surf_parse_host_fct_t)(surf_parsing_host_arg_t);
+void surf_parse_host_add_cb(surf_parse_host_fct_t);
+
+void surf_parse_host(surf_parsing_host_arg_t h);
+
+
+
+#endif                          /* SG_PLATF_INTERFACE_H */
index ff6bd66..bac2778 100644 (file)
@@ -29,7 +29,6 @@ typedef struct lmm_constraint *lmm_constraint_t;
 typedef struct lmm_system *lmm_system_t;
 
 typedef struct tmgr_history *tmgr_history_t;
-typedef struct tmgr_trace *tmgr_trace_t;
 typedef struct tmgr_trace_event *tmgr_trace_event_t;
 
 
index cde8899..f33177c 100644 (file)
 #include "surf/datatypes.h"
 #include "xbt/lib.h"
 #include "surf/surf_routing.h"
+#include "simgrid/platf_interface.h"
 
 SG_BEGIN_DECL()
 /* Actions and models are highly connected structures... */
-typedef enum {
-  SURF_RESOURCE_ON = 1,                   /**< Up & ready        */
-  SURF_RESOURCE_OFF = 0                   /**< Down & broken     */
-} e_surf_resource_state_t;
 
 typedef enum {
   SURF_LINK_FULLDUPLEX = 2,
index 70cbc24..c38d061 100644 (file)
@@ -57,18 +57,6 @@ typedef struct s_surf_parsing_router_arg {
        char* V_router_coord;
 } s_surf_parsing_router_arg_t;
 
-typedef struct s_surf_parsing_host_arg *surf_parsing_host_arg_t;
-typedef struct s_surf_parsing_host_arg {
-       char* V_host_id;                          //id
-       double V_host_power_peak;                     //power
-       int V_host_core;                          //core
-       double V_host_power_scale;                      //availability
-       tmgr_trace_t V_host_power_trace;                  //availability file
-       e_surf_resource_state_t V_host_state_initial;           //state
-       tmgr_trace_t V_host_state_trace;                  //state file
-       const char* V_host_coord;
-} s_surf_parsing_host_arg_t;
-
 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;
@@ -76,15 +64,11 @@ typedef struct s_surf_parsing_link_up_down {
 } s_surf_parsing_link_up_down_t;
 
 
-typedef void (*surf_parse_host_fct_t)(surf_parsing_host_arg_t);
-void surf_parse_host_add_cb(surf_parse_host_fct_t);
-
 extern surf_parsing_router_arg_t struct_router;
 extern surf_parsing_cluster_arg_t struct_cluster;
 extern surf_parsing_peer_arg_t struct_peer;
 extern surf_parsing_link_arg_t struct_lnk;
 
-void surf_parse_host(surf_parsing_host_arg_t h);
 void surf_parse_link(void);
 
 #endif /* SURFXML_PARSE_VALUES_H_ */
index d8de2e7..394cddc 100644 (file)
@@ -11,6 +11,7 @@
 #include "xbt/dynar.h"
 #include "surf/maxmin.h"
 #include "surf/datatypes.h"
+#include "simgrid/platf_interface.h"
 
 /* Creation functions */
 XBT_PUBLIC(tmgr_history_t) tmgr_history_new(void);
diff --git a/src/surf/sg_platf.c b/src/surf/sg_platf.c
new file mode 100644 (file)
index 0000000..89eff09
--- /dev/null
@@ -0,0 +1,35 @@
+/* Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011. 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. */
+
+#include "xbt/misc.h"
+#include "xbt/log.h"
+#include "xbt/str.h"
+#include "xbt/dict.h"
+#include "simgrid/platf_interface.h"
+#include "surf/surf_private.h"
+
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse);
+xbt_dynar_t surf_parse_host_cb_list = NULL; // of functions of type: surf_parsing_host_arg_t -> void
+
+/** Module management function: creates all internal data structures */
+void sg_platf_init(void) {
+  surf_parse_host_cb_list = xbt_dynar_new(sizeof(surf_parse_host_fct_t), NULL);
+}
+/** Module management function: frees all internal data structures */
+void sg_platf_exit(void) {
+  xbt_dynar_free(&surf_parse_host_cb_list);
+}
+
+void surf_parse_host(surf_parsing_host_arg_t h){
+  unsigned int iterator;
+  surf_parse_host_fct_t fun;
+  xbt_dynar_foreach(surf_parse_host_cb_list, iterator, fun) {
+    if (fun) (*fun) (h);
+  }
+}
+void surf_parse_host_add_cb(surf_parse_host_fct_t fct) {
+  xbt_dynar_push(surf_parse_host_cb_list, &fct);
+}
index 8344e4a..634b3c7 100644 (file)
@@ -6,7 +6,7 @@
 
 #include <pcre.h>               /* regular expression library */
 
-#include "simgrid/platf.h" // platform creation API
+#include "simgrid/platf_interface.h" // platform creation API internal interface
 
 #include "surf_routing_private.h"
 #include "surf/surf_routing.h"
index a438b8f..e257345 100644 (file)
@@ -49,7 +49,6 @@ int surf_parse_get_int(const char *string) {
 
 /* make sure these symbols are defined as strong ones in this file so that the linker can resolve them */
 //xbt_dynar_t STag_surfxml_host_cb_list = NULL;
-xbt_dynar_t surf_parse_host_cb_list = NULL; // of functions of type: surf_parsing_host_arg_t -> void
 xbt_dynar_t STag_surfxml_platform_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_platform_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_host_cb_list = NULL;
@@ -162,8 +161,7 @@ void surf_parse_init_callbacks(void)
          ETag_surfxml_platform_cb_list =
              xbt_dynar_new(sizeof(void_f_void_t), NULL);
 
-         surf_parse_host_cb_list = xbt_dynar_new(sizeof(surf_parse_host_fct_t), NULL);
-
+         sg_platf_init();
          ETag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
          STag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
          ETag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
@@ -225,7 +223,7 @@ void surf_parse_reset_callbacks(void)
 
 void surf_parse_free_callbacks(void)
 {
-  xbt_dynar_free(&surf_parse_host_cb_list);
+  sg_platf_exit();
 
   xbt_dynar_free(&STag_surfxml_platform_cb_list);
   xbt_dynar_free(&ETag_surfxml_platform_cb_list);
@@ -294,7 +292,6 @@ void STag_surfxml_platform(void)
 }
 
 void STag_surfxml_host(void){
-//     XBT_INFO("STag_surfxml_host [%s]",A_surfxml_host_id);
   s_surf_parsing_host_arg_t host;
   memset(&host,0,sizeof(host));
 
@@ -314,16 +311,6 @@ void STag_surfxml_host(void){
 
        surf_parse_host(&host);
 }
-void surf_parse_host(surf_parsing_host_arg_t h){
-  unsigned int iterator;
-  surf_parse_host_fct_t fun;
-  xbt_dynar_foreach(surf_parse_host_cb_list, iterator, fun) {
-    if (fun) (*fun) (h);
-  }
-}
-void surf_parse_host_add_cb(surf_parse_host_fct_t fct) {
-  xbt_dynar_push(surf_parse_host_cb_list, &fct);
-}
 void ETag_surfxml_host(void){
        surfxml_call_cb_functions(ETag_surfxml_host_cb_list);
 }