Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
authorAugustin Degomme <degomme@idpann.imag.fr>
Wed, 13 Feb 2013 09:51:39 +0000 (10:51 +0100)
committerAugustin Degomme <degomme@idpann.imag.fr>
Wed, 13 Feb 2013 09:51:39 +0000 (10:51 +0100)
45 files changed:
.gitignore
buildtools/Cmake/AddTests.cmake
buildtools/Cmake/CompleteInFiles.cmake
buildtools/Cmake/MakeJava.cmake [new file with mode: 0644]
buildtools/Cmake/MakeLib.cmake
examples/msg/bittorrent/bittorrent.c
examples/msg/bittorrent/bittorrent.h
examples/msg/bittorrent/bittorrent.tesh
examples/msg/bittorrent/peer.c
examples/msg/bittorrent/tracker.c
include/msg/msg.h
include/simgrid/simix.h
include/xbt/dynar.h
src/bindings/java/jmsg_file.c
src/bindings/java/jmsg_process.c
src/bindings/java/jmsg_rngstream.c
src/bindings/java/jmsg_vm.c
src/bindings/java/jxbt_utilities.h
src/bindings/java/org/simgrid/msg/Host.java
src/bindings/java/org/simgrid/msg/Process.java
src/bindings/java/org/simgrid/msg/VM.java
src/bindings/java/smx_context_cojava.c
src/bindings/java/smx_context_cojava.h
src/bindings/java/smx_context_java.c
src/bindings/java/smx_context_java.h
src/msg/msg_gos.c
src/msg/msg_mailbox.c
src/msg/msg_mailbox.h
src/msg/msg_vm.c
src/simix/smx_user.c
src/surf/instr_routing.c
src/surf/surf_private.h
src/surf/surf_routing.c
src/surf/surf_routing_cluster.c
src/surf/surf_routing_dijkstra.c
src/surf/surf_routing_floyd.c
src/surf/surf_routing_full.c
src/surf/surf_routing_generic.c
src/surf/surf_routing_none.c
src/surf/surf_routing_private.h
src/surf/surf_routing_rulebased.c
src/surf/surf_routing_vivaldi.c
src/surf/surfxml_parse.c
src/xbt/dynar.c
teshsuite/smpi/mpich-test/env/runtests

index 55dfe37..47a2888 100644 (file)
@@ -67,12 +67,13 @@ CMakeFiles
 CMakeCache.txt
 DartConfiguration.tcl
 simgrid.nsi
+TAGS
 Testing/
 Makefile
 bin/
 lib/
 manpages/
-build_dir/
+build_*/
 build/
 buildtools/Cmake/memcheck_tests.cmake
 buildtools/Cmake/test_prog/prog_va_copy.c
index bd6c5b8..1b3dda1 100644 (file)
@@ -446,13 +446,6 @@ if(NOT enable_memcheck)
         set_tests_properties(mc-centralized-raw PROPERTIES WILL_FAIL true)
       endif()
     endif()
-    set_tests_properties(msg-bittorrent-thread-parallel PROPERTIES ENVIRONMENT SG_TEST_EXENV=true WILL_FAIL true)
-    if(CONTEXT_UCONTEXT)
-      set_tests_properties(msg-bittorrent-ucontext-parallel PROPERTIES ENVIRONMENT SG_TEST_EXENV=true WILL_FAIL true)
-    endif()
-    if(HAVE_RAWCTX)
-      set_tests_properties(msg-bittorrent-raw-parallel PROPERTIES ENVIRONMENT SG_TEST_EXENV=true WILL_FAIL true)
-    endif()
   endif()
 
 endif()
index b33553e..771e21c 100644 (file)
@@ -85,7 +85,6 @@ endif()
 if(enable_java)
   find_package(Java REQUIRED COMPONENTS Runtime Development)
   find_package(JNI REQUIRED)
-  include(UseJava)
   set(HAVE_Java 1)
 endif()
 if(enable_lua)
diff --git a/buildtools/Cmake/MakeJava.cmake b/buildtools/Cmake/MakeJava.cmake
new file mode 100644 (file)
index 0000000..3391898
--- /dev/null
@@ -0,0 +1,91 @@
+cmake_minimum_required(VERSION 2.8.6)
+
+include(UseJava)
+
+# Rules to build libSG_java
+#
+add_library(SG_java SHARED ${JMSG_C_SRC})
+set_target_properties(SG_java PROPERTIES VERSION ${libSG_java_version})
+get_target_property(COMMON_INCLUDES SG_java INCLUDE_DIRECTORIES)
+set_target_properties(SG_java PROPERTIES
+  INCLUDE_DIRECTORIES "${COMMON_INCLUDES};${JNI_INCLUDE_DIRS}")
+add_dependencies(SG_java simgrid)
+
+if(WIN32)
+  get_target_property(SIMGRID_LIB_NAME_NAME SG_java LIBRARY_OUTPUT_NAME)
+  set_target_properties(SG_java PROPERTIES
+    LINK_FLAGS "-Wl,--subsystem,windows,--kill-at ${SIMGRID_LIB_NAME}"
+    PREFIX "")
+  find_path(PEXPORTS_PATH NAMES pexports.exe PATHS NO_DEFAULT_PATHS)
+  message(STATUS "pexports: ${PEXPORTS_PATH}")
+  if(PEXPORTS_PATH)
+    add_custom_command(TARGET SG_java POST_BUILD
+      COMMAND ${PEXPORTS_PATH}/pexports.exe ${CMAKE_BINARY_DIR}/SG_java.dll > ${CMAKE_BINARY_DIR}/SG_java.def)
+  endif(PEXPORTS_PATH)
+else()
+  target_link_libraries(SG_java simgrid)
+endif()
+
+# Rules to build simgrid.jar
+#
+
+## Files to include in simgrid.jar
+##
+set(SIMGRID_JAR "${CMAKE_BINARY_DIR}/simgrid.jar")
+set(MANIFEST_FILE "${CMAKE_HOME_DIRECTORY}/src/bindings/java/MANIFEST.MF")
+set(LIBSIMGRID_SO
+  ${CMAKE_SHARED_LIBRARY_PREFIX}simgrid${CMAKE_SHARED_LIBRARY_SUFFIX})
+set(LIBSG_JAVA_SO
+  ${CMAKE_SHARED_LIBRARY_PREFIX}SG_java${CMAKE_SHARED_LIBRARY_SUFFIX})
+
+## Name of the "NATIVE" folder in simgrid.jar
+##
+if(CMAKE_SYSTEM_PROCESSOR MATCHES ".86")
+  if(${ARCH_32_BITS})
+    set(JSG_BUNDLE "NATIVE/${CMAKE_SYSTEM_NAME}/i386/")
+  else()
+    set(JSG_BUNDLE "NATIVE/${CMAKE_SYSTEM_NAME}/amd64/")
+  endif()
+else()
+  message(WARNING "Unknown system type. Processor: ${CMAKE_SYSTEM_PROCESSOR}; System: ${CMAKE_SYSTEM_NAME}")
+  set(JSG_BUNDLE "NATIVE/${CMAKE_SYSTEM_NAME}/${CMAKE_SYSTEM_PROCESSOR/")
+endif()
+message("Native libraries bundled into: ${JSG_BUNDLE}")
+
+## Don't strip libraries if not in release mode
+##
+if(release)
+  set(STRIP_COMMAND "${CMAKE_STRIP}")
+else()
+  set(STRIP_COMMAND "true")
+endif()
+
+## Here is how to build simgrid.jar
+##
+set(CMAKE_JAVA_TARGET_OUTPUT_NAME simgrid)
+add_jar(SG_java_pre_jar ${JMSG_JAVA_SRC})
+
+add_custom_command(
+  COMMENT "Finalize simgrid.jar..."
+  OUTPUT ${SIMGRID_JAR}_finalized
+  DEPENDS simgrid SG_java SG_java_pre_jar
+          ${SIMGRID_JAR} ${MANIFEST_FILE}
+          ${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_SO}
+          ${CMAKE_BINARY_DIR}/lib/${LIBSG_JAVA_SO}
+          ${CMAKE_HOME_DIRECTORY}/COPYING
+          ${CMAKE_HOME_DIRECTORY}/ChangeLog
+          ${CMAKE_HOME_DIRECTORY}/ChangeLog.SimGrid-java
+  COMMAND ${CMAKE_COMMAND} -E remove_directory "NATIVE"
+  COMMAND ${CMAKE_COMMAND} -E make_directory "${JSG_BUNDLE}"
+  COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_SO}" "${JSG_BUNDLE}"
+  COMMAND ${STRIP_COMMAND} -S "${JSG_BUNDLE}/${LIBSIMGRID_SO}"
+  COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/lib/${LIBSG_JAVA_SO}" "${JSG_BUNDLE}"
+  COMMAND ${STRIP_COMMAND} -S "${JSG_BUNDLE}/${LIBSG_JAVA_SO}"
+  COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_HOME_DIRECTORY}/COPYING" "${JSG_BUNDLE}"
+  COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_HOME_DIRECTORY}/ChangeLog" "${JSG_BUNDLE}"
+  COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_HOME_DIRECTORY}/ChangeLog.SimGrid-java" "${JSG_BUNDLE}"
+  COMMAND ${JAVA_ARCHIVE} -uvmf ${MANIFEST_FILE} ${SIMGRID_JAR} "NATIVE"
+  COMMAND ${CMAKE_COMMAND} -E remove ${SIMGRID_JAR}_finalized
+  COMMAND ${CMAKE_COMMAND} -E touch ${SIMGRID_JAR}_finalized
+  )
+add_custom_target(SG_java_jar ALL DEPENDS ${SIMGRID_JAR}_finalized)
index 0cc8a6a..f7adde3 100644 (file)
@@ -24,81 +24,7 @@ if(enable_smpi)
 endif()
 
 if(enable_java)
