From 71edc49814448de0a3c3617b6664c0801abf3cdd Mon Sep 17 00:00:00 2001 From: tqchen Date: Fri, 25 Sep 2015 21:00:07 -0700 Subject: [PATCH 1/2] [ENGINE] Change obj pool to normal struct instead of union, to support more compiler --- include/mxnet/base.h | 3 ++- src/common/object_pool.h | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/mxnet/base.h b/include/mxnet/base.h index b5670070ae1a..1ef9c6bf8450 100644 --- a/include/mxnet/base.h +++ b/include/mxnet/base.h @@ -42,7 +42,8 @@ * Used to support g++-4.6 and g++4.7 */ #if DMLC_USE_CXX11 && defined(__GNUC__) && !defined(__clang_version__) -#if __GNUC__ == 4 && __GNUC_MINOR__ == 6 +#if __GNUC__ == 4 && __GNUC_MINOR__ < 8 +#error "Currently we need g++ 4.8 or higher to fully support c++11 features" #define override #define final #endif diff --git a/src/common/object_pool.h b/src/common/object_pool.h index 43d309e24bf5..0306ed6ef355 100644 --- a/src/common/object_pool.h +++ b/src/common/object_pool.h @@ -46,10 +46,15 @@ class ObjectPool { * \brief Internal structure to hold pointers. */ struct LinkedList { +#if defined(_MSC_VER) + T t; + LinkedList* next{nullptr}; +#else union { - LinkedList* next{nullptr}; T t; + LinkedList* next{nullptr}; }; +#endif }; /*! * \brief Page size of allocation. From a801b3e36a3b2110df4252e5e67d27c13dddf560 Mon Sep 17 00:00:00 2001 From: tqchen Date: Fri, 25 Sep 2015 23:16:13 -0700 Subject: [PATCH 2/2] Some update --- scripts/travis_script.sh | 1 + src/engine/threaded_engine.cc | 6 ++++++ src/engine/threaded_engine.h | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/travis_script.sh b/scripts/travis_script.sh index 68f5a9211628..dd2a62c8b37b 100755 --- a/scripts/travis_script.sh +++ b/scripts/travis_script.sh @@ -81,6 +81,7 @@ if [ ${TASK} == "cpp_unittest" ]; then echo "GTEST_PATH="${CACHE_PREFIX} >> config.mk make test || exit -1 export MXNET_ENGINE_TYPE=ThreadedEngine + export MXNET_ENGINE_INFO=true for test in tests/cpp/*_test; do ./$test || exit -1 done diff --git a/src/engine/threaded_engine.cc b/src/engine/threaded_engine.cc index ea122a67becf..1f71e9154761 100644 --- a/src/engine/threaded_engine.cc +++ b/src/engine/threaded_engine.cc @@ -302,11 +302,17 @@ void ThreadedEngine::WaitForVar(VarHandle var) { if (threaded_var->ready_to_read()) return; std::atomic done{false}; this->PushSync([this, &done](RunContext) { + if (engine_info_) { + LOG(INFO) << "Sync is executed"; + } { std::unique_lock lock{finished_m_}; done.store(true); } finished_cv_.notify_all(); + if (engine_info_) { + LOG(INFO) << "Sync is notified"; + } }, Context::CPU(), {var}, {}, FnProperty::kNormal); { std::unique_lock lock{finished_m_}; diff --git a/src/engine/threaded_engine.h b/src/engine/threaded_engine.h index 13c55c6d5747..7a8708484f9c 100644 --- a/src/engine/threaded_engine.h +++ b/src/engine/threaded_engine.h @@ -249,7 +249,9 @@ class ThreadedEngine : public Engine { shutdown_phase_.store(true); } - ThreadedEngine() {} + ThreadedEngine() { + engine_info_ = dmlc::GetEnv("MXNET_ENGINE_INFO", false); + } ~ThreadedEngine() { { std::unique_lock lock{finished_m_}; @@ -319,6 +321,8 @@ class ThreadedEngine : public Engine { std::atomic kill_{false}; /*! \brief whether it is during shutdown phase*/ std::atomic shutdown_phase_{false}; + /*!\brief show more information from engine actions */ + bool engine_info_{false}; /*! * \brief Mutex and condition_variable, * used to Notify waits for single or all variables.