Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Assert that the log categories are unique
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 25 Jan 2021 10:06:53 +0000 (11:06 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 25 Jan 2021 10:06:57 +0000 (11:06 +0100)
This interacts badly with SMPI that loads the same binary several
times, as its constructors are naturally started several times. This
is why it's not a real assert but a warning for now.

examples/c/io-disk-raw/io-disk-raw.c
examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp
examples/smpi/replay/replay.cpp
examples/smpi/trace_call_location/trace_call_location.tesh
include/xbt/log.h
src/smpi/internals/smpi_global.cpp
src/xbt/log.cpp
teshsuite/smpi/gh-139/gh-139.tesh
teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.tesh

index c6e4fa7..4a09da3 100644 (file)
@@ -15,7 +15,7 @@
 #include <stddef.h>
 #include <stdlib.h>
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(disk, "Messages specific for this simulation");
+XBT_LOG_NEW_DEFAULT_CATEGORY(disk_example, "Messages specific for this simulation");
 
 static void host(int argc, char* argv[])
 {
index 7d69d36..4b36beb 100644 (file)
@@ -7,7 +7,7 @@
 #include <string>
 #include <unordered_map>
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(disk, "Messages specific for this simulation");
+XBT_LOG_NEW_DEFAULT_CATEGORY(disk_test, "Messages specific for this simulation");
 
 static void host()
 {
index 441c991..a71fd99 100644 (file)
@@ -10,7 +10,7 @@
 #include "xbt/str.h"
 
 #include "xbt/log.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(replay_test, "Messages specific for this msg example");
 
 /* This shows how to extend the trace format by adding a new kind of events.
    This function is registered through xbt_replay_action_register() below. */
index cfa3993..3ac6412 100644 (file)
@@ -15,11 +15,11 @@ $ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace-ti -trace-file ${bindir:=
 
 #Test replaying the trace, without altering the time.
 #We disable computation, but leave the sleep.
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ${srcdir:=.}/hostfile -platform ${platfdir}/small_platform.xml -np 3 -replay ${bindir:=.}/smpi_trace.txt ${bindir:=.}/../replay/smpi_replay --cfg=smpi/host-speed:1f --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/simulate-computation:no
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ${srcdir:=.}/hostfile -platform ${platfdir}/small_platform.xml -np 3 -replay ${bindir:=.}/smpi_trace.txt ${bindir:=.}/../replay/smpi_replay --cfg=smpi/host-speed:1f --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/simulate-computation:no --log=log.thres:error
 > [Fafard:2:(3) 1000.007967] [smpi_replay/INFO] Simulation time 1000.007967
 
 #Test replaying the trace, altering the time to have the sleep much faster (1 instead of 1000).
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ${srcdir:=.}/hostfile -platform ${platfdir}/small_platform.xml --cfg=smpi/comp-adjustment-file:${srcdir:=.}/trace_call_location/adjust -np 3 -replay ${bindir:=.}/smpi_trace.txt ${bindir:=.}/../replay/smpi_replay  --cfg=smpi/host-speed:1f --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/simulate-computation:no
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ${srcdir:=.}/hostfile -platform ${platfdir}/small_platform.xml --cfg=smpi/comp-adjustment-file:${srcdir:=.}/trace_call_location/adjust -np 3 -replay ${bindir:=.}/smpi_trace.txt ${bindir:=.}/../replay/smpi_replay  --cfg=smpi/host-speed:1f --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning  --log=log.thres:error --cfg=smpi/simulate-computation:no
 > [Fafard:2:(3) 1.007967] [smpi_replay/INFO] Simulation time 1.007967
 
 $ rm -f ${bindir:=.}/smpi_trace.tx*
index 5ee5e4b..1e6292b 100644 (file)
@@ -5,25 +5,8 @@
 /* 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. */
 
-/** @addtogroup XBT_log
- *  @brief A generic logging facility in the spirit of log4j (grounding feature)
- *
- */
-
-/** @defgroup XBT_log_cats Existing log categories
- *  @ingroup XBT_log
- *  @brief (automatically extracted)
- *
- *  This is the list of all existing log categories in SimGrid.
- *  This list is automatically extracted from the source code by the tools/doxygen/xbt_log_extract_hierarchy.pl utility.
- *
- *  It should thus contain every categories that are defined in the SimGrid library.
- *  If you want to see the one defined in your code in addition, provide `--help-logs` on the command line of your
- * simulator.
- */
-
-/* XBT_LOG_MAYDAY: define this to replace the logging facilities with basic printf function.
-   Useful to debug the logging facilities themselves, or to not make prehistoric source analysis tools mad. */
+/* Define the XBT_LOG_MAYDAY symbol to change all logging facilities into basic printfs, e.g. to debug the logs
+ * themselves. */
 //#define XBT_LOG_MAYDAY
 
 #ifndef XBT_LOG_H
@@ -98,6 +81,9 @@ typedef enum {
  * start of main().
  */
 
+/* Asserts that the provided name was not already used for another category */
+void _xbt_log_is_name_unique(const char* name, const char* file, int line);
+
 /* XBT_LOG_NEW_SUBCATEGORY_helper:
  * Implementation of XBT_LOG_NEW_SUBCATEGORY, which must declare "extern parent" in addition to avoid an extra
  * declaration of root when XBT_LOG_NEW_SUBCATEGORY is called by XBT_LOG_NEW_CATEGORY */
@@ -108,6 +94,7 @@ typedef enum {
   void _XBT_LOGV_CTOR(catName)(void)                                                                                   \
   {                                                                                                                    \
     XBT_LOG_EXTERNAL_CATEGORY(catName);                                                                                \
+    _xbt_log_is_name_unique(_XBT_STRINGIFY(catName), __FILE__, __LINE__);                                              \
     if (!_XBT_LOGV(catName).initialized) {                                                                             \
       _xbt_log_cat_init(&_XBT_LOGV(catName), xbt_log_priority_uninitialized);                                          \
     }                                                                                                                  \
index ce1c397..2e96efe 100644 (file)
@@ -542,7 +542,7 @@ int smpi_main(const char* executable, int argc, char* argv[])
   simgrid::instr::init();
   SIMIX_global_init(&argc, argv);
 
-  auto engine              = simgrid::s4u::Engine::get_instance();
+  auto engine = simgrid::s4u::Engine::get_instance();
 
   sg_storage_file_system_init();
   // parse the platform file: get the host list
index 6be9068..fd8afa0 100644 (file)
@@ -16,6 +16,7 @@
 #include <array>
 #include <mutex>
 #include <string>
+#include <unordered_set>
 #include <vector>
 
 int xbt_log_no_loc = 0; /* if set to true (with --log=no_loc), file localization will be omitted (for tesh tests) */
@@ -247,6 +248,16 @@ static void _xbt_log_cat_apply_set(xbt_log_category_t category, const xbt_log_se
   }
 }
 
+/** Asserts that the provided name is unique */
+void _xbt_log_is_name_unique(const char* name, const char* file, int line)
+{
+  static std::unordered_set<std::string> used_names;
+
+  if (used_names.find(name) != used_names.end())
+    XBT_WARN("%s:%d: log category redefined: %s", file, line, name);
+  used_names.insert(std::string(name));
+}
+
 /*
  * This gets called the first time a category is referenced and performs the initialization.
  * Also resets threshold to inherited!
@@ -254,6 +265,7 @@ static void _xbt_log_cat_apply_set(xbt_log_category_t category, const xbt_log_se
 int _xbt_log_cat_init(xbt_log_category_t category, e_xbt_log_priority_t priority)
 {
   DISABLE_XBT_LOG_CAT_INIT();
+
   if (category->initialized)
     return priority >= category->threshold;
 
index f9a9233..2afe088 100644 (file)
@@ -1,4 +1,4 @@
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -np 2 -platform ../../../examples/platforms/small_platform.xml -hostfile ../hostfile ${bindir:=.}/gh-139 --cfg=smpi/simulate-computation:no --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -np 2 -platform ../../../examples/platforms/small_platform.xml -hostfile ../hostfile ${bindir:=.}/gh-139 --cfg=smpi/simulate-computation:no --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning  --log=log.thres:error
 > [Tremblay:0:(1) 0.000000] [smpi_test/INFO] I'm 0/2
 > [Jupiter:1:(2) 0.000000] [smpi_test/INFO] I'm 1/2
 > [Tremblay:wait send:(3) 0.000000] [smpi_test/INFO] new thread has parameter rank 0 and global variable rank 0
index 675262e..789caee 100644 (file)
@@ -1,6 +1,6 @@
 p Test dsend
 ! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ${bindir:=.}/../hostfile -platform ${platfdir}/small_platform.xml -np 2 ${bindir:=.}/pt2pt-dsend -s --long --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/simulate-computation:no
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ${bindir:=.}/../hostfile -platform ${platfdir}/small_platform.xml -np 2 ${bindir:=.}/pt2pt-dsend -s --long --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning --log=log.thres:error --cfg=smpi/simulate-computation:no
 > [Jupiter:1:(2) 0.000000] [dsend/INFO] rank 1: data exchanged
 > [Tremblay:0:(1) 0.005896] [dsend/INFO] rank 0: data exchanged
 > [rank 0] -> Tremblay
@@ -11,7 +11,7 @@ p message size is 4 bytes
 p process 1 will finish at 0.5+2*4 (send) + 1+0.1*4 (isend) = 9.9s
 p process 2 will finish at 0.5+2*4 (time before first send) + 2*(1+0.5*4) (recv+irecv) + 0.005890 (network time, same as before) = 14.505890s
 ! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ${bindir:=.}/../hostfile -platform ${platfdir}/small_platform.xml -np 2 ${bindir:=.}/pt2pt-dsend -s --long --log=smpi_config.thres:warning --cfg=smpi/or:0:1:0.5 --cfg=smpi/os:0:0.5:2 --cfg=smpi/ois:0:1:0.1 --cfg=smpi/simulate-computation:no --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ${bindir:=.}/../hostfile -platform ${platfdir}/small_platform.xml -np 2 ${bindir:=.}/pt2pt-dsend -s --long --log=smpi_config.thres:warning --cfg=smpi/or:0:1:0.5 --cfg=smpi/os:0:0.5:2 --cfg=smpi/ois:0:1:0.1 --cfg=smpi/simulate-computation:no --log=xbt_cfg.thres:warning --log=log.thres:error
 > [Jupiter:1:(2) 9.900000] [dsend/INFO] rank 1: data exchanged
 > [Tremblay:0:(1) 14.505896] [dsend/INFO] rank 0: data exchanged
 > [rank 0] -> Tremblay