Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated spdlog version v1.15.0 #2329

Merged
merged 3 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/dnnl_compat.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ set(COMPAT_CACHE_BOOL_VARS
"EXPERIMENTAL"
"EXPERIMENTAL_SPARSE"
"EXPERIMENTAL_UKERNEL"
"EXPERIMENTAL_LOGGING"
"VERBOSE"
"ENABLE_CONCURRENT_EXEC"
"ENABLE_PRIMITIVE_CACHE"
Expand Down
2 changes: 2 additions & 0 deletions cmake/platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ if(MSVC)
append(CMAKE_CCXX_FLAGS "/bigobj")
# make preprocessor standard compliant
append(CMAKE_CCXX_FLAGS "/Zc:preprocessor")
# Set UTF-8 as default encoding to be consistent with other compilers
append(CMAKE_CCXX_FLAGS "/utf-8")
# int64_t -> int (tent)
append(CMAKE_CCXX_NOWARN_FLAGS "/wd4244")
# workaround: macro outputs defined token in msvs header
Expand Down
4 changes: 3 additions & 1 deletion src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ if(NOT DNNL_CPU_RUNTIME STREQUAL "THREADPOOL")
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/stream_threadpool.cpp")
endif()

if(NOT DNNL_EXPERIMENTAL_LOGGING)
if(DNNL_EXPERIMENTAL_LOGGING)
include_directories(${CMAKE_CURRENT_LIST_DIR})
vpirogov marked this conversation as resolved.
Show resolved Hide resolved
else()
# avoid building and linking spdlog if logging support is not enabled
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/spdlog/*")
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/logging.cpp")
Expand Down
3 changes: 3 additions & 0 deletions src/common/spdlog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This code is from [spdlog](https://github.com/gabime/spdlog).

tag: 1.15.0
18 changes: 18 additions & 0 deletions src/common/spdlog/_clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#===============================================================================
# Copyright 2019-2020 Intel Corporation
#
# 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.
#===============================================================================

DisableFormat : true
SortIncludes: false
46 changes: 20 additions & 26 deletions src/common/spdlog/common-inl.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#pragma once

#ifndef SPDLOG_HEADER_ONLY
#include <common/spdlog/common.h>
#include <spdlog/common.h>
#endif

#include <algorithm>
Expand All @@ -16,59 +16,53 @@ namespace level {
#if __cplusplus >= 201703L
constexpr
#endif
static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES;
static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES;

static const char *short_level_names[] SPDLOG_SHORT_LEVEL_NAMES;

SPDLOG_INLINE const string_view_t &to_string_view(
spdlog::level::level_enum l) SPDLOG_NOEXCEPT {
SPDLOG_INLINE const string_view_t &to_string_view(spdlog::level::level_enum l) SPDLOG_NOEXCEPT {
return level_string_views[l];
}

SPDLOG_INLINE const char *to_short_c_str(
spdlog::level::level_enum l) SPDLOG_NOEXCEPT {
SPDLOG_INLINE const char *to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOEXCEPT {
return short_level_names[l];
}

SPDLOG_INLINE spdlog::level::level_enum from_str(
const std::string &name) SPDLOG_NOEXCEPT {
auto it = std::find(
std::begin(level_string_views), std::end(level_string_views), name);
SPDLOG_INLINE spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT {
auto it = std::find(std::begin(level_string_views), std::end(level_string_views), name);
if (it != std::end(level_string_views))
return static_cast<level::level_enum>(
std::distance(std::begin(level_string_views), it));
return static_cast<level::level_enum>(std::distance(std::begin(level_string_views), it));

// check also for "warn" and "err" before giving up..
if (name == "warn") { return level::warn; }
if (name == "err") { return level::err; }
if (name == "warn") {
return level::warn;
}
if (name == "err") {
return level::err;
}
return level::off;
}
} // namespace level
} // namespace level

SPDLOG_INLINE spdlog_ex::spdlog_ex(std::string msg) : msg_(std::move(msg)) {}
SPDLOG_INLINE spdlog_ex::spdlog_ex(std::string msg)
: msg_(std::move(msg)) {}

SPDLOG_INLINE spdlog_ex::spdlog_ex(const std::string &msg, int last_errno) {
#ifdef SPDLOG_USE_STD_FORMAT
msg_ = std::system_error(
std::error_code(last_errno, std::generic_category()), msg)
.what();
msg_ = std::system_error(std::error_code(last_errno, std::generic_category()), msg).what();
#else
memory_buf_t outbuf;
fmt::format_system_error(outbuf, last_errno, msg.c_str());
msg_ = fmt::to_string(outbuf);
#endif
}

SPDLOG_INLINE const char *spdlog_ex::what() const SPDLOG_NOEXCEPT {
return msg_.c_str();
}
SPDLOG_INLINE const char *spdlog_ex::what() const SPDLOG_NOEXCEPT { return msg_.c_str(); }

SPDLOG_INLINE void throw_spdlog_ex(const std::string &msg, int last_errno) {
SPDLOG_THROW(spdlog_ex(msg, last_errno));
}

SPDLOG_INLINE void throw_spdlog_ex(std::string msg) {
SPDLOG_THROW(spdlog_ex(std::move(msg)));
}
SPDLOG_INLINE void throw_spdlog_ex(std::string msg) { SPDLOG_THROW(spdlog_ex(std::move(msg))); }

} // namespace spdlog
} // namespace spdlog
Loading
Loading