-  add_library(SG_java SHARED ${JMSG_C_SRC})
-  set_target_properties(SG_java PROPERTIES VERSION ${libSG_java_version})
-  get_target_property(COMMON_INCLUDES SG_java INCLUDE_DIRECTORIES)
-  set_target_properties(SG_java PROPERTIES
-    INCLUDE_DIRECTORIES "${COMMON_INCLUDES};${JNI_INCLUDE_DIRS}")
-  add_dependencies(SG_java simgrid)
-
-  if(WIN32)
-    get_target_property(SIMGRID_LIB_NAME_NAME SG_java LIBRARY_OUTPUT_NAME)
-    set_target_properties(SG_java PROPERTIES
-      LINK_FLAGS "-Wl,--subsystem,windows,--kill-at ${SIMGRID_LIB_NAME}"
-      PREFIX "")
-    find_path(PEXPORTS_PATH NAMES pexports.exe PATHS NO_DEFAULT_PATHS)
-    message(STATUS "pexports: ${PEXPORTS_PATH}")
-    if(PEXPORTS_PATH)
-      add_custom_command(TARGET SG_java POST_BUILD
-        COMMAND ${PEXPORTS_PATH}/pexports.exe ${CMAKE_BINARY_DIR}/SG_java.dll > ${CMAKE_BINARY_DIR}/SG_java.def)
-    endif(PEXPORTS_PATH)
-  else()
-    target_link_libraries(SG_java simgrid)
-  endif()
-
-  set(CMAKE_JAVA_TARGET_OUTPUT_NAME simgrid)
-  add_jar(SG_java_pre_jar ${JMSG_JAVA_SRC})
-
-  set(SIMGRID_JAR "${CMAKE_BINARY_DIR}/simgrid.jar")
-  set(MANIFEST_FILE "${CMAKE_HOME_DIRECTORY}/src/bindings/java/MANIFEST.MF")
-
-  if(CMAKE_SYSTEM_PROCESSOR MATCHES ".86")
-    if(${ARCH_32_BITS})
-      set(JSG_BUNDLE "NATIVE/${CMAKE_SYSTEM_NAME}/x86/")
-    else()
-      set(JSG_BUNDLE "NATIVE/${CMAKE_SYSTEM_NAME}/amd64/")
-    endif()
-  else()
-    message(WARNING "Unknown system type. Processor: ${CMAKE_SYSTEM_PROCESSOR}; System: ${CMAKE_SYSTEM_NAME}")
-    set(JSG_BUNDLE "NATIVE/${CMAKE_SYSTEM_NAME}/${CMAKE_SYSTEM_PROCESSOR/")
-  endif()
-  message("Native libraries bundled into: ${JSG_BUNDLE}")
-
-  set(LIBSIMGRID_SO
-    ${CMAKE_SHARED_LIBRARY_PREFIX}simgrid${CMAKE_SHARED_LIBRARY_SUFFIX})
-  set(LIBSG_JAVA_SO
-    ${CMAKE_SHARED_LIBRARY_PREFIX}SG_java${CMAKE_SHARED_LIBRARY_SUFFIX})
-
-  if(release)
-    set(STRIP_COMMAND "${CMAKE_STRIP}")
-  else()
-    set(STRIP_COMMAND "true")
-  endif()
-
-  add_custom_command(
-    COMMENT "Finalize simgrid.jar..."
-    OUTPUT ${SIMGRID_JAR}_finalized
-    DEPENDS simgrid SG_java SG_java_pre_jar
-            ${SIMGRID_JAR} ${MANIFEST_FILE}
-            ${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_SO}
-            ${CMAKE_BINARY_DIR}/lib/${LIBSG_JAVA_SO}
-            ${CMAKE_HOME_DIRECTORY}/COPYING
-            ${CMAKE_HOME_DIRECTORY}/ChangeLog
-            ${CMAKE_HOME_DIRECTORY}/ChangeLog.SimGrid-java
-    COMMAND ${CMAKE_COMMAND} -E remove_directory "NATIVE"
-    COMMAND ${CMAKE_COMMAND} -E make_directory "${JSG_BUNDLE}"
-    COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_SO}" "${JSG_BUNDLE}"
-    COMMAND ${STRIP_COMMAND} -S "${JSG_BUNDLE}/${LIBSIMGRID_SO}"
-    COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/lib/${LIBSG_JAVA_SO}" "${JSG_BUNDLE}"
-    COMMAND ${STRIP_COMMAND} -S "${JSG_BUNDLE}/${LIBSG_JAVA_SO}"
-    COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_HOME_DIRECTORY}/COPYING" "${JSG_BUNDLE}"
-    COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_HOME_DIRECTORY}/ChangeLog" "${JSG_BUNDLE}"
-    COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_HOME_DIRECTORY}/ChangeLog.SimGrid-java" "${JSG_BUNDLE}"
-    COMMAND ${JAVA_ARCHIVE} -uvmf ${MANIFEST_FILE} ${SIMGRID_JAR} "NATIVE"
-    COMMAND ${CMAKE_COMMAND} -E remove ${SIMGRID_JAR}_finalized
-    COMMAND ${CMAKE_COMMAND} -E touch ${SIMGRID_JAR}_finalized
-    )
-  add_custom_target(SG_java_jar ALL DEPENDS ${SIMGRID_JAR}_finalized)
+  include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeJava.cmake)
 endif()
 
 add_dependencies(simgrid maintainer_files)
index e0e4c68..d6fd85d 100644 (file)
@@ -7,11 +7,17 @@
 #include "peer.h"
 #include "tracker.h"
 #include <msg/msg.h>
+#include <xbt/RngStream.h>
+
 /**
  * Bittorrent example launcher
  */
 int main(int argc, char *argv[])
 {
+  xbt_dynar_t host_list;
+  msg_host_t host;
+  unsigned i;
+
   MSG_init(&argc, argv);
 
   /* Check the arguments */
@@ -25,6 +31,15 @@ int main(int argc, char *argv[])
 
   MSG_create_environment(platform_file);
 
+  host_list = MSG_hosts_as_dynar();
+  xbt_dynar_foreach(host_list, i, host) {
+    char descr[512];
+    RngStream stream;
+    snprintf(descr, sizeof descr, "RngSream<%s>", MSG_host_get_name(host));
+    stream = RngStream_CreateStream(descr);
+    MSG_host_set_data(host, stream);
+  }
+
   MSG_function_register("tracker", tracker);
   MSG_function_register("peer", peer);
 
@@ -32,5 +47,11 @@ int main(int argc, char *argv[])
 
   MSG_main();
 
+  xbt_dynar_foreach(host_list, i, host) {
+    RngStream stream = MSG_host_get_data(host);
+    RngStream_DeleteStream(&stream);
+  }
+  xbt_dynar_free(&host_list);
+
   return 0;
 }
index 87881f4..2cad1e4 100644 (file)
@@ -53,4 +53,5 @@
  * Number of pieces the peer asks for simultaneously
  */
 #define MAX_PIECES 1
+
 #endif                          /* BITTORRENT_BITTORRENT_H_ */
index d5a8a9a..ec7df8a 100644 (file)
@@ -15,7 +15,7 @@ $ $SG_TEST_EXENV ${bindir:=.}/bittorrent ${srcdir:=.}/../msg_platform.xml ${srcd
 > [    0.000000] (8:peer@McGee) Hi, I'm joining the network with id 8
 > [ 3000.000000] (1:tracker@Jacquelin) Tracker is leaving
 > [ 5000.005340] (5:peer@Geoff) Here is my current status: 1111111111
-> [ 5000.012657] (7:peer@iRMX) Here is my current status: 1111111111
+> [ 5000.012635] (7:peer@iRMX) Here is my current status: 1111111111
 > [ 5000.048881] (2:peer@Boivin) Here is my current status: 1111111111
 > [ 5000.827441] (8:peer@McGee) Here is my current status: 1111111111
 > [ 5000.832977] (3:peer@Jean_Yves) Here is my current status: 1111111111
index 026be29..2a9db33 100644 (file)
@@ -239,7 +239,7 @@ void peer_init(peer_t peer, int id, int seed)
   peer->current_pieces = xbt_dynar_new(sizeof(int), NULL);
   peer->current_piece = -1;
 
-  peer->stream = RngStream_CreateStream("");
+  peer->stream = MSG_host_get_data(MSG_host_self());
   peer->comm_received = NULL;
 
   peer->round = 0;
@@ -265,8 +265,6 @@ void peer_free(peer_t peer)
   xbt_free(peer->pieces_count);
   xbt_free(peer->bitfield);
   xbt_free(peer->bitfield_blocks);
-
-  RngStream_DeleteStream(&peer->stream);
 }
 
 /**
index d619047..169b5d6 100644 (file)
@@ -19,7 +19,7 @@ int tracker(int argc, char *argv[])
 {
   int i;
 
-  RngStream stream = RngStream_CreateStream("tracker");
+  RngStream stream = MSG_host_get_data(MSG_host_self());
 
   //Checking arguments
   xbt_assert(argc == 2, "Wrong number of arguments for the tracker.");
@@ -78,8 +78,6 @@ int tracker(int argc, char *argv[])
   }
   //Free the peers list
   xbt_dynar_free(&peers_list);
-  //Free the RngStream object.
-  RngStream_DeleteStream(&stream);
 
   XBT_INFO("Tracker is leaving");
 
index 330ed56..986a463 100644 (file)
@@ -43,16 +43,16 @@ XBT_PUBLIC(void) MSG_config(const char *key, const char *value);
  *
  *  We allow to link against compiled versions that differ in the patch level.
  */
