From 470a545069a336d3e14a08c827fb50c89246ad6b Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 6 Oct 2020 09:40:36 +0000 Subject: [PATCH] fixed glog bug, enable stack trace, used python faulthandler --- cmake/Dependencies.cmake | 2 +- include/singa/utils/logging.h | 1 + python/singa/__init__.py | 5 +++++ src/api/core_tensor.i | 4 ++++ src/core/tensor/tensor.cc | 1 - test/gtest/gtest_main.cc | 2 ++ test/singa/test_logging.cc | 1 - 7 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index a4257a638f..60c4327291 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -67,7 +67,7 @@ ENDIF() FIND_PACKAGE(Glog) IF(GLOG_FOUND) - #MESSAGE(STATUS "GLOG FOUND at ${GLOG_INCLUDE_DIR}") + MESSAGE(STATUS "FOUND GLOG at ${GLOG_INCLUDE_DIR}") #ADD_DEFINITIONS("-DUSE_GLOG") SET(USE_GLOG TRUE) LIST(APPEND SINGA_LINKER_LIBS ${GLOG_LIBRARIES}) diff --git a/include/singa/utils/logging.h b/include/singa/utils/logging.h index 9b9e64323e..92ab7336e5 100644 --- a/include/singa/utils/logging.h +++ b/include/singa/utils/logging.h @@ -24,6 +24,7 @@ #ifndef SINGA_UTILS_LOGGING_H_ #define SINGA_UTILS_LOGGING_H_ +#include "singa/singa_config.h" #include #include diff --git a/python/singa/__init__.py b/python/singa/__init__.py index 039d356b8f..11db05ae7e 100644 --- a/python/singa/__init__.py +++ b/python/singa/__init__.py @@ -17,4 +17,9 @@ from . import singa_wrap +import faulthandler +faulthandler.enable() + +singa_wrap.InitLogging("") + __version__ = singa_wrap.SINGA_VERSION diff --git a/src/api/core_tensor.i b/src/api/core_tensor.i index 04e75e0697..154240af6c 100755 --- a/src/api/core_tensor.i +++ b/src/api/core_tensor.i @@ -34,6 +34,8 @@ #include "singa/proto/core.pb.h" // #include "singa/proto/model.pb.h" #include "half.hpp" +#include "singa/utils/logging.h" + using singa::DataType; %} %shared_ptr(singa::Device) @@ -384,4 +386,6 @@ namespace singa{ Tensor CrossEntropyFwd(const Tensor& p, const Tensor& t); Tensor SoftmaxCrossEntropyBwd(const Tensor& p, const Tensor& t); + + void InitLogging(const char* argv); } diff --git a/src/core/tensor/tensor.cc b/src/core/tensor/tensor.cc index 5355a51e8d..7f4bbec657 100644 --- a/src/core/tensor/tensor.cc +++ b/src/core/tensor/tensor.cc @@ -16,7 +16,6 @@ * limitations under the License. */ #include "singa/core/tensor.h" -// #include "singa/utils/stacktrace.h" #include #include diff --git a/test/gtest/gtest_main.cc b/test/gtest/gtest_main.cc index f302822552..22477f32b8 100644 --- a/test/gtest/gtest_main.cc +++ b/test/gtest/gtest_main.cc @@ -30,9 +30,11 @@ #include #include "gtest/gtest.h" +#include "singa/utils/logging.h" GTEST_API_ int main(int argc, char **argv) { printf("Running main() from gtest_main.cc\n"); + singa::InitLogging(""); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/test/singa/test_logging.cc b/test/singa/test_logging.cc index 16efa8fa0e..71b6d96670 100644 --- a/test/singa/test_logging.cc +++ b/test/singa/test_logging.cc @@ -23,7 +23,6 @@ #include "singa/utils/logging.h" TEST(Logging, InfoLogging) { - singa::InitLogging(""); int a = 3; CHECK_EQ(a, 3); LOG(INFO) << "test info logging";