Skip to content
Open
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
2 changes: 1 addition & 1 deletion bin/pytorch_inference/CCommandParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool CCommandParser::ioLoop(const TRequestHandlerFunc& requestHandler,

json::value doc;
json::stream_parser p;
json::error_code ec;
boost::system::error_code ec;
std::string line;
std::size_t n = 0;
while (true) {
Expand Down
2 changes: 1 addition & 1 deletion bin/pytorch_inference/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ int main(int argc, char** argv) {
// allocations rather than per allocation. But macOS is not supported for
// production, but just as a convenience for developers. So the most
// important thing is that the threading works as intended on Linux.
at::set_num_threads(threadSettings.numThreadsPerAllocation());
at::set_num_threads(static_cast<int>(threadSettings.numThreadsPerAllocation()));

// This is not used as we don't call at::launch anywhere.
// Setting it to 1 to ensure there is no thread pool sitting around.
Expand Down
3 changes: 3 additions & 0 deletions cmake/compiler/clang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ list(APPEND ML_C_FLAGS
"-Wno-padded"
"-Wno-poison-system-directories"
"-Wno-sign-conversion"
"-Wno-missing-noreturn"
"-Wno-nrvo"
"-Wno-switch-default"
"-Wno-unknown-warning-option"
"-Wno-unreachable-code"
"-Wno-used-but-marked-unused"
Expand Down
16 changes: 16 additions & 0 deletions cmake/compiler/msvc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ list(APPEND ML_COMPILE_DEFINITIONS
_WIN32_WINNT=0x0601
Windows)

# Treat SYSTEM include directories as external — suppress warnings from
# third-party headers (Boost, Eigen, PyTorch, etc.). Requires MSVC 17.0+.
set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "/external:I ")
list(APPEND ML_C_FLAGS
"/X"
"/nologo"
"/W4"
"/external:W0"
"/EHsc"
"/Gw"
"/Zc:inline"
Expand All @@ -47,7 +51,19 @@ list(APPEND ML_CXX_FLAGS
"/we4150"
"/wd4201"
"/wd4231"
# C4250 ("inherits via dominance") is a purely informational MSVC-only
# diagnostic. The instrumentation classes use a deliberate virtual-inheritance
# mixin (CDataFrameAnalysisInstrumentation supplies the shared implementation
# while the per-analysis interfaces add their own pure virtuals); the C++
# dominance rule resolves the shared methods correctly. GCC/Clang do not warn.
"/wd4250"
"/wd4251"
# C4324 ("structure was padded due to alignment specifier") is emitted for
# types that deliberately over-align members with alignas to avoid false
# sharing (e.g. the std::atomic counters in CCompressedLfuCache). The padding
# is the intended consequence of the alignment, so the diagnostic is pure
# noise here. GCC/Clang do not warn.
"/wd4324"
"/wd4355"
"/wd4512"
"/wd4702"
Expand Down
13 changes: 13 additions & 0 deletions cmake/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,19 @@ function(ml_add_test_executable _target)

set_property(TARGET ml_test_${_target} PROPERTY POSITION_INDEPENDENT_CODE TRUE)

# Suppress benign warnings on test targets only (production code keeps them):
# 1. -Wsubobject-linkage (GCC): Boost.Test's fixture macros generate test
# classes with external linkage that derive from fixtures defined in
# anonymous namespaces (internal linkage). The anonymous namespace is
# deliberate - it keeps each file's fixtures ODR-distinct within the
# monolithic per-library test binary - so this idiomatic pattern is benign.
# 2. -Wunused-macros (Clang): Boost.Test's BOOST_TEST_MODULE /
# BOOST_TEST_NO_MAIN macros are consumed by the subsequent
# #include <boost/test/unit_test.hpp> but Clang flags them as unused.
target_compile_options(ml_test_${_target} PRIVATE
$<$<CXX_COMPILER_ID:GNU>:-Wno-subobject-linkage>
$<$<CXX_COMPILER_ID:AppleClang,Clang>:-Wno-unused-macros>)

if(ML_PCH)
target_precompile_headers(ml_test_${_target} PRIVATE
<string>
Expand Down
6 changes: 3 additions & 3 deletions include/api/CSerializableToJson.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class API_EXPORT CSerializableFromCompressedChunkedJson {
TIStreamPtr inputStream,
std::iostream& buffer);

static void assertNoParseError(const json::error_code& ec) {
static void assertNoParseError(const boost::system::error_code& ec) {
if (ec) {
throw std::runtime_error{"Error parsing JSON: " + ec.message()};
}
Expand Down Expand Up @@ -178,7 +178,7 @@ class API_EXPORT CSerializableFromCompressedChunkedJson {
}

static std::int64_t getAsInt64From(const json::value& value) {
json::error_code ec;
boost::system::error_code ec;
std::int64_t ret = value.to_number<std::int64_t>(ec);
if (ec) {
throw std::runtime_error{"is not a int64"};
Expand All @@ -187,7 +187,7 @@ class API_EXPORT CSerializableFromCompressedChunkedJson {
}

static std::uint64_t getAsUint64From(const json::value& value) {
json::error_code ec;
boost::system::error_code ec;
std::uint64_t ret = value.to_number<std::uint64_t>(ec);
if (ec) {
throw std::runtime_error{"is not a uint64"};
Expand Down
10 changes: 5 additions & 5 deletions include/core/CBoostJsonParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CORE_EXPORT CBoostJsonParser {
static bool parse(const std::string& jsonString, json::value& doc) {
unsigned char buffer[JSON_PARSE_BUFFER_SIZE]; // Small stack buffer to avoid most allocations during parse
json::monotonic_resource mr(buffer); // This resource will use our local buffer first
json::error_code ec;
boost::system::error_code ec;
doc = json::parse(jsonString, ec, &mr);
if (ec) {
LOG_ERROR(<< "An error occurred while parsing JSON: \""
Expand All @@ -50,14 +50,14 @@ class CORE_EXPORT CBoostJsonParser {
return true;
}

static json::error_code parse(std::istream& istream, json::value& doc) {
static boost::system::error_code parse(std::istream& istream, json::value& doc) {
json::stream_parser p;

unsigned char buf[JSON_PARSE_BUFFER_SIZE]; // Now we need a buffer to hold the actual JSON values
json::monotonic_resource mr(buf); // The static resource is monotonic, using only a caller-provided buffer
p.reset(&mr); // Use the static resource for producing the value

json::error_code ec;
boost::system::error_code ec;
std::string line;
while (std::getline(istream, line)) {
LOG_TRACE(<< "write_some: " << line);
Expand All @@ -70,14 +70,14 @@ class CORE_EXPORT CBoostJsonParser {
return ec;
}

static json::error_code parse(char* begin, std::size_t length, json::value& doc) {
static boost::system::error_code parse(char* begin, std::size_t length, json::value& doc) {
json::stream_parser p;

unsigned char buf[JSON_PARSE_BUFFER_SIZE]; // Now we need a buffer to hold the actual JSON values
json::monotonic_resource mr(buf); // The static resource is monotonic, using only a caller-provided buffer
p.reset(&mr); // Use the static resource for producing the value

json::error_code ec;
boost::system::error_code ec;
std::size_t written{0};
p.reset();
while (written < length) {
Expand Down
2 changes: 1 addition & 1 deletion include/core/CConcurrentWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CConcurrentWrapper final : private CNonCopyable {
//! The code inside of this lambda is guaranteed to be executed in an atomic fashion.
template<typename F>
void operator()(F f) const {
m_Queue.push([=] { f(m_Resource); });
m_Queue.push([this, f] { f(m_Resource); });
}

//! Debug the memory used by this component.
Expand Down
38 changes: 20 additions & 18 deletions include/core/CJsonStateRestoreTraverser.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,44 +130,46 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser {
//! @return `true` on success.
//! @param ec Set to the error, if any occurred.
//!
bool on_document_begin(json::error_code& ec);
bool on_document_begin(boost::system::error_code& ec);

//! Called when the JSON parsing is done.
//!
//! @return `true` on success.
//! @param ec Set to the error, if any occurred.
//!
bool on_document_end(json::error_code& ec) { return ec ? false : true; }
bool on_document_end(boost::system::error_code& ec) {
return ec ? false : true;
}

//! Called when the beginning of an array is encountered.
//!
//! @return `true` on success.
//! @param ec Set to the error, if any occurred.
//!
bool on_array_begin(json::error_code& ec);
bool on_array_begin(boost::system::error_code& ec);

//! Called when the end of the current array is encountered.
//!
//! @return `true` on success.
//! @param n The number of elements in the array.
//! @param ec Set to the error, if any occurred.
//!
bool on_array_end(std::size_t n, json::error_code& ec);
bool on_array_end(std::size_t n, boost::system::error_code& ec);

//! Called when the beginning of an object is encountered.
//!
//! @return `true` on success.
//! @param ec Set to the error, if any occurred.
//!
bool on_object_begin(json::error_code& ec);
bool on_object_begin(boost::system::error_code& ec);

//! Called when the end of the current object is encountered.
//!
//! @return `true` on success.
//! @param n The number of elements in the object.
//! @param ec Set to the error, if any occurred.
//!
bool on_object_end(std::size_t n, json::error_code& ec);
bool on_object_end(std::size_t n, boost::system::error_code& ec);

//! Called with characters corresponding to part of the current string.
//!
Expand All @@ -176,7 +178,7 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser {
//! @param n The total size of the string thus far
//! @param ec Set to the error, if any occurred.
//!
bool on_string_part(std::string_view s, std::size_t n, json::error_code& ec);
bool on_string_part(std::string_view s, std::size_t n, boost::system::error_code& ec);

//! Called with the last characters corresponding to the current string.
//!
Expand All @@ -185,7 +187,7 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser {
//! @param n The total size of the string
//! @param ec Set to the error, if any occurred.
//!
bool on_string(std::string_view s, std::size_t n, json::error_code& ec);
bool on_string(std::string_view s, std::size_t n, boost::system::error_code& ec);

//! Called with characters corresponding to part of the current key.
//!
Expand All @@ -194,7 +196,7 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser {
//! @param n The total size of the key thus far
//! @param ec Set to the error, if any occurred.
//!
bool on_key_part(std::string_view s, std::size_t n, json::error_code& ec);
bool on_key_part(std::string_view s, std::size_t n, boost::system::error_code& ec);

//! Called with the last characters corresponding to the current key.
//!
Expand All @@ -203,15 +205,15 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser {
//! @param n The total size of the key
//! @param ec Set to the error, if any occurred.
//!
bool on_key(std::string_view s, std::size_t n, json::error_code& ec);
bool on_key(std::string_view s, std::size_t n, boost::system::error_code& ec);

//! Called with the characters corresponding to part of the current number.
//!
//! @return `true` on success.
//! @param s The partial characters
//! @param ec Set to the error, if any occurred.
//!
bool on_number_part(std::string_view s, json::error_code& ec);
bool on_number_part(std::string_view s, boost::system::error_code& ec);

//! Called when a signed integer is parsed.
//!
Expand All @@ -220,7 +222,7 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser {
//! @param s The remaining characters
//! @param ec Set to the error, if any occurred.
//!
bool on_int64(int64_t i, std::string_view s, json::error_code& ec);
bool on_int64(int64_t i, std::string_view s, boost::system::error_code& ec);

//! Called when an unsigend integer is parsed.
//!
Expand All @@ -229,7 +231,7 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser {
//! @param s The remaining characters
//! @param ec Set to the error, if any occurred.
//!
bool on_uint64(uint64_t u, std::string_view s, json::error_code& ec);
bool on_uint64(uint64_t u, std::string_view s, boost::system::error_code& ec);

//! Called when a double is parsed.
//!
Expand All @@ -238,38 +240,38 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser {
//! @param s The remaining characters
//! @param ec Set to the error, if any occurred.
//!
bool on_double(double d, std::string_view s, json::error_code& ec);
bool on_double(double d, std::string_view s, boost::system::error_code& ec);

//! Called when a boolean is parsed.
//!
//! @return `true` on success.
//! @param b The value
//! @param ec Set to the error, if any occurred.
//!
bool on_bool(bool b, json::error_code& ec);
bool on_bool(bool b, boost::system::error_code& ec);

//! Called when a null is parsed.
//!
//! @return `true` on success.
//! @param ec Set to the error, if any occurred.
//!
bool on_null(json::error_code& ec);
bool on_null(boost::system::error_code& ec);

//! Called with characters corresponding to part of the current comment.
//!
//! @return `true` on success.
//! @param s The partial characters.
//! @param ec Set to the error, if any occurred.
//!
bool on_comment_part(std::string_view s, json::error_code& ec);
bool on_comment_part(std::string_view s, boost::system::error_code& ec);

//! Called with the last characters corresponding to the current comment.
//!
//! @return `true` on success.
//! @param s The remaining characters
//! @param ec Set to the error, if any occurred.
//!
bool on_comment(std::string_view s, json::error_code& ec);
bool on_comment(std::string_view s, boost::system::error_code& ec);

enum ETokenType {
E_TokenNull = 0,
Expand Down
14 changes: 13 additions & 1 deletion include/core/CMemoryFwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,23 @@

namespace ml {
namespace core {

//! C++20-safe replacement for the deprecated \c std::is_pod / \c std::is_pod_v.
//!
//! \c std::is_pod was deprecated in C++20. The standard defines a POD type as
//! one that is both trivial and standard-layout, so this reproduces
//! \c std::is_pod_v exactly - verified equivalent across fundamentals, cv- and
//! pointer-qualified types, arrays, enums, unions, aggregates, inheritance
//! (standard-layout) edge cases and library types - without emitting the
//! deprecation warning (MSVC C4996 / \c -Wdeprecated-declarations).
template<typename T>
inline constexpr bool is_pod_v = std::is_trivial_v<T>&& std::is_standard_layout_v<T>;

namespace memory_detail {
//! \brief Base implementation checks for POD.
template<typename T, typename = void>
struct SDynamicSizeAlwaysZero {
static constexpr inline bool value() { return std::is_pod<T>::value; }
static constexpr inline bool value() { return is_pod_v<T>; }
};

//! \brief Checks types in pair.
Expand Down
Loading