-#define MSG_init(argc,argv)  {                      \
-         int ver_major,ver_minor,ver_patch;              \
-         sg_version(&ver_major,&ver_minor,&ver_patch);   \
-         if ((ver_major != SIMGRID_VERSION_MAJOR) ||     \
-             (ver_minor != SIMGRID_VERSION_MINOR)) {     \
-           fprintf(stderr,"FATAL ERROR: Your program was compiled with SimGrid version %d.%d.%d, and then linked against SimGrid %d.%d.%d. Please fix this.\n", \
-               SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH,ver_major,ver_minor,ver_patch);                          \
-         }                                               \
-         MSG_init_nocheck(argc,argv);                    \
-       }
+#define MSG_init(argc,argv)  {                                          \
+    int ver_major,ver_minor,ver_patch;                                  \
+    sg_version(&ver_major,&ver_minor,&ver_patch);                       \
+    if ((ver_major != SIMGRID_VERSION_MAJOR) ||                         \
+        (ver_minor != SIMGRID_VERSION_MINOR)) {                         \
+      fprintf(stderr,"FATAL ERROR: Your program was compiled with SimGrid version %d.%d.%d, and then linked against SimGrid %d.%d.%d. Please fix this.\n", \
+              SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH,ver_major,ver_minor,ver_patch); \
+    }                                                                   \
+    MSG_init_nocheck(argc,argv);                                        \
+  }
 
 XBT_PUBLIC(void) MSG_init_nocheck(int *argc, char **argv);
 XBT_PUBLIC(msg_error_t) MSG_main(void);
@@ -195,6 +195,8 @@ XBT_PUBLIC(msg_error_t) MSG_task_destroy(msg_task_t task);
 
 XBT_PUBLIC(msg_error_t) MSG_task_receive_from_host(msg_task_t * task, const char *alias,
                                        msg_host_t host);
+XBT_PUBLIC(msg_error_t) MSG_task_receive_from_host_bounded(msg_task_t * task, const char *alias,
+                                       msg_host_t host, double rate);
 
 XBT_PUBLIC(msg_error_t) MSG_task_execute(msg_task_t task);
 XBT_PUBLIC(msg_error_t) MSG_parallel_task_execute(msg_task_t task);
@@ -206,7 +208,7 @@ XBT_PUBLIC(double) MSG_task_get_compute_duration(msg_task_t task);
 XBT_PUBLIC(void) MSG_task_set_compute_duration(msg_task_t task,
                                                double compute_duration);
 XBT_PUBLIC(void) MSG_task_set_data_size(msg_task_t task,
-                                              double data_size);
+                                        double data_size);
 
 XBT_PUBLIC(double) MSG_task_get_remaining_computation(msg_task_t task);
 XBT_PUBLIC(double) MSG_task_get_remaining_communication(msg_task_t task);
@@ -226,6 +228,20 @@ XBT_PUBLIC(msg_error_t)
     MSG_task_receive(msg_task_t * task, const char *alias);
 #define MSG_task_recv(t,a) MSG_task_receive(t,a)
 
+
+
+XBT_PUBLIC(msg_error_t)
+    MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, double timeout,
+                     msg_host_t host, double rate);
+
+XBT_PUBLIC(msg_error_t)
+    MSG_task_receive_with_timeout_bounded(msg_task_t * task, const char *alias,
+                              double timeout, double rate);
+
+XBT_PUBLIC(msg_error_t)
+    MSG_task_receive_bounded(msg_task_t * task, const char *alias,double rate);
+#define MSG_task_recv_bounded(t,a,r) MSG_task_receive_bounded(t,a,r)
+
 XBT_PUBLIC(msg_comm_t) MSG_task_isend(msg_task_t task, const char *alias);
 XBT_PUBLIC(msg_comm_t) MSG_task_isend_bounded(msg_task_t task, const char *alias, double maxrate);
 XBT_PUBLIC(msg_comm_t) MSG_task_isend_with_matching(msg_task_t task,
@@ -236,6 +252,7 @@ XBT_PUBLIC(msg_comm_t) MSG_task_isend_with_matching(msg_task_t task,
 XBT_PUBLIC(void) MSG_task_dsend(msg_task_t task, const char *alias, void_f_pvoid_t cleanup);
 XBT_PUBLIC(void) MSG_task_dsend_bounded(msg_task_t task, const char *alias, void_f_pvoid_t cleanup, double maxrate);
 XBT_PUBLIC(msg_comm_t) MSG_task_irecv(msg_task_t * task, const char *alias);
+XBT_PUBLIC(msg_comm_t) MSG_task_irecv_bounded(msg_task_t * task, const char *alias, double rate);
 XBT_PUBLIC(int) MSG_comm_test(msg_comm_t comm);
 XBT_PUBLIC(int) MSG_comm_testany(xbt_dynar_t comms);
 XBT_PUBLIC(void) MSG_comm_destroy(msg_comm_t comm);
@@ -254,7 +271,7 @@ XBT_PUBLIC(int) MSG_task_listen_from_host(const char *alias,
 XBT_PUBLIC(msg_error_t)
     MSG_task_send_with_timeout(msg_task_t task, const char *alias,
                            double timeout);
-    
+
 XBT_PUBLIC(msg_error_t)
     MSG_task_send_with_timeout_bounded(msg_task_t task, const char *alias,
                            double timeout, double maxrate);
@@ -275,6 +292,10 @@ XBT_PUBLIC(msg_error_t)
     MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, msg_task_t * task,
                          msg_host_t host, double timeout);
 
+XBT_PUBLIC(msg_error_t)
+    MSG_mailbox_get_task_ext_bounded(msg_mailbox_t mailbox, msg_task_t *task,
+                                     msg_host_t host, double timeout, double rate);
+
 XBT_PUBLIC(msg_error_t)
     MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, msg_task_t task,
                              double timeout);
index a856c0b..5997464 100644 (file)
@@ -409,6 +409,7 @@ XBT_PUBLIC(smx_action_t) simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff,
 XBT_PUBLIC(void) simcall_comm_destroy(smx_action_t comm);
 XBT_PUBLIC(smx_action_t) simcall_comm_iprobe(smx_rdv_t rdv, int src, int tag,
                                 int (*match_fun)(void *, void *, smx_action_t), void *data);
+XBT_PUBLIC(double) simcall_comm_change_rate_first_action(smx_rdv_t rdv, double newrate);
 XBT_PUBLIC(void) simcall_comm_cancel(smx_action_t comm);
 
 /* FIXME: waitany is going to be a vararg function, and should take a timeout */
index d706778..5f0a615 100644 (file)
@@ -52,6 +52,12 @@ SG_BEGIN_DECL()
   * \skip end_of_doxygen
   * \until }
   *
+  * Note that if you use dynars to store pointed data, the
+  * xbt_dynar_search(), xbt_dynar_search_or_negative() and
+  * xbt_dynar_member() won't be for you. Instead of comparing
+  * your pointed elements, they compare the pointer to them. See
+  * the documentation of xbt_dynar_search() for more info.
+  * 
   */
 /** @defgroup XBT_dynar_cons Dynar constructor and destructor
  *  @ingroup XBT_dynar
@@ -267,7 +273,7 @@ _xbt_dynar_cursor_get(const xbt_dynar_t dynar,
  *  @param _data
  *  @hideinitializer
  *
- * \note An example of usage:
+ * Here is an example of usage:
  * \code
 xbt_dynar_t dyn;
 unsigned int cpt;
@@ -276,6 +282,10 @@ xbt_dynar_foreach (dyn,cpt,str) {
   printf("Seen %s\n",str);
 }
 \endcode
+ * 
+ * Note that underneath, that's a simple for loop with no real black
+ * magic involved. It's perfectly safe to interrupt a foreach with a
+ * break or a return statement. 
  */
 #define xbt_dynar_foreach(_dynar,_cursor,_data) \
        for (_xbt_dynar_cursor_first(_dynar,&(_cursor))      ; \
index 1d45583..9266483 100644 (file)
@@ -6,12 +6,14 @@
   * under the terms of the license (GNU LGPL) which comes with this package. */
 #include "jmsg_file.h"
 #include "jxbt_utilities.h"
+
 void jfile_bind(JNIEnv *env, jobject jfile, msg_file_t stream) {
-  (*env)->SetLongField(env, jfile, jfile_field_bind, (jlong) (long) (stream));
+  (*env)->SetLongField(env, jfile, jfile_field_bind, (intptr_t)stream);
 }
 
 msg_file_t jfile_get_native(JNIEnv *env, jobject jfile) {
-  msg_file_t file = (msg_file_t)(*env)->GetLongField(env, jfile, jfile_field_bind);
+  msg_file_t file =
+    (msg_file_t)(intptr_t)(*env)->GetLongField(env, jfile, jfile_field_bind);
   return file;
 }
 
index 233a614..7e40aec 100644 (file)
@@ -56,17 +56,21 @@ void jprocess_join(jobject jprocess, JNIEnv * env)
 
 msg_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env)
 {
-  return (msg_process_t) (long) (*env)->GetLongField(env, jprocess, jprocess_field_Process_bind);
+  return
+    (msg_process_t)(intptr_t)(*env)->GetLongField(env, jprocess,
+                                                  jprocess_field_Process_bind);
 }
 
 void jprocess_bind(jobject jprocess, msg_process_t process, JNIEnv * env)
 {
-  (*env)->SetLongField(env, jprocess, jprocess_field_Process_bind, (jlong)(process));
+  (*env)->SetLongField(env, jprocess, jprocess_field_Process_bind,
+                       (intptr_t)process);
 }
 
 jlong jprocess_get_id(jobject jprocess, JNIEnv * env)
 {
-  return (*env)->GetLongField(env, jprocess, jprocess_field_Process_id);
+  return
+    (intptr_t)(*env)->GetLongField(env, jprocess, jprocess_field_Process_id);
 }
 
 jstring jprocess_get_name(jobject jprocess, JNIEnv * env)
