diff --git a/mindspore/ccsrc/dataset/CMakeLists.txt b/mindspore/ccsrc/dataset/CMakeLists.txt index c60ff64604796547ccc68cf795abd2ee2a9cc072..0895c8c33b7d397548ac3a8e74a99c40359ea2b0 100644 --- a/mindspore/ccsrc/dataset/CMakeLists.txt +++ b/mindspore/ccsrc/dataset/CMakeLists.txt @@ -82,11 +82,10 @@ set_target_properties(_c_dataengine PROPERTIES ###################################################################### ################# Link with external libraries ######################## +target_link_libraries(_c_dataengine PRIVATE mindspore mindspore_gvar) if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") - target_link_libraries(_c_dataengine PRIVATE mindspore) target_link_libraries(_c_dataengine PRIVATE mindspore::pybind11_module ${PYTHON_LIBRARIES} mindspore::protobuf ${SECUREC_LIBRARY}) else() - target_link_libraries(_c_dataengine PRIVATE mindspore mindspore_gvar) target_link_libraries(_c_dataengine PRIVATE mindspore::pybind11_module -ldl mindspore::protobuf ${SECUREC_LIBRARY}) endif() target_link_libraries(_c_dataengine PUBLIC mindspore::jpeg_turbo mindspore::opencv_core mindspore::opencv_imgcodecs diff --git a/mindspore/ccsrc/device/CMakeLists.txt b/mindspore/ccsrc/device/CMakeLists.txt index b56d6acc89efdbdbefb75dede04652e08b2fa3f4..fba0b20711fec2ccc6a27d2481dbbcde75199323 100644 --- a/mindspore/ccsrc/device/CMakeLists.txt +++ b/mindspore/ccsrc/device/CMakeLists.txt @@ -47,5 +47,6 @@ if (ENABLE_GPU) # add_library(_mindspore_device_cuda_obj OBJECT ${CUDA_SRC_LIST}) endif () -set_property(SOURCE ${DEVICE_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_DEVICE) +set_property(SOURCE ${DEVICE_SRC_LIST} ${D_SRC_LIST} ${CPU_SRC_LIST} + PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_DEVICE) add_library(_mindspore_device_obj OBJECT ${DEVICE_SRC_LIST} ${D_SRC_LIST} ${CPU_SRC_LIST}) diff --git a/mindspore/ccsrc/gvar/logging_level.cc b/mindspore/ccsrc/gvar/logging_level.cc new file mode 100644 index 0000000000000000000000000000000000000000..158c5c8ce0a0a7479ef9d651d6ad02a9261556fa --- /dev/null +++ b/mindspore/ccsrc/gvar/logging_level.cc @@ -0,0 +1,24 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "utils/log_adapter.h" + +namespace mindspore { + +// set default log level to WARNING for all sub modules +int g_ms_submodule_log_levels[NUM_SUBMODUES] = {WARNING}; + +} // namespace mindspore diff --git a/mindspore/ccsrc/kernel/CMakeLists.txt b/mindspore/ccsrc/kernel/CMakeLists.txt index 1d49f13fd93150b3adc24f001ebc79cc9c547ae7..112a258905ad5240921723047c55534f86b67603 100644 --- a/mindspore/ccsrc/kernel/CMakeLists.txt +++ b/mindspore/ccsrc/kernel/CMakeLists.txt @@ -43,5 +43,6 @@ if (ENABLE_GPU) # add_library(_mindspore_kernel_cuda_obj OBJECT ${CUDA_SRC_LIST}) endif() -set_property(SOURCE ${KERNEL_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_KERNEL) +set_property(SOURCE ${KERNEL_SRC_LIST} ${CPU_SRC_LIST} ${GPU_SRC_LIST} ${D_SRC_LIST} + PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_KERNEL) add_library(_mindspore_kernel_obj OBJECT ${KERNEL_SRC_LIST} ${CPU_SRC_LIST} ${GPU_SRC_LIST} ${D_SRC_LIST}) diff --git a/mindspore/ccsrc/mindrecord/CMakeLists.txt b/mindspore/ccsrc/mindrecord/CMakeLists.txt index b49ad7179c73d88187b1d4c22e902b1d8852988b..4b2a30c9f1f95c62d331cda6697569d3006c858f 100644 --- a/mindspore/ccsrc/mindrecord/CMakeLists.txt +++ b/mindspore/ccsrc/mindrecord/CMakeLists.txt @@ -28,7 +28,7 @@ set_target_properties(_c_mindrecord PROPERTIES # add link library if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") - target_link_libraries(_c_mindrecord PRIVATE mindspore::sqlite mindspore mindspore::protobuf) + target_link_libraries(_c_mindrecord PRIVATE mindspore::sqlite mindspore mindspore_gvar mindspore::protobuf) else() target_link_libraries(_c_mindrecord PRIVATE mindspore::sqlite ${PYTHON_LIB} ${SECUREC_LIBRARY} mindspore mindspore_gvar mindspore::protobuf) endif() diff --git a/mindspore/ccsrc/utils/log_adapter.cc b/mindspore/ccsrc/utils/log_adapter.cc index ffbb95216a17fbc29b9a29e7183c364ed254208a..cd248acdabbcfc1bf0a374321e29bae6d9fb4988 100644 --- a/mindspore/ccsrc/utils/log_adapter.cc +++ b/mindspore/ccsrc/utils/log_adapter.cc @@ -241,28 +241,6 @@ static std::string GetEnv(const std::string &envvar) { return std::string(value); } -#ifndef USE_GLOG -// set default log warning to WARNING -int g_mslog_level = WARNING; - -static void InitMsLogLevel() { - int log_level = WARNING; // set default log level to WARNING - auto str_level = GetEnv("GLOG_v"); - if (str_level.size() == 1) { - int ch = str_level.c_str()[0]; - ch = ch - '0'; // substract ASCII code of '0', which is 48 - if (ch >= DEBUG && ch <= ERROR) { - log_level = ch; - } - } - g_mslog_level = log_level; -} - -#endif - -// set default log level to WARNING for all sub modules -int g_ms_submodule_log_levels[NUM_SUBMODUES] = {WARNING}; - enum LogConfigToken { INVALID, // indicate invalid token LEFT_BRACE, // '{' @@ -449,7 +427,16 @@ static MsLogLevel GetGlobalLogLevel() { #ifdef USE_GLOG return static_cast(FLAGS_v); #else - return static_cast(g_mslog_level); + int log_level = WARNING; // set default log level to WARNING + auto str_level = GetEnv("GLOG_v"); + if (str_level.size() == 1) { + int ch = str_level.c_str()[0]; + ch = ch - '0'; // substract ASCII code of '0', which is 48 + if (ch >= DEBUG && ch <= ERROR) { + log_level = ch; + } + } + return static_cast(log_level); #endif } @@ -521,10 +508,7 @@ void mindspore_log_init(void) { FLAGS_logtostderr = true; MS_LOG(WARNING) << "`GLOG_log_dir` is not set, output log to screen."; } - - mindspore::InitSubModulesLogLevel(); -#else - mindspore::InitMsLogLevel(); #endif + mindspore::InitSubModulesLogLevel(); } } diff --git a/mindspore/ccsrc/utils/log_adapter.h b/mindspore/ccsrc/utils/log_adapter.h index a572cfa210a8ca461d36ddcec5315929add112a2..dfd463ee1d74ee3d5385a9b5717e37a2c5d369a9 100644 --- a/mindspore/ccsrc/utils/log_adapter.h +++ b/mindspore/ccsrc/utils/log_adapter.h @@ -125,10 +125,11 @@ enum SubModuleId : int { #define SUBMODULE_ID mindspore::SubModuleId::SM_ME #endif -#ifndef USE_GLOG -extern int g_mslog_level; -#endif +#if defined(_WIN32) || defined(_WIN64) +extern int g_ms_submodule_log_levels[] __attribute__((dllexport)); +#else extern int g_ms_submodule_log_levels[] __attribute__((visibility("default"))); +#endif class LogWriter { public: