From 9304dfd37fe98984bb8b1ae13a107438ed44189f Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 25 Jan 2021 14:58:47 +0100 Subject: [PATCH] Revert "Assert that the log categories are unique" The proposed method is not reliable, because when log categories are not unique, there is 2 variables of the same name and 2 constructors of the same name. Redefinitions should thus be detected by the linker and we cannot fix it reliably from our side. I'll use less common category names in the library to reduce the risk of conflict. This reverts commit 7ca53b5ebe9b96f24832b6890a34e13599b254c2. --- examples/c/io-disk-raw/io-disk-raw.c | 2 +- examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp | 2 +- examples/smpi/replay/replay.cpp | 2 +- .../trace_call_location.tesh | 4 +-- include/xbt/log.h | 25 ++++++++++++++----- src/smpi/internals/smpi_global.cpp | 2 +- src/xbt/log.cpp | 12 --------- teshsuite/smpi/gh-139/gh-139.tesh | 2 +- teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.tesh | 4 +-- 9 files changed, 28 insertions(+), 27 deletions(-) diff --git a/examples/c/io-disk-raw/io-disk-raw.c b/examples/c/io-disk-raw/io-disk-raw.c index 4a09da3704..c6e4fa7e3d 100644 --- a/examples/c/io-disk-raw/io-disk-raw.c +++ b/examples/c/io-disk-raw/io-disk-raw.c @@ -15,7 +15,7 @@ #include #include -XBT_LOG_NEW_DEFAULT_CATEGORY(disk_example, "Messages specific for this simulation"); +XBT_LOG_NEW_DEFAULT_CATEGORY(disk, "Messages specific for this simulation"); static void host(int argc, char* argv[]) { diff --git a/examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp b/examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp index 4b36bebf2a..7d69d361ee 100644 --- a/examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp +++ b/examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp @@ -7,7 +7,7 @@ #include #include -XBT_LOG_NEW_DEFAULT_CATEGORY(disk_test, "Messages specific for this simulation"); +XBT_LOG_NEW_DEFAULT_CATEGORY(disk, "Messages specific for this simulation"); static void host() { diff --git a/examples/smpi/replay/replay.cpp b/examples/smpi/replay/replay.cpp index a71fd99205..441c991307 100644 --- a/examples/smpi/replay/replay.cpp +++ b/examples/smpi/replay/replay.cpp @@ -10,7 +10,7 @@ #include "xbt/str.h" #include "xbt/log.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(replay_test, "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_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. */ diff --git a/examples/smpi/trace_call_location/trace_call_location.tesh b/examples/smpi/trace_call_location/trace_call_location.tesh index 3ac6412a19..cfa3993aae 100644 --- a/examples/smpi/trace_call_location/trace_call_location.tesh +++ b/examples/smpi/trace_call_location/trace_call_location.tesh @@ -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 --log=log.thres:error +$ ${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 > [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 --log=log.thres:error --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 --cfg=smpi/simulate-computation:no > [Fafard:2:(3) 1.007967] [smpi_replay/INFO] Simulation time 1.007967 $ rm -f ${bindir:=.}/smpi_trace.tx* diff --git a/include/xbt/log.h b/include/xbt/log.h index 1e6292b25c..5ee5e4b286 100644 --- a/include/xbt/log.h +++ b/include/xbt/log.h @@ -5,8 +5,25 @@ /* 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. */ -/* Define the XBT_LOG_MAYDAY symbol to change all logging facilities into basic printfs, e.g. to debug the logs - * themselves. */ +/** @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 XBT_LOG_MAYDAY #ifndef XBT_LOG_H @@ -81,9 +98,6 @@ 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 */ @@ -94,7 +108,6 @@ void _xbt_log_is_name_unique(const char* name, const char* file, int line); 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); \ } \ diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index 2e96efe233..ce1c397f4e 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -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 diff --git a/src/xbt/log.cpp b/src/xbt/log.cpp index fa02f97812..4819878dfb 100644 --- a/src/xbt/log.cpp +++ b/src/xbt/log.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include int xbt_log_no_loc = 0; /* if set to true (with --log=no_loc), file localization will be omitted (for tesh tests) */ @@ -248,16 +247,6 @@ 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 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! @@ -265,7 +254,6 @@ void _xbt_log_is_name_unique(const char* name, const char* file, int line) 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; diff --git a/teshsuite/smpi/gh-139/gh-139.tesh b/teshsuite/smpi/gh-139/gh-139.tesh index 2afe088ede..f9a9233c87 100644 --- a/teshsuite/smpi/gh-139/gh-139.tesh +++ b/teshsuite/smpi/gh-139/gh-139.tesh @@ -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 --log=log.thres:error +$ ${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 > [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 diff --git a/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.tesh b/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.tesh index 789caee74b..675262edeb 100644 --- a/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.tesh +++ b/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.tesh @@ -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 --log=log.thres:error --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 --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 --log=log.thres:error +$ ${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 > [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 -- 2.20.1