@@ -128,7 +132,7 @@ Java_org_simgrid_msg_Process_create(JNIEnv * env,
   /* bind/retrieve the msg host */
   host = MSG_get_host_by_name(hostname);
 
-  if (!(host)) {    /* not binded */
+  if (!(host)) {    /* not bound */
     jxbt_throw_host_not_found(env, hostname);
     return;
   }
index a51c4cc..6610b84 100644 (file)
@@ -13,7 +13,8 @@
 jfieldID jrngstream_bind;
 
 RngStream jrngstream_to_native(JNIEnv *env, jobject jrngstream) {
-  RngStream rngstream = (RngStream) (*env)->GetLongField(env, jrngstream, jrngstream_bind);
+  RngStream rngstream =
+    (RngStream)(intptr_t)(*env)->GetLongField(env, jrngstream, jrngstream_bind);
   if (!rngstream) {
     jxbt_throw_notbound(env, "rngstream", jrngstream);
     return NULL;
@@ -33,7 +34,7 @@ Java_org_simgrid_msg_RngStream_create(JNIEnv *env, jobject jrngstream, jstring j
   const char *name = (*env)->GetStringUTFChars(env, jname, 0);
   RngStream rngstream = RngStream_CreateStream(name);
   //Bind the RngStream object
-  (*env)->SetLongField(env, jrngstream, jrngstream_bind, (jlong)rngstream);
+  (*env)->SetLongField(env, jrngstream, jrngstream_bind, (intptr_t)rngstream);
 
   (*env)->ReleaseStringUTFChars(env, jname, name);
 }
@@ -41,7 +42,7 @@ JNIEXPORT void JNICALL
 Java_org_simgrid_msg_RngStream_destroy(JNIEnv *env, jobject jrngstream) {
   RngStream rngstream = jrngstream_to_native(env, jrngstream);
   RngStream_DeleteStream(&rngstream);
-  (*env)->SetLongField(env, jrngstream, jrngstream_bind, (jlong)NULL);
+  (*env)->SetLongField(env, jrngstream, jrngstream_bind, (intptr_t)NULL);
 }
 JNIEXPORT jboolean JNICALL
 Java_org_simgrid_msg_RngStream_setPackageSeed(JNIEnv *env, jobject jrngstream, jintArray jseed) {
index 7e98a81..626afd5 100644 (file)
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
 
 void jvm_bind(JNIEnv *env, jobject jvm, msg_vm_t vm) {
-  (*env)->SetLongField(env, jvm, jvm_field_bind, (jlong) (long) (vm));
+  (*env)->SetLongField(env, jvm, jvm_field_bind, (intptr_t)vm);
 }
 msg_vm_t jvm_get_native(JNIEnv *env, jobject jvm) {
-       msg_vm_t vm = (msg_vm_t)(*env)->GetLongField(env, jvm, jvm_field_bind);
-       return vm;
+  return (msg_vm_t)(intptr_t)(*env)->GetLongField(env, jvm, jvm_field_bind);
 }
 
 JNIEXPORT void JNICALL
@@ -61,8 +60,8 @@ Java_org_simgrid_msg_VM_bind(JNIEnv *env, jobject jvm, jobject jprocess) {
   msg_vm_t vm = jvm_get_native(env,jvm);
   msg_process_t process = jprocess_to_native_process(jprocess,env);
 
-  xbt_assert((vm != NULL), "VM object is not binded");
-  xbt_assert((process != NULL), "Process object is not binded.");
+  xbt_assert((vm != NULL), "VM object is not bound");
+  xbt_assert((process != NULL), "Process object is not bound.");
 
   MSG_vm_bind(vm,process);
 }
index 4752c7c..8d5084c 100644 (file)
@@ -10,6 +10,7 @@
 #define JXBT_UTILITY_H
 
 #include <jni.h>
+#include <stdint.h>
 
 /* *********** */
 /* JNI GETTERS */
index 6684147..c00dd54 100644 (file)
@@ -16,7 +16,7 @@ package org.simgrid.msg;
  * Thus it is represented as a physical resource with computing capabilities, some 
  * mailboxes to enable running process to communicate with remote ones, and some private 
  * data that can be only accessed by local process. An instance of this class is always 
- * binded with the corresponding native host. All the native hosts are automatically created 
+ * bound with the corresponding native host. All the native hosts are automatically created
  * during the call of the method Msg.createEnvironment(). This method take as parameter a
  * platform file which describes all elements of the platform (host, link, root..).
  * You cannot create a host yourself.
index 650606c..2b2c4b2 100644 (file)
@@ -195,7 +195,7 @@ public abstract class Process implements Runnable {
        }
        /**
         * The natively implemented method to create an MSG process.
-        * @param hostName    A valid (binded) host where create the process.
+        * @param hostName    A valid (bound) host where create the process.
         */
        protected native void create(String hostName) throws HostNotFoundException;
        /**
index 9389a55..785c3df 100644 (file)
@@ -58,7 +58,7 @@ public class VM {
         */     
        public native void bind(Process process);
        /** Removes the given process from the given VM, and kill it
-        *  Will raise a ProcessNotFound exception if the process were not binded to that VM
+        *  Will raise a ProcessNotFound exception if the process were not bound to that VM
         */     
        public native void unbind(Process process);
        /** Immediately change the host on which all processes are running
index 00fe9b5..4983f73 100644 (file)
@@ -210,7 +210,9 @@ static void smx_ctx_cojava_suspend(smx_context_t context)
     else if (!java_context->bound) {
       java_context->bound = 1;
       smx_process_t process = SIMIX_process_self();
-      (*global_env)->SetLongField(global_env, java_context->jprocess, jprocess_field_Process_bind, (jlong)process);
+      (*global_env)->SetLongField(global_env, java_context->jprocess,
+                                  jprocess_field_Process_bind,
+                                  (intptr_t)process);
     }
 
     next_coroutine = java_context->jcoroutine;
@@ -236,7 +238,8 @@ static void smx_ctx_cojava_resume(smx_context_t new_context) {
   else if (!java_context->bound) {
     java_context->bound = 1;
     smx_process_t process = SIMIX_process_self();
-    (*global_env)->SetLongField(global_env, java_context->jprocess, jprocess_field_Process_bind, (jlong)process);
+    (*global_env)->SetLongField(global_env, java_context->jprocess,
+                                jprocess_field_Process_bind, (intptr_t)process);
   }
   (*global_env)->CallStaticVoidMethod(global_env, coclass, coroutine_yieldTo, java_context->jcoroutine);
 }
index 1f7a8de..695af57 100644 (file)
@@ -18,7 +18,7 @@ SG_BEGIN_DECL()
 
 typedef struct s_smx_ctx_cojava {
   s_smx_ctx_base_t super;       /* Fields of super implementation */
-  jobject jprocess;             /* the java process instance binded with the msg process structure */
+  jobject jprocess;             /* the java process instance bound with the msg process structure */
   JNIEnv *jenv;                 /* jni interface pointer associated to this thread */
   jobject jcoroutine;                                          /* java coroutine object */
   int bound:1;
index 02f6f7b..02406f2 100644 (file)
@@ -110,7 +110,8 @@ static void* smx_ctx_java_thread_run(void *data) {
   }
   else {
     smx_process_t process = SIMIX_process_self();
-    (*env)->SetLongField(env, context->jprocess, jprocess_field_Process_bind, (jlong)process);
+    (*env)->SetLongField(env, context->jprocess, jprocess_field_Process_bind,
+                         (intptr_t)process);
   }
   xbt_assert((context->jprocess != NULL), "Process not created...");
   //wait for the process to be able to begin
index 084c5d4..789bf17 100644 (file)
@@ -18,7 +18,7 @@ SG_BEGIN_DECL()
 
 typedef struct s_smx_ctx_java {
   s_smx_ctx_base_t super;       /* Fields of super implementation */
-  jobject jprocess;             /* the java process instance binded with the msg process structure */
+  jobject jprocess;             /* the java process instance bound with the msg process structure */
   JNIEnv *jenv;                 /* jni interface pointer associated to this thread */
   xbt_os_thread_t thread;
   xbt_os_sem_t begin;           /* this semaphore is used to schedule/yield the process  */
index e37e0d7..aeb6ad3 100644 (file)
@@ -199,6 +199,26 @@ MSG_task_receive_from_host(msg_task_t * task, const char *alias,
   return MSG_task_receive_ext(task, alias, -1, host);
 }
 
+/** msg_task_usage
+ *\brief Deprecated function that used to receive a task from a mailbox from a specific host
+ *\brief at a given rate
+ *
+ * \param task a memory location for storing a #msg_task_t.
+ * \param alias name of the mailbox to receive the task from
+ * \param host a #msg_host_t host from where the task was sent
+ * \param rate limit the reception to rate bandwidth
+ *
+ * \return Returns
+ * #MSG_OK if the task was successfully received,
+ * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE otherwise.
+ */
+msg_error_t
+MSG_task_receive_from_host_bounded(msg_task_t * task, const char *alias,
+                           msg_host_t host, double rate)
+{
+  return MSG_task_receive_ext_bounded(task, alias, -1, host, rate);
+}
+
 /** \ingroup msg_task_usage
  * \brief Receives a task from a mailbox.
  *
@@ -218,6 +238,22 @@ msg_error_t MSG_task_receive(msg_task_t * task, const char *alias)
   return MSG_task_receive_with_timeout(task, alias, -1);
 }
 
+/** \ingroup msg_task_usage
+ * \brief Receives a task from a mailbox at a given rate.
+ *
+ * \param task a memory location for storing a #msg_task_t.
+ * \param alias name of the mailbox to receive the task from
+ *  \param rate limit the reception to rate bandwidth
+ *
+ * \return Returns
+ * #MSG_OK if the task was successfully received,
+ * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE otherwise.
+ */
+msg_error_t MSG_task_receive_bounded(msg_task_t * task, const char *alias, double rate)
+{
+  return MSG_task_receive_with_timeout_bounded(task, alias, -1, rate);
+}
+
 /** \ingroup msg_task_usage
  * \brief Receives a task from a mailbox with a given timeout.
  *
@@ -241,6 +277,25 @@ MSG_task_receive_with_timeout(msg_task_t * task, const char *alias,
   return MSG_task_receive_ext(task, alias, timeout, NULL);
 }
 
+/** \ingroup msg_task_usage
+ * \brief Receives a task from a mailbox with a given timeout and at a given rate.
+ *
+ * \param task a memory location for storing a #msg_task_t.
+ * \param alias name of the mailbox to receive the task from
+ * \param timeout is the maximum wait time for completion (if -1, this call is the same as #MSG_task_receive)
+ *  \param rate limit the reception to rate bandwidth
+ *
+ * \return Returns
+ * #MSG_OK if the task was successfully received,
+ * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE, or #MSG_TIMEOUT otherwise.
+ */
+msg_error_t
+MSG_task_receive_with_timeout_bounded(msg_task_t * task, const char *alias,
+                              double timeout,double rate)
+{
+  return MSG_task_receive_ext_bounded(task, alias, timeout, NULL,rate);
+}
+
 /** \ingroup msg_task_usage
  * \brief Receives a task from a mailbox from a specific host with a given timeout.
  *
@@ -284,6 +339,31 @@ MSG_task_receive_ext(msg_task_t * task, const char *alias, double timeout,
   return ret;
 }
 
+/** \ingroup msg_task_usage
+ * \brief Receives a task from a mailbox from a specific host with a given timeout
+ *  and at a given rate.
+ *
+ * \param task a memory location for storing a #msg_task_t.
+ * \param alias name of the mailbox to receive the task from
+ * \param timeout is the maximum wait time for completion (provide -1 for no timeout)
+ * \param host a #msg_host_t host from where the task was sent
+ * \param rate limit the reception to rate bandwidth
+ *
+ * \return Returns
+ * #MSG_OK if the task was successfully received,
+* #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE, or #MSG_TIMEOUT otherwise.
+ */
+msg_error_t
+MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, double timeout,
+                     msg_host_t host, double rate)
+{
+  XBT_DEBUG
+      ("MSG_task_receive_ext: Trying to receive a message on mailbox '%s'",
+       alias);
+  return MSG_mailbox_get_task_ext_bounded(MSG_mailbox_get_by_alias(alias), task,
+                                  host, timeout, rate);
+}
+
 /** \ingroup msg_task_usage
  * \brief Sends a task on a mailbox.
  *
@@ -528,6 +608,40 @@ msg_comm_t MSG_task_irecv(msg_task_t *task, const char *name)
   return comm;
 }
 
+/** \ingroup msg_task_usage
+ * \brief Starts listening for receiving a task from an asynchronous communication
+ * at a given rate.
+ *
+ * \param task a memory location for storing a #msg_task_t. has to be valid until the end of the communication.
+ * \param name of the mailbox to receive the task on
+ * \param rate limit the bandwidth to the given rate
+ * \return the msg_comm_t communication created
+ */
+msg_comm_t MSG_task_irecv_bounded(msg_task_t *task, const char *name, double rate)
+{
+
+
+  smx_rdv_t rdv = MSG_mailbox_get_by_alias(name);
+  simcall_comm_change_rate_first_action(rdv,rate);
+  /* FIXME: these functions are not traceable */
+
+  /* Sanity check */
+  xbt_assert(task, "Null pointer for the task storage");
+
+  if (*task)
+    XBT_CRITICAL
+        ("MSG_task_irecv() was asked to write in a non empty task struct.");
+
+  /* Try to receive it by calling SIMIX network layer */
+  msg_comm_t comm = xbt_new0(s_msg_comm_t, 1);
+  comm->task_sent = NULL;
+  comm->task_received = task;
+  comm->status = MSG_OK;
+  comm->s_comm = simcall_comm_irecv(rdv, task, NULL, NULL, NULL);
+
+  return comm;
+}
+
 /** \ingroup msg_task_usage
  * \brief Checks whether a communication is done, and if yes, finalizes it.
  * \param comm the communication to test
index 1abbf0e..15d9c3f 100644 (file)
@@ -44,6 +44,10 @@ MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox,
   return simcall_rdv_comm_count_by_host(mailbox, host);
 }
 
+double MSG_set_rate_before_read(msg_mailbox_t mailbox, double newrate) {
+       return simcall_comm_change_rate_first_action(mailbox,newrate);
+}
+
 msg_mailbox_t MSG_mailbox_get_by_alias(const char *alias)
 {
 
@@ -141,6 +145,30 @@ MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, msg_task_t * task,
   MSG_RETURN(ret);
 }
 
+
+
+/** \ingroup msg_mailbox_management
+ * \brief Get a task from a mailbox on a given host at a given rate
+ *
+ * \param mailbox The mailbox where the task was sent
+ * \param task a memory location for storing a #msg_task_t.
+ * \param host a #msg_host_t host from where the task was sent
+ * \param timeout a timeout
+ * \param rate a bandwidth rate
+
+ * \return Returns
+ * #MSG_OK if the task was successfully received,
+ * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE otherwise.
+ */
+msg_error_t
+MSG_mailbox_get_task_ext_bounded(msg_mailbox_t mailbox, msg_task_t * task,
+                         msg_host_t host, double timeout, double rate)
+{
+       MSG_set_rate_before_read(mailbox,rate);
+       MSG_RETURN(MSG_mailbox_get_task_ext(mailbox,task,host,timeout));
+}
+
+
 msg_error_t
 MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, msg_task_t task,
                              double timeout)
index 9f3f379..ac387d6 100644 (file)
@@ -40,6 +40,13 @@ void MSG_mailbox_free(void *mailbox);
  */
 void MSG_mailbox_free(void *mailbox);
 
+/* \brief MSG_set_rate_before_read - set a rate before receiving a task
+ *
+ * \param mailbox  The mailbox to release.
+ * \param rate    The new rate
+ */
+double MSG_set_rate_before_read(msg_mailbox_t mailbox, double rate);
+
 /* \brief MSG_mailbox_get_by_alias - get a mailbox from its alias.
  *
  * The function MSG_mailbox_get_by_alias returns the mailbox associated with
index 175317b..f46e7ca 100644 (file)
@@ -90,7 +90,7 @@ void MSG_vm_bind(msg_vm_t vm, msg_process_t process) {
 /** @brief Removes the given process from the given VM, and kill it
  *  @ingroup msg_VMs
  *
- *  Will raise a not_found exception if the process were not binded to that VM
+ *  Will raise a not_found exception if the process were not bound to that VM
  */
 void MSG_vm_unbind(msg_vm_t vm, msg_process_t process) {
   int pos = xbt_dynar_search(vm->processes,process);
index f013642..f618fdf 100644 (file)
@@ -735,6 +735,29 @@ smx_action_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_
 }
 
 
+/**
+ * \ingroup simix_comm_management
+ */
+double simcall_comm_change_rate_first_action(smx_rdv_t rdv, double newrate)
+{
+  xbt_assert(rdv, "No rendez-vous point defined for change_rate_first_action");
+
+  smx_action_t action;
+  xbt_fifo_item_t item;
+
+  item = xbt_fifo_get_first_item(rdv->comm_fifo);
+  if (item != NULL) {
+    action = (smx_action_t) xbt_fifo_get_item_content(item);
+    if (action->comm.rate > newrate) {
+      action->comm.rate = newrate;
+      return newrate;
+    } else
+      return action->comm.rate;
+  } else
+    return -1.0;
+}
+
+
 /**
  * \ingroup simix_comm_management
  */
index c5fc212..285a03b 100644 (file)
@@ -160,60 +160,24 @@ static void recursiveGraphExtraction (AS_t rc, container_t container, xbt_dict_t
     }
   }
 
-  //let's get routes
-  xbt_dict_cursor_t cursor1 = NULL, cursor2 = NULL;
-  container_t child1, child2;
-  const char *child1_name, *child2_name;
-  xbt_dict_foreach(container->children, cursor1, child1_name, child1) {
-    //if child1 is not a link, a smpi node, a msg process, a msg vm or a msg task
-    if (child1->kind == INSTR_LINK || child1->kind == INSTR_SMPI || child1->kind == INSTR_MSG_PROCESS || child1->kind == INSTR_MSG_VM || child1->kind == INSTR_MSG_TASK) continue;
-
-    xbt_dict_foreach(container->children, cursor2, child2_name, child2) {
-      //if child2 is not a link, a smpi node, a msg process, a msg vm or a msg task
-      if (child2->kind == INSTR_LINK || child2->kind == INSTR_SMPI || child2->kind == INSTR_MSG_PROCESS || child2->kind == INSTR_MSG_VM || child2->kind == INSTR_MSG_TASK) continue;
-
-      //if child1 is not child2
-      if (strcmp (child1_name, child2_name) == 0) continue;
-
-      //get the route
-      sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1);
-      route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t),NULL);
-      rc->get_route_and_latency(rc, child1->net_elm, child2->net_elm,
-                                route, NULL);
-
-      //user might want to extract a graph using routes with only one link
-      //see --cfg=tracing/onelink_only:1 or --help-tracing for details
-      if (TRACE_onelink_only() && xbt_dynar_length (route->link_list) > 1){
-        generic_free_route(route);
-        continue;
-      }
+  {
+       xbt_graph_t graph = xbt_graph_new_graph (0, NULL);
+    xbt_dict_t nodes = xbt_dict_new_homogeneous(NULL);
+    xbt_dict_t edges = xbt_dict_new_homogeneous(NULL);
+    xbt_edge_t edge = NULL;
 
-      //traverse the route connecting the containers
-      unsigned int cpt;
-      void *link;
-      container_t current, previous;
-      if (route->gw_src){
-        previous = PJ_container_get(route->gw_src->name);
-      }else{
-        previous = child1;
-      }
+    xbt_dict_cursor_t cursor = NULL;
+    char *edge_name;
 
-      xbt_dynar_foreach (route->link_list, cpt, link) {
-        //FIXME (TODO): Should have a cleaner way to get the link name
-        char *link_name = ((link_CM02_t)link)->lmm_resource.generic_resource.name;
-        current = PJ_container_get(link_name);
-        linkContainers(previous, current, filter);
-        previous = current;
-      }
-      if (route->gw_dst){
-        current = PJ_container_get(route->gw_dst->name);
-      }else{
-        current = child2;
-      }
-      linkContainers(previous, current, filter);
-      generic_free_route(route);
+    rc->get_graph(graph,nodes,edges,rc);
+    xbt_dict_foreach(edges,cursor,edge_name,edge) {
+        linkContainers(PJ_container_get(edge->src->data), PJ_container_get(edge->dst->data), filter);
     }
+    xbt_dict_free (&nodes);
+    xbt_dict_free (&edges);
+    xbt_graph_free_graph(graph,xbt_free, xbt_free, NULL);
   }
+
 }
 
 /*
@@ -498,41 +462,6 @@ int instr_platform_traced ()
 #define GRAPHICATOR_SUPPORT_FUNCTIONS
 
 
-static xbt_node_t new_xbt_graph_node (xbt_graph_t graph, const char *name, xbt_dict_t nodes)
-{
-  xbt_node_t ret = xbt_dict_get_or_null (nodes, name);
-  if (ret) return ret;
-
-  ret = xbt_graph_new_node (graph, xbt_strdup(name));
-  xbt_dict_set (nodes, name, ret, NULL);
-  return ret;
-}
-
-static 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;
-  char *name = (char*)xbt_malloc(len * sizeof(char));
-
-
-  snprintf (name, len, "%s%s", sn, dn);
-  ret = xbt_dict_get_or_null (edges, name);
-  if (ret == NULL){
-    snprintf (name, len, "%s%s", dn, sn);
-    ret = xbt_dict_get_or_null (edges, name);
-  }
-
-  if (ret == NULL){
-    ret = xbt_graph_new_edge(graph, s, d, NULL);
-    xbt_dict_set (edges, name, ret, NULL);
-  }
-  free (name);
-  return ret;
-}
-
 static void recursiveXBTGraphExtraction (xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges,
     AS_t rc, container_t container)
 {
@@ -547,58 +476,7 @@ static void recursiveXBTGraphExtraction (xbt_graph_t graph, xbt_dict_t nodes, xb
     }
   }
 
-  //let's get routes
-  xbt_dict_cursor_t cursor1 = NULL, cursor2 = NULL;
-  container_t child1, child2;
-  const char *child1_name, *child2_name;
-  xbt_dict_foreach(container->children, cursor1, child1_name, child1) {
-    //if child1 is not a link, a smpi node, a msg process, a msg vm or a msg task
-    if (child1->kind == INSTR_LINK || child1->kind == INSTR_SMPI || child1->kind == INSTR_MSG_PROCESS || child1->kind == INSTR_MSG_VM || child1->kind == INSTR_MSG_TASK) continue;
-
-    xbt_dict_foreach(container->children, cursor2, child2_name, child2) {
-      //if child2 is not a link, a smpi node, a msg process or a msg task
-      if (child2->kind == INSTR_LINK || child2->kind == INSTR_SMPI || child2->kind == INSTR_MSG_PROCESS || child2->kind == INSTR_MSG_VM || child2->kind == INSTR_MSG_TASK) continue;
-
-      //if child1 is not child2
-      if (strcmp (child1_name, child2_name) == 0) continue;
-
-      //get the route
-      sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1);
-      route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t),NULL);
-      rc->get_route_and_latency(rc, child1->net_elm, child2->net_elm,
-                                route, NULL);
-
-      //user might want to extract a graph using routes with only one link
-      //see --cfg=tracing/onelink_only:1 or --help-tracing for details
-      if (TRACE_onelink_only() && xbt_dynar_length (route->link_list) > 1) continue;
-
-      //traverse the route connecting the containers
-      unsigned int cpt;
-      void *link;
-      xbt_node_t current, previous;
-      if (route->gw_src){
-        previous = new_xbt_graph_node(graph, route->gw_src->name, nodes);
-      }else{
-        previous = new_xbt_graph_node(graph, child1_name, nodes);
-      }
-
-      xbt_dynar_foreach (route->link_list, cpt, link) {
-        char *link_name = ((link_CM02_t)link)->lmm_resource.generic_resource.name;
-        current = new_xbt_graph_node(graph, link_name, nodes);
-        new_xbt_graph_edge (graph, previous, current, edges);
-        //previous -> current
-        previous = current;
-      }
-      if (route->gw_dst){
-        current = new_xbt_graph_node(graph, route->gw_dst->name, nodes);
-      }else{
-        current = new_xbt_graph_node(graph, child2_name, nodes);
-      }
-      new_xbt_graph_edge (graph, previous, current, edges);
-      generic_free_route(route);
-    }
-  }
-
+  rc->get_graph(graph,nodes,edges,rc);
 }
 
 xbt_graph_t instr_routing_platform_graph (void)
index 4732aa3..c01d50b 100644 (file)
@@ -153,6 +153,7 @@ typedef struct s_as {
   void (*get_route_and_latency) (AS_t as, sg_routing_edge_t src, sg_routing_edge_t dst, sg_platf_route_cbarg_t into, double *latency);
 
   xbt_dynar_t(*get_onelink_routes) (AS_t as);
+  void (*get_graph) (xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges, AS_t rc);
   sg_platf_route_cbarg_t(*get_bypass_route) (AS_t as, sg_routing_edge_t src, sg_routing_edge_t dst, double *lat);
   void (*finalize) (AS_t as);
 
@@ -192,6 +193,7 @@ XBT_PUBLIC(void) generic_free_route(sg_platf_route_cbarg_t route); // FIXME rena
 XBT_PUBLIC(void) routing_get_route_and_latency(sg_routing_edge_t src, sg_routing_edge_t dst,
                               xbt_dynar_t * route, double *latency);
 
+XBT_PUBLIC(void) generic_get_graph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges, AS_t rc);
 /**
  * Resource protected methods
  */
index cf77d31..8e25069 100644 (file)
@@ -920,6 +920,7 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster)
         bprintf("%s%s_router%s", cluster->prefix, cluster->id,
                 cluster->suffix);
   sg_platf_new_router(&router);
