diff --git a/mindspore/core/CMakeLists.txt b/mindspore/core/CMakeLists.txt index 20c814c85d9..da781bfe075 100644 --- a/mindspore/core/CMakeLists.txt +++ b/mindspore/core/CMakeLists.txt @@ -3,7 +3,6 @@ include_directories(${CMAKE_BINARY_DIR}) include_directories(${CMAKE_SOURCE_DIR}/mindspore/core) include_directories(${CMAKE_SOURCE_DIR}/mindspore/ccsrc) include_directories(${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset) -add_subdirectory(gvar) if("${ENABLE_HIDDEN}" STREQUAL "OFF" AND NOT MSVC) string(REPLACE " -Werror " " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") @@ -48,8 +47,7 @@ endif() set_property(SOURCE ${CORE_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_CORE) add_library(core_obj OBJECT ${CORE_SRC_LIST}) add_library(core_proto_obj OBJECT ${PROTO_SRCS}) -add_library(mindspore_core SHARED $ $ - $) +add_library(mindspore_core SHARED $ $) target_link_libraries(mindspore_core PRIVATE mindspore::protobuf securec) if(CMAKE_SYSTEM_NAME MATCHES "Linux") diff --git a/mindspore/core/gvar/CMakeLists.txt b/mindspore/core/gvar/CMakeLists.txt deleted file mode 100644 index 677f74d0aa2..00000000000 --- a/mindspore/core/gvar/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -file(GLOB_RECURSE MS_GVAR_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cc) -set_property(SOURCE ${MS_GVAR_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_COMMON) -add_library(mindspore_gvar OBJECT ${MS_GVAR_SRC_LIST}) -target_compile_definitions(mindspore_gvar PRIVATE BUILDING_DLL) diff --git a/mindspore/core/gvar/log_adapter_common.cc b/mindspore/core/gvar/log_adapter_common.cc deleted file mode 100644 index 6f6402ea8e7..00000000000 --- a/mindspore/core/gvar/log_adapter_common.cc +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Copyright 2021 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. - */ -#ifndef _MSC_VER -#include -#endif -#include -#include "utils/log_adapter.h" - -namespace mindspore { -const std::string GetSubModuleName(SubModuleId module_id) { - static const std::vector sub_module_names = { - "UNKNOWN", // SM_UNKNOWN - "CORE", // SM_CORE - "ANALYZER", // SM_ANALYZER - "COMMON", // SM_COMMON - "DEBUG", // SM_DEBUG - "OFFLINE_DEBUG", // SM_OFFLINE_DEBUG - "DEVICE", // SM_DEVICE - "GE_ADPT", // SM_GE_ADPT - "IR", // SM_IR - "KERNEL", // SM_KERNEL - "MD", // SM_MD - "ME", // SM_ME - "EXPRESS", // SM_EXPRESS - "OPTIMIZER", // SM_OPTIMIZER - "PARALLEL", // SM_PARALLEL - "PARSER", // SM_PARSER - "PIPELINE", // SM_PIPELINE - "PRE_ACT", // SM_PRE_ACT - "PYNATIVE", // SM_PYNATIVE - "SESSION", // SM_SESSION - "UTILS", // SM_UTILS - "VM", // SM_VM - "PROFILER", // SM_PROFILER - "PS", // SM_PS - "FL", // SM_FL - "DISTRIBUTED", // SM_DISTRIBUTED - "LITE", // SM_LITE - "ARMOUR", // SM_ARMOUR - "HCCL_ADPT", // SM_HCCL_ADPT - "RUNTIME_FRAMEWORK", // SM_RUNTIME_FRAMEWORK - "GE", // SM_GE - "API", // SM_API - }; - return sub_module_names[(module_id % NUM_SUBMODUES)]; -} - -// export GetTimeString for all sub modules -std::string GetTimeString() { - constexpr auto BUFLEN = 80; - char buf[BUFLEN]; - (void)memset(buf, '\0', BUFLEN); -#if defined(_WIN32) || defined(_WIN64) - time_t time_seconds = time(0); - struct tm now_time; - localtime_s(&now_time, &time_seconds); - (void)snprintf(buf, BUFLEN, "%d-%d-%d %d:%d:%d", now_time.tm_year + 1900, now_time.tm_mon + 1, now_time.tm_mday, - now_time.tm_hour, now_time.tm_min, now_time.tm_sec); -#else - struct timeval cur_time; - (void)gettimeofday(&cur_time, nullptr); - - struct tm now; - constexpr size_t time_str_len = 19; - constexpr int64_t time_convert_unit = 1000; - (void)localtime_r(&cur_time.tv_sec, &now); - (void)strftime(buf, BUFLEN, "%Y-%m-%d-%H:%M:%S", &now); // format date and time -#ifdef __APPLE__ - const std::string fmt_str = ".%03lld.%03lld"; -#else - const std::string fmt_str = ".%03ld.%03ld"; -#endif - (void)snprintf(buf + time_str_len, BUFLEN - time_str_len, fmt_str.c_str(), cur_time.tv_usec / time_convert_unit, - cur_time.tv_usec % time_convert_unit); -#endif - return std::string(buf); -} -} // namespace mindspore diff --git a/mindspore/core/gvar/logging_level.cc b/mindspore/core/gvar/logging_level.cc deleted file mode 100644 index 2cec7035859..00000000000 --- a/mindspore/core/gvar/logging_level.cc +++ /dev/null @@ -1,28 +0,0 @@ -/** - * 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 { -std::map acl_handle_map; -// set default log level to WARNING for all sub modules -int g_ms_submodule_log_levels[NUM_SUBMODUES] = {WARNING}; -#if defined(_WIN32) || defined(_WIN64) -enum MsLogLevel this_thread_max_log_level = EXCEPTION; -#else -thread_local enum MsLogLevel this_thread_max_log_level = EXCEPTION; -#endif -} // namespace mindspore diff --git a/mindspore/core/gvar/typeid_manager.cc b/mindspore/core/gvar/typeid_manager.cc deleted file mode 100644 index 28176f55b83..00000000000 --- a/mindspore/core/gvar/typeid_manager.cc +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright 2019-2021 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 "base/base.h" -// This file is kept to make cmake happy. diff --git a/mindspore/core/utils/log_adapter.cc b/mindspore/core/utils/log_adapter.cc index fd5046e3276..25366c8446a 100644 --- a/mindspore/core/utils/log_adapter.cc +++ b/mindspore/core/utils/log_adapter.cc @@ -26,6 +26,15 @@ // namespace to support utils module definition namespace mindspore { +std::map acl_handle_map; +// set default log level to WARNING for all sub modules +int g_ms_submodule_log_levels[NUM_SUBMODUES] = {WARNING}; +#if defined(_WIN32) || defined(_WIN64) +enum MsLogLevel this_thread_max_log_level = EXCEPTION; +#else +thread_local enum MsLogLevel this_thread_max_log_level = EXCEPTION; +#endif + #ifdef USE_GLOG #define google mindspore_private static std::string GetProcName() { @@ -427,6 +436,75 @@ void InitSubModulesLogLevel() { g_ms_submodule_log_levels[mod_idx] = static_cast(submodule_log_level); } } + +const std::string GetSubModuleName(SubModuleId module_id) { + static const std::vector sub_module_names = { + "UNKNOWN", // SM_UNKNOWN + "CORE", // SM_CORE + "ANALYZER", // SM_ANALYZER + "COMMON", // SM_COMMON + "DEBUG", // SM_DEBUG + "OFFLINE_DEBUG", // SM_OFFLINE_DEBUG + "DEVICE", // SM_DEVICE + "GE_ADPT", // SM_GE_ADPT + "IR", // SM_IR + "KERNEL", // SM_KERNEL + "MD", // SM_MD + "ME", // SM_ME + "EXPRESS", // SM_EXPRESS + "OPTIMIZER", // SM_OPTIMIZER + "PARALLEL", // SM_PARALLEL + "PARSER", // SM_PARSER + "PIPELINE", // SM_PIPELINE + "PRE_ACT", // SM_PRE_ACT + "PYNATIVE", // SM_PYNATIVE + "SESSION", // SM_SESSION + "UTILS", // SM_UTILS + "VM", // SM_VM + "PROFILER", // SM_PROFILER + "PS", // SM_PS + "FL", // SM_FL + "DISTRIBUTED", // SM_DISTRIBUTED + "LITE", // SM_LITE + "ARMOUR", // SM_ARMOUR + "HCCL_ADPT", // SM_HCCL_ADPT + "RUNTIME_FRAMEWORK", // SM_RUNTIME_FRAMEWORK + "GE", // SM_GE + "API", // SM_API + }; + return sub_module_names[(module_id % NUM_SUBMODUES)]; +} + +std::string GetTimeString() { + constexpr auto BUFLEN = 80; + char buf[BUFLEN]; + (void)memset(buf, '\0', BUFLEN); +#if defined(_WIN32) || defined(_WIN64) + time_t time_seconds = time(0); + struct tm now_time; + localtime_s(&now_time, &time_seconds); + constexpr int base_year = 1900; + (void)snprintf(buf, BUFLEN, "%d-%d-%d %d:%d:%d", now_time.tm_year + base_year, now_time.tm_mon + 1, now_time.tm_mday, + now_time.tm_hour, now_time.tm_min, now_time.tm_sec); +#else + struct timeval cur_time; + (void)gettimeofday(&cur_time, nullptr); + + struct tm now; + constexpr size_t time_str_len = 19; + constexpr int64_t time_convert_unit = 1000; + (void)localtime_r(&cur_time.tv_sec, &now); + (void)strftime(buf, BUFLEN, "%Y-%m-%d-%H:%M:%S", &now); // format date and time +#ifdef __APPLE__ + constexpr auto fmt_str = ".%03lld.%03lld"; +#else + constexpr auto fmt_str = ".%03ld.%03ld"; +#endif + (void)snprintf(buf + time_str_len, BUFLEN - time_str_len, fmt_str, cur_time.tv_usec / time_convert_unit, + cur_time.tv_usec % time_convert_unit); +#endif + return std::string(buf); +} } // namespace mindspore extern "C" { diff --git a/mindspore/lite/src/CMakeLists.txt b/mindspore/lite/src/CMakeLists.txt index 5c74312fc56..1cd7390f081 100644 --- a/mindspore/lite/src/CMakeLists.txt +++ b/mindspore/lite/src/CMakeLists.txt @@ -161,9 +161,7 @@ if(MSLITE_ENABLE_RUNTIME_GLOG) string(REPLACE "-fno-rtti" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) if(NOT MSLITE_ENABLE_RUNTIME_CONVERT) set(LITE_SRC ${LITE_SRC} - ${CORE_DIR}/utils/log_adapter.cc - ${CORE_DIR}/gvar/logging_level.cc - ${CORE_DIR}/gvar/log_adapter_common.cc) + ${CORE_DIR}/utils/log_adapter.cc) endif() endif() diff --git a/mindspore/lite/tools/converter/registry/CMakeLists.txt b/mindspore/lite/tools/converter/registry/CMakeLists.txt index 9fa0ee46e08..7aa3e403516 100644 --- a/mindspore/lite/tools/converter/registry/CMakeLists.txt +++ b/mindspore/lite/tools/converter/registry/CMakeLists.txt @@ -15,9 +15,7 @@ set(REG_SRC ${CONVERT_REG_SRC} ${KERNEL_REG_DIR}/../common/utils.cc ${KERNEL_REG_DIR}/../delegate/tensorrt/distribution/distribution_base.cc ${CORE_DIR}/utils/log_adapter.cc - ${CORE_DIR}/utils/status.cc - ${CORE_DIR}/gvar/log_adapter_common.cc - ${CORE_DIR}/gvar/logging_level.cc) + ${CORE_DIR}/utils/status.cc) set_property(SOURCE ${REG_SRC} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_LITE) add_library(mslite_converter_plugin SHARED ${REG_SRC}) target_link_libraries(mslite_converter_plugin mindspore::glog) diff --git a/tests/ut/cpp/CMakeLists.txt b/tests/ut/cpp/CMakeLists.txt index a327c8d4aba..d90e6a8de87 100644 --- a/tests/ut/cpp/CMakeLists.txt +++ b/tests/ut/cpp/CMakeLists.txt @@ -232,7 +232,7 @@ add_dependencies(_ut_mindspore_obj graph) add_dependencies(_ut_ut_obj engine-cache-server graph) set(ut_objects $ $ $ $ $ - $ $) + $) if(ENABLE_MINDDATA) set(ut_objects ${ut_objects} ${dataengine_submodules} $) endif()