Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
convert graphicator to C++
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Sun, 29 Mar 2020 12:08:42 +0000 (14:08 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Sun, 29 Mar 2020 12:08:42 +0000 (14:08 +0200)
also test the output .dot file in tesh

MANIFEST.in
tools/graphicator/CMakeLists.txt
tools/graphicator/graphicator.cpp [moved from tools/graphicator/graphicator.c with 64% similarity]
tools/graphicator/graphicator.tesh

index 05520f4..c6627be 100644 (file)
@@ -1724,7 +1724,7 @@ include tools/doxygen/fig2dev_postprocessor.pl
 include tools/doxygen/xbt_log_extract_hierarchy.pl
 include tools/fix-paje-trace.sh
 include tools/generate-dwarf-functions
-include tools/graphicator/graphicator.c
+include tools/graphicator/graphicator.cpp
 include tools/graphicator/graphicator.tesh
 include tools/normalize-pointers.py
 include tools/pkg-config/simgrid.pc.in
index 4c526be..715e159 100644 (file)
@@ -1,16 +1,15 @@
-if(enable_msg)
-  add_executable       (graphicator graphicator.c)
-  add_dependencies     (tests       graphicator)
-  target_link_libraries(graphicator simgrid)
-  set_target_properties(graphicator PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
-  ADD_TESH(graphicator --setenv srcdir=${CMAKE_HOME_DIRECTORY} --setenv bindir=${CMAKE_BINARY_DIR}/bin --cd ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/graphicator.tesh)
+add_executable       (graphicator graphicator.cpp)
+add_dependencies     (tests       graphicator)
+target_link_libraries(graphicator simgrid)
+set_target_properties(graphicator PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
+ADD_TESH(graphicator --setenv srcdir=${CMAKE_HOME_DIRECTORY} --setenv bindir=${CMAKE_BINARY_DIR}/bin
+                     --cd ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/graphicator.tesh)
 
-  install(TARGETS graphicator DESTINATION ${CMAKE_INSTALL_BINDIR}/)
+install(TARGETS graphicator DESTINATION ${CMAKE_INSTALL_BINDIR}/)
 
-  ## Clean generated files
-  get_directory_property(extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES)
-  set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${extra_clean_files};${CMAKE_CURRENT_BINARY_DIR}/simgrid.trace;")
-endif()
+## Clean generated files
+get_directory_property(extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES)
+set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${extra_clean_files};${CMAKE_CURRENT_BINARY_DIR}/simgrid.trace;")
 
 set(tesh_files  ${tesh_files}  ${CMAKE_CURRENT_SOURCE_DIR}/graphicator.tesh  PARENT_SCOPE)
-set(tools_src   ${tools_src}   ${CMAKE_CURRENT_SOURCE_DIR}/graphicator.c     PARENT_SCOPE)
+set(tools_src   ${tools_src}   ${CMAKE_CURRENT_SOURCE_DIR}/graphicator.cpp   PARENT_SCOPE)
similarity index 64%
rename from tools/graphicator/graphicator.c
rename to tools/graphicator/graphicator.cpp
index 14c471e..9d90d2b 100644 (file)
@@ -4,19 +4,20 @@
 /* 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 "simgrid/msg.h"
+#include "simgrid/instr.h"
+#include "simgrid/s4u.hpp"
 #include "xbt/graph.h"
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
-  MSG_init(&argc, argv);
+  simgrid::s4u::Engine e(&argc, argv);
 
   xbt_assert(argc == 3, "Usage: %s <platform_file.xml> <graphviz_file.dot>", argv[0]);
 
-  MSG_create_environment(argv[1]);
-  int status = TRACE_platform_graph_export_graphviz (argv[2]);
+  e.load_platform(argv[1]);
+  int status = TRACE_platform_graph_export_graphviz(argv[2]);
 
   xbt_assert(status != 0, "%s expects --cfg=tracing:yes --cfg=tracing/platform:yes", argv[0]);
-  MSG_main(); /* useless, except for correctly cleaning memory */
+  e.run(); /* useless, except for correctly cleaning memory */
   return 0;
 }
index eec5619..4a2d5bf 100644 (file)
@@ -4,4 +4,50 @@ $ ${bindir:=.}/graphicator ${srcdir:=.}/teshsuite/simdag/platforms/one_cluster.x
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/platform' to 'yes'
 
-$ rm test.dot
+$ cat test.dot
+> graph test {
+>   graph [overlap=scale]
+>   node [shape=box, style=filled]
+>   node [width=.3, height=.3, style=filled, color=skyblue]
+>
+>   "bobbob_cluster_router.hamburger.edu";
+>   "bob_cluster_backbone";
+>   "bob0.hamburger.edu";
+>   "bob_cluster_link_0_UP";
+>   "bob_cluster_link_0_DOWN";
+>   "bob2.hamburger.edu";
+>   "bob_cluster_link_2_UP";
+>   "bob_cluster_link_2_DOWN";
+>   "bob3.hamburger.edu";
+>   "bob_cluster_link_3_UP";
+>   "bob_cluster_link_3_DOWN";
+>   "bob4.hamburger.edu";
+>   "bob_cluster_link_4_UP";
+>   "bob_cluster_link_4_DOWN";
+>   "bob6.hamburger.edu";
+>   "bob_cluster_link_6_UP";
+>   "bob_cluster_link_6_DOWN";
+>   "bobbob_cluster_router.hamburger.edu" -- "bob_cluster_backbone";
+>   "bob0.hamburger.edu" -- "bob_cluster_link_0_UP";
+>   "bob_cluster_link_0_UP" -- "bob_cluster_backbone";
+>   "bob0.hamburger.edu" -- "bob_cluster_link_0_DOWN";
+>   "bob_cluster_link_0_DOWN" -- "bob_cluster_backbone";
+>   "bob2.hamburger.edu" -- "bob_cluster_link_2_UP";
+>   "bob_cluster_link_2_UP" -- "bob_cluster_backbone";
+>   "bob2.hamburger.edu" -- "bob_cluster_link_2_DOWN";
+>   "bob_cluster_link_2_DOWN" -- "bob_cluster_backbone";
+>   "bob3.hamburger.edu" -- "bob_cluster_link_3_UP";
+>   "bob_cluster_link_3_UP" -- "bob_cluster_backbone";
+>   "bob3.hamburger.edu" -- "bob_cluster_link_3_DOWN";
+>   "bob_cluster_link_3_DOWN" -- "bob_cluster_backbone";
+>   "bob4.hamburger.edu" -- "bob_cluster_link_4_UP";
+>   "bob_cluster_link_4_UP" -- "bob_cluster_backbone";
+>   "bob4.hamburger.edu" -- "bob_cluster_link_4_DOWN";
+>   "bob_cluster_link_4_DOWN" -- "bob_cluster_backbone";
+>   "bob6.hamburger.edu" -- "bob_cluster_link_6_UP";
+>   "bob_cluster_link_6_UP" -- "bob_cluster_backbone";
+>   "bob6.hamburger.edu" -- "bob_cluster_link_6_DOWN";
+>   "bob_cluster_link_6_DOWN" -- "bob_cluster_backbone";
+> }
+
+$ rm -f test.dot