+  ((as_cluster_t)current_routing)->router = xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL);
   free(newid);
 
   //Make the backbone
index 37f2e32..f2d468a 100644 (file)
@@ -4,6 +4,7 @@
 /* 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 "surf_routing_private.h"
+#include "xbt/graph.h"
 
 /* Global vars */
 
@@ -15,40 +16,213 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf"
 
 /* Business methods */
 static void cluster_get_route_and_latency(AS_t as,
-    sg_routing_edge_t src, sg_routing_edge_t dst,
-    sg_platf_route_cbarg_t route, double *lat) {
-
-      s_surf_parsing_link_up_down_t info;
-    XBT_DEBUG("cluster_get_route_and_latency from '%s'[%d] to '%s'[%d]",
-        src->name,src->id,
-        dst->name,dst->id);
-
-    if(src->rc_type != SURF_NETWORK_ELEMENT_ROUTER){ // No specific link for router
-        info = xbt_dynar_get_as(as->link_up_down_list,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);
-        if (lat)
-          *lat += surf_network_model->extension.network.get_link_latency(info.link_up);
-        }
+                                          sg_routing_edge_t src,
+                                          sg_routing_edge_t dst,
+                                          sg_platf_route_cbarg_t route,
+                                          double *lat)
+{
+
+  s_surf_parsing_link_up_down_t info;
+  XBT_DEBUG("cluster_get_route_and_latency from '%s'[%d] to '%s'[%d]",
+            src->name, src->id, dst->name, dst->id);
+
+  if (src->rc_type != SURF_NETWORK_ELEMENT_ROUTER) {    // No specific link for router
+    info =
+        xbt_dynar_get_as(as->link_up_down_list, 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);
+      if (lat)
+        *lat +=
+            surf_network_model->extension.network.get_link_latency(info.
+                                                                   link_up);
     }
+  }
+
+  if (((as_cluster_t) as)->backbone) {
+    xbt_dynar_push_as(route->link_list, void *, ((as_cluster_t) as)->backbone);
+    if (lat)
+      *lat +=
+          surf_network_model->extension.network.
+          get_link_latency(((as_cluster_t) as)->backbone);
+  }
 
-    if ( ((as_cluster_t)as)->backbone ) {
-      xbt_dynar_push_as(route->link_list,void*, ((as_cluster_t)as)->backbone) ;
+  if (dst->rc_type != SURF_NETWORK_ELEMENT_ROUTER) {    // No specific link for router
+    info =
+        xbt_dynar_get_as(as->link_up_down_list, 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);
       if (lat)
-        *lat += surf_network_model->extension.network.get_link_latency(((as_cluster_t)as)->backbone);
+        *lat +=
+            surf_network_model->extension.network.get_link_latency(info.
+                                                                   link_down);
+    }
+  }
+}
+
+static void cluster_get_graph(xbt_graph_t graph, xbt_dict_t nodes,
+                              xbt_dict_t edges, AS_t rc)
+{
+  int isrc;
+  int table_size = xbt_dynar_length(rc->index_network_elm);
+
+  sg_routing_edge_t src;
+  xbt_node_t current, previous, backboneNode = NULL, routerNode;
+  s_surf_parsing_link_up_down_t info;
+
+  xbt_assert(((as_cluster_t) rc)->router,"Malformed cluster");
+
+  /* create the router */
+  char *link_name =
+    ((sg_routing_edge_t) ((as_cluster_t) rc)->router)->name;
+  routerNode = new_xbt_graph_node(graph, link_name, nodes);
+
+  if(((as_cluster_t) rc)->backbone) {
+    char *link_nameR =
+      ((surf_resource_t) ((as_cluster_t) rc)->backbone)->name;
+    backboneNode = new_xbt_graph_node(graph, link_nameR, nodes);
+
+    new_xbt_graph_edge(graph, routerNode, backboneNode, edges);
+  }
+
+  for (isrc = 0; isrc < table_size; isrc++) {
+    src = xbt_dynar_get_as(rc->index_network_elm, isrc, sg_routing_edge_t);
+
+    if (src->rc_type != SURF_NETWORK_ELEMENT_ROUTER) {
+      previous = new_xbt_graph_node(graph, src->name, nodes);
+
+      info = xbt_dynar_get_as(rc->link_up_down_list, src->id,
+                              s_surf_parsing_link_up_down_t);
+
+      if (info.link_up) {     // link up
+
+        char *link_name = ((surf_resource_t) info.link_up)->name;
+        current = new_xbt_graph_node(graph, link_name, nodes);
+        new_xbt_graph_edge(graph, previous, current, edges);
+
+        if (((as_cluster_t) rc)->backbone) {
+          new_xbt_graph_edge(graph, current, backboneNode, edges);
+        } else {
+          new_xbt_graph_edge(graph, current, routerNode, edges);
+        }
+
+      }
+
+      if (info.link_down) {    // link down
+        char *link_name = ((surf_resource_t) info.link_down)->name;
+        current = new_xbt_graph_node(graph, link_name, nodes);
+        new_xbt_graph_edge(graph, previous, current, edges);
+
+        if (((as_cluster_t) rc)->backbone) {
+          new_xbt_graph_edge(graph, current, backboneNode, edges);
+        } else {
+          new_xbt_graph_edge(graph, current, routerNode, edges);
+        }
+
+      }
+/*
+      if (((as_cluster_t) rc)->backbone) {
+        char *link_name =
+          ((surf_resource_t) ((as_cluster_t) rc)->backbone)->name;
+
+        current = new_xbt_graph_node(graph, link_name, nodes);
+        new_xbt_graph_edge(graph, previous, current, edges);
+        previous = current;
+
+        revCurrent = new_xbt_graph_node(graph, link_name, nodes);
+        new_xbt_graph_edge(graph, revCurrent, revPrevious, edges);
+        revPrevious = revCurrent;
+      } else {
+        info = xbt_dynar_get_as(rc->link_up_down_list, dst->id,
+                                s_surf_parsing_link_up_down_t);
+
+        if (info.link_up) {     // link up
+          char *link_name = ((surf_resource_t) info.link_up)->name;
+          current = new_xbt_graph_node(graph, link_name, nodes);
+          new_xbt_graph_edge(graph, previous, current, edges);
+          previous = current;
+        } else if (info.link_down) {    // link down
+          char *link_name = ((surf_resource_t) info.link_down)->name;
+          revCurrent = new_xbt_graph_node(graph, link_name, nodes);
+          new_xbt_graph_edge(graph, revCurrent, revPrevious, edges);
+          revPrevious = revCurrent;
+        }
+      }
+*/
     }
+  }
+/*
+  if(rc->)
+    for (isrc = 0; isrc < table_size; isrc++) {
+      src = xbt_dynar_get_as(rc->index_network_elm, isrc, sg_routing_edge_t);
+
+      previous = new_xbt_graph_node(graph, src->name, nodes);
+      revPrevious = new_xbt_graph_node(graph, src->name, nodes);
+
+      for (idst = isrc + 1; idst < table_size; idst++) {
+        dst = xbt_dynar_get_as(rc->index_network_elm, idst, sg_routing_edge_t);
+
+        s_surf_parsing_link_up_down_t info;
+
+        if (src->rc_type != SURF_NETWORK_ELEMENT_ROUTER) {        // No specific link for router
+          info =
+            xbt_dynar_get_as(rc->link_up_down_list, src->id,
+                             s_surf_parsing_link_up_down_t);
 
-    if(dst->rc_type != SURF_NETWORK_ELEMENT_ROUTER){ // No specific link for router
-        info = xbt_dynar_get_as(as->link_up_down_list,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);
-        if (lat)
-          *lat += surf_network_model->extension.network.get_link_latency(info.link_down);
+          if (info.link_up) {     // link up
+            char *link_name = ((surf_resource_t) info.link_up)->name;
+            current = new_xbt_graph_node(graph, link_name, nodes);
+            new_xbt_graph_edge(graph, previous, current, edges);
+            previous = current;
+          } else if (info.link_down) {    // link down
+            char *link_name = ((surf_resource_t) info.link_down)->name;
+            revCurrent = new_xbt_graph_node(graph, link_name, nodes);
+            new_xbt_graph_edge(graph, revCurrent, revPrevious, edges);
+            revPrevious = revCurrent;
+          }
         }
+
+
+
+        if (((as_cluster_t) rc)->backbone) {
+          char *link_name =
+            ((surf_resource_t) ((as_cluster_t) rc)->backbone)->name;
+
+          current = new_xbt_graph_node(graph, link_name, nodes);
+          new_xbt_graph_edge(graph, previous, current, edges);
+          previous = current;
+
+          revCurrent = new_xbt_graph_node(graph, link_name, nodes);
+          new_xbt_graph_edge(graph, revCurrent, revPrevious, edges);
+          revPrevious = revCurrent;
+        }
+
+        if (dst->rc_type != SURF_NETWORK_ELEMENT_ROUTER) {        // No specific link for router
+          info =
+            xbt_dynar_get_as(rc->link_up_down_list, dst->id,
+                             s_surf_parsing_link_up_down_t);
+
+          if (info.link_up) {     // link up
+            char *link_name = ((surf_resource_t) info.link_up)->name;
+            current = new_xbt_graph_node(graph, link_name, nodes);
+            new_xbt_graph_edge(graph, previous, current, edges);
+            previous = current;
+          } else if (info.link_down) {    // link down
+            char *link_name = ((surf_resource_t) info.link_down)->name;
+            revCurrent = new_xbt_graph_node(graph, link_name, nodes);
+            new_xbt_graph_edge(graph, revCurrent, revPrevious, edges);
+            revPrevious = revCurrent;
+          }
+        }
+
+      }
     }
+*/
 }
 
-static void model_cluster_finalize(AS_t as) {
+static void model_cluster_finalize(AS_t as)
+{
   model_none_finalize(as);
 }
 
@@ -70,6 +244,7 @@ AS_t model_cluster_create(void)
   AS_t result = model_none_create_sized(sizeof(s_as_cluster_t));
   result->get_route_and_latency = cluster_get_route_and_latency;
   result->finalize = model_cluster_finalize;
+  result->get_graph = cluster_get_graph;
   result->parse_AS = cluster_parse_AS;
   result->parse_PU = cluster_parse_PU;
 
index 7d7eac4..4b0d4c9 100644 (file)
@@ -156,8 +156,7 @@ static void add_loopback_dijkstra(as_dijkstra_t as) {
     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(sg_routing_link_t), NULL);
-      xbt_dynar_push(e_route->link_list,
-          &routing_platf->loopback);
+      xbt_dynar_push(e_route->link_list, &routing_platf->loopback);
       xbt_graph_new_edge(as->route_graph, node, node, e_route);
     }
   }
@@ -420,6 +419,7 @@ AS_t model_dijkstra_both_create(int cached)
   new_component->generic_routing.get_route_and_latency = dijkstra_get_route_and_latency;
   new_component->generic_routing.get_onelink_routes =
       dijkstra_get_onelink_routes;
+  new_component->generic_routing.get_graph = generic_get_graph;
   new_component->generic_routing.finalize = dijkstra_finalize;
   new_component->cached = cached;
 
index 5bce7d4..0f08c52 100644 (file)
@@ -146,6 +146,7 @@ AS_t model_floyd_create(void)
   new_component->generic_routing.get_route_and_latency = floyd_get_route_and_latency;
   new_component->generic_routing.get_onelink_routes =
       floyd_get_onelink_routes;
+  new_component->generic_routing.get_graph = generic_get_graph;
   new_component->generic_routing.finalize = floyd_finalize;
   return (AS_t)new_component;
 }
index 71cdfc6..0fb3422 100644 (file)
@@ -115,6 +115,8 @@ AS_t model_full_create(void)
   new_component->generic_routing.parse_ASroute = model_full_set_route;
   new_component->generic_routing.get_route_and_latency =
       full_get_route_and_latency;
+  new_component->generic_routing.get_graph = generic_get_graph;
+
   new_component->generic_routing.get_onelink_routes = full_get_onelink_routes;
   new_component->generic_routing.finalize = full_finalize;
 
index 177c092..e6192c6 100644 (file)
@@ -9,6 +9,7 @@
 #include "surf_routing_private.h"
 #include "surf/surf_routing.h"
 #include "surf/surfxml_parse_values.h"
+#include "xbt/graph.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic implementation of the surf routing");
 
@@ -91,11 +92,109 @@ xbt_dynar_t generic_get_onelink_routes(AS_t rc) { // FIXME: kill that stub
   return NULL;
 }
 
-sg_platf_route_cbarg_t generic_get_bypassroute(AS_t rc, sg_routing_edge_t src, sg_routing_edge_t dst, double *lat)
+static const char *instr_node_name(xbt_node_t node)
+{
+  void *data = xbt_graph_node_get_data(node);
+  char *str = (char *) data;
+  return str;
+}
+
+xbt_node_t new_xbt_graph_node(xbt_graph_t graph, const char *name,
+                              xbt_dict_t nodes)
+{
+  xbt_node_t ret = xbt_dict_get_or_null(nodes, name);
+  if (ret)
+    return ret;
+
+  ret = xbt_graph_new_node(graph, xbt_strdup(name));
+  xbt_dict_set(nodes, name, ret, NULL);
+  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 ret;
+
+  const char *sn = instr_node_name(s);
+  const char *dn = instr_node_name(d);
+  int len = strlen(sn) + strlen(dn) + 1;
+  char *name = (char *) xbt_malloc(len * sizeof(char));
+
+
+  snprintf(name, len, "%s%s", sn, dn);
+  ret = xbt_dict_get_or_null(edges, name);
+  if (ret == NULL) {
+    snprintf(name, len, "%s%s", dn, sn);
+    ret = xbt_dict_get_or_null(edges, name);
+  }
+
+  if (ret == NULL) {
+    ret = xbt_graph_new_edge(graph, s, d, NULL);
+    xbt_dict_set(edges, name, ret, NULL);
+  }
+  free(name);
+  return ret;
+}
+
+void generic_get_graph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges,
+                       AS_t rc)
+{
+  int src, dst;
+  int table_size = xbt_dynar_length(rc->index_network_elm);
+
+  sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
+  route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
+
+  for (src = 0; src < table_size; src++) {
+    sg_routing_edge_t my_src =
+        xbt_dynar_get_as(rc->index_network_elm, src, sg_routing_edge_t);
+    for (dst = 0; dst < table_size; dst++) {
+      if (src == dst)
+        continue;
+      sg_routing_edge_t my_dst =
+          xbt_dynar_get_as(rc->index_network_elm, dst, sg_routing_edge_t);
+
+      rc->get_route_and_latency(rc, my_src, my_dst, route, NULL);
+
+      if (route) {
+        unsigned int cpt;
+        void *link;
+
+        xbt_node_t current, previous;
+
+        if (route->gw_src) {
+          previous = new_xbt_graph_node(graph, route->gw_src->name, nodes);
+        } else {
+          previous = new_xbt_graph_node(graph, my_src->name, nodes);
+        }
+
+        xbt_dynar_foreach(route->link_list, cpt, link) {
+          char *link_name = ((surf_resource_t) link)->name;
+          current = new_xbt_graph_node(graph, link_name, nodes);
+          new_xbt_graph_edge(graph, previous, current, edges);
+          previous = current;
+        }
+
+        if (route->gw_dst) {
+          current = new_xbt_graph_node(graph, route->gw_dst->name, nodes);
+        } else {
+          current = new_xbt_graph_node(graph, my_dst->name, nodes);
+        }
+        new_xbt_graph_edge(graph, previous, current, edges);
+
+      }
+    }
+  }
+}
+
+sg_platf_route_cbarg_t generic_get_bypassroute(AS_t rc, sg_routing_edge_t src,
+                                               sg_routing_edge_t dst,
+                                               double *lat)
 {
   // If never set a bypass route return NULL without any further computations
-  XBT_DEBUG("generic_get_bypassroute from %s to %s",src->name,dst->name);
-  if(no_bypassroute_declared)
+  XBT_DEBUG("generic_get_bypassroute from %s to %s", src->name, dst->name);
+  if (no_bypassroute_declared)
     return NULL;
 
   sg_platf_route_cbarg_t e_route_bypass = NULL;
index 1f403c8..46d667b 100644 (file)
@@ -18,6 +18,11 @@ static void none_get_route_and_latency(AS_t rc, sg_routing_edge_t src, sg_routin
   *lat = 0.0;
 }
 
+static void none_get_graph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges, AS_t rc)
+{
+       XBT_INFO("No routing no graph");
+}
+
 static sg_platf_route_cbarg_t none_get_bypass_route(AS_t rc,
     sg_routing_edge_t src,
     sg_routing_edge_t dst, double *lat) {
@@ -53,6 +58,7 @@ AS_t model_none_create_sized(size_t childsize) {
   new_component->get_onelink_routes = none_get_onelink_routes;
   new_component->get_bypass_route = none_get_bypass_route;
   new_component->finalize = model_none_finalize;
+  new_component->get_graph = none_get_graph;
   new_component->routing_sons = xbt_dict_new_homogeneous(NULL);
   new_component->index_network_elm = xbt_dynar_new(sizeof(char*),NULL);
 
index cdc5fb4..c1369d0 100644 (file)
@@ -57,7 +57,6 @@ generic_processing_units_exist(AS_t rc, char *element);
 void generic_src_dst_check(AS_t rc, sg_routing_edge_t src,
     sg_routing_edge_t dst);
 
-
 /* ************************************************************************** */
 /* *************************** FLOYD ROUTING ******************************** */
 AS_t model_floyd_create(void);  /* create structures for floyd routing model */
@@ -73,6 +72,7 @@ AS_t model_rulebased_create(void);      /* create structures for rulebased routi
 typedef struct {
   s_as_t generic_routing;
   void *backbone;
+  sg_routing_edge_t router;
 } s_as_cluster_t, *as_cluster_t;
 
 AS_t model_cluster_create(void);      /* create structures for cluster routing model */
@@ -98,6 +98,10 @@ AS_t model_full_create(void);   /* create structures for full routing model */
 void model_full_end(AS_t as);       /* finalize the creation of full routing model */
 void model_full_set_route(  /* Set the route and ASroute between src and dst */
     AS_t rc, sg_platf_route_cbarg_t route);
+/* ************************************************************************** */
+/* ************************* GRAPH EXPORTING FUNCTIONS ********************** */
+xbt_node_t new_xbt_graph_node (xbt_graph_t graph, const char *name, xbt_dict_t nodes);
+xbt_edge_t new_xbt_graph_edge (xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xbt_dict_t edges);
 
 
 #endif                          /* _SURF_SURF_ROUTING_PRIVATE_H */
index 53d87be..2c69fc9 100644 (file)
@@ -64,14 +64,14 @@ static void rule_route_extended_free(void *e)
 static int model_rulebased_parse_PU(AS_t rc, sg_routing_edge_t elm)
 {
   AS_rulebased_t routing = (AS_rulebased_t) rc;
-  xbt_dynar_push(routing->generic_routing.index_network_elm,(void *)elm);
+  xbt_dynar_push(routing->generic_routing.index_network_elm,&elm);
   return -1;
 }
 
 static int model_rulebased_parse_AS(AS_t rc, sg_routing_edge_t elm)
 {
   AS_rulebased_t routing = (AS_rulebased_t) rc;
-  xbt_dynar_push(routing->generic_routing.index_network_elm,(void *)elm);
+  xbt_dynar_push(routing->generic_routing.index_network_elm,&elm);
   return -1;
 }
 
@@ -394,6 +394,7 @@ AS_t model_rulebased_create(void) {
   new_component->generic_routing.get_onelink_routes = rulebased_get_onelink_routes;
   new_component->generic_routing.get_route_and_latency = rulebased_get_route_and_latency;
   new_component->generic_routing.get_bypass_route = rulebased_get_bypass_route;
+  new_component->generic_routing.get_graph = generic_get_graph;
   new_component->generic_routing.finalize = rulebased_finalize;
   /* initialization of internal structures */
   new_component->list_route = xbt_dynar_new(sizeof(rule_route_t), &rule_route_free);
index 2079a80..ed8a80c 100644 (file)
@@ -105,5 +105,6 @@ AS_t model_vivaldi_create(void)
   AS_t new_component = model_rulebased_create();
   new_component->get_route_and_latency = vivaldi_get_route_and_latency;
   new_component->parse_PU = vivaldi_parse_PU;
+  new_component->get_graph = generic_get_graph;
   return new_component;
 }
index 2c03573..18a6f49 100644 (file)
@@ -841,6 +841,7 @@ void surf_parse_close(void)
   xbt_dynar_free(&surf_parsed_filename_stack);
 
   free(surf_parsed_filename);
+  surf_parsed_filename = NULL;
 
   if (surf_file_to_parse) {
     surf_parse__delete_buffer(surf_input_buffer);
index 720b376..8c7cd9f 100644 (file)
@@ -466,6 +466,19 @@ xbt_dynar_remove_n_at(xbt_dynar_t const dynar,
 
 /** @brief Returns the position of the element in the dynar
  *
+ * Beware that if your dynar contains pointed values (such as strings) instead 
+ * of scalar, this function compares the pointer value, not what's pointed. The only
+ * solution to search for a pointed value is then to write the foreach loop yourself:
+ * \code
+ * signed int position = -1;
+ * xbt_dynar_foreach(dynar, iter, elem) {
+ *    if (!memcmp(elem, searched_element, sizeof(*elem))) {
+ *        position = iter;
+ *        break;
+ *    }
+ * }
+ * \endcode
+ * 
  * Raises not_found_error if not found. If you have less than 2 millions elements,
  * you probably want to use #xbt_dynar_search_or_negative() instead, so that you
  * don't have to TRY/CATCH on element not found.
@@ -485,6 +498,10 @@ unsigned int xbt_dynar_search(xbt_dynar_t const dynar, void *const elem)
 
 /** @brief Returns the position of the element in the dynar (or -1 if not found)
  *
+ * Beware that if your dynar contains pointed values (such as
+ * strings) instead of scalar, this function is probably not what you
+ * want. Check the documentation of xbt_dynar_search() for more info.
+ * 
  * Note that usually, the dynar indices are unsigned integers. If you have more
  * than 2 million elements in your dynar, this very function will not work (but the other will).
  */
@@ -500,7 +517,12 @@ signed int xbt_dynar_search_or_negative(xbt_dynar_t const dynar, void *const ele
   return -1;
 }
 
-/** @brief Returns a boolean indicating whether the element is part of the dynar */
+/** @brief Returns a boolean indicating whether the element is part of the dynar 
+ *
+ * Beware that if your dynar contains pointed values (such as
+ * strings) instead of scalar, this function is probably not what you
+ * want. Check the documentation of xbt_dynar_search() for more info.
+ */
 int xbt_dynar_member(xbt_dynar_t const dynar, void *const elem)
 {
 
index 3ee7e01..75a58bf 100755 (executable)
@@ -120,7 +120,14 @@ RunTest getproc 1 "*** Test Get Processor Name ***"
 #
 # If there was a Unix standard interface to ps, we could check for orphaned
 # processes...
-if ps -fwu $LOGNAME > /dev/null 2>&1 ; then
+if ps --version | grep procps > /dev/null 2>&1 ; then
+   # This is a try to be a better choice than ps -u because it
+   # restricts the list of processes to those of the current session.
+   # The options are known to work with the ps command from the procps
+   # package.
+   SESSION=`ps -o sess= $$`
+   PSPGM="ps -o pid,tname,command -s $SESSION"
+elif ps -fwu $LOGNAME > /dev/null 2>&1 ; then
    # This is a better choice than ps aux because it restricts the list of 
    # processes to those of the running user.  The w is needed on some
    # systems to get a long output for the command