diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 3d4f055bb6f53..208bcb67ca731 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -42,7 +42,7 @@ include(CheckFunctionExists) include(GNUInstallDirs) # onnxruntime_providers_* require CMAKE_INSTALL_* variables # TODO: update this once all system adapt c++20 -if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") +if(UNIX) set(CMAKE_CXX_STANDARD 20) else() set(CMAKE_CXX_STANDARD 17) diff --git a/include/onnxruntime/core/common/eigen_common_wrapper.h b/include/onnxruntime/core/common/eigen_common_wrapper.h index 57599e04037dc..c7425fdede6f0 100644 --- a/include/onnxruntime/core/common/eigen_common_wrapper.h +++ b/include/onnxruntime/core/common/eigen_common_wrapper.h @@ -10,6 +10,7 @@ // error: ignoring attributes on template argument "Eigen::PacketType::type {aka __vector(4) float}" [-Werror=ignored-attributes] #if defined(__GNUC__) #pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated" #if __GNUC__ >= 6 #pragma GCC diagnostic ignored "-Wignored-attributes" #endif diff --git a/include/onnxruntime/core/platform/ort_mutex.h b/include/onnxruntime/core/platform/ort_mutex.h index e24665f51423d..5e602f2ca2747 100644 --- a/include/onnxruntime/core/platform/ort_mutex.h +++ b/include/onnxruntime/core/platform/ort_mutex.h @@ -108,7 +108,14 @@ std::cv_status OrtCondVar::wait_for(std::unique_lock& cond_mutex, namespace onnxruntime { class OrtMutex { +#if defined(__clang__) && __cplusplus >= 202002L +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-pragma" +#endif nsync::nsync_mu data_ = NSYNC_MU_INIT; +#if defined(__clang__) && __cplusplus >= 202002L +#pragma clang diagnostic pop +#endif public: constexpr OrtMutex() = default; @@ -125,8 +132,14 @@ class OrtMutex { }; class OrtCondVar { +#if defined(__clang__) && __cplusplus >= 202002L +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-pragma" +#endif nsync::nsync_cv native_cv_object = NSYNC_CV_INIT; - +#if defined(__clang__) && __cplusplus >= 202002L +#pragma clang diagnostic pop +#endif public: constexpr OrtCondVar() noexcept = default; diff --git a/onnxruntime/contrib_ops/cpu/bert/embed_layer_norm.cc b/onnxruntime/contrib_ops/cpu/bert/embed_layer_norm.cc index 570f4108c3f62..c6db36931ef4e 100644 --- a/onnxruntime/contrib_ops/cpu/bert/embed_layer_norm.cc +++ b/onnxruntime/contrib_ops/cpu/bert/embed_layer_norm.cc @@ -87,7 +87,18 @@ Status EmbedLayerNorm::Compute(OpKernelContext* context) const { int n = batch_size * sequence_length; concurrency::ThreadPool::TryBatchParallelFor( +#if __cplusplus >= 202002L + context->GetOperatorThreadPool(), n, [=, this, &failed](ptrdiff_t index) { +#else +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated" +#endif context->GetOperatorThreadPool(), n, [=, &failed](ptrdiff_t index) { +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif +#endif int word_col_index = input_ids_data[index]; if (word_col_index < 0 || word_col_index >= word_embedding_length) { failed.store(true, std::memory_order_release); diff --git a/onnxruntime/core/common/logging/sinks/ostream_sink.cc b/onnxruntime/core/common/logging/sinks/ostream_sink.cc index 033f4d2573cda..cccf627b64370 100644 --- a/onnxruntime/core/common/logging/sinks/ostream_sink.cc +++ b/onnxruntime/core/common/logging/sinks/ostream_sink.cc @@ -33,7 +33,11 @@ void OStreamSink::SendImpl(const Timestamp& timestamp, const std::string& logger // Going with #2 as it should scale better at the cost of creating the message in memory first // before sending to the stream. +#ifdef _WIN32 + std::wostringstream msg; +#else std::ostringstream msg; +#endif #ifndef ORT_MINIMAL_BUILD if (message.Severity() == Severity::kWARNING) { diff --git a/onnxruntime/core/providers/cpu/text/string_normalizer.cc b/onnxruntime/core/providers/cpu/text/string_normalizer.cc index 32de3105d627d..6bda1b5c479ed 100644 --- a/onnxruntime/core/providers/cpu/text/string_normalizer.cc +++ b/onnxruntime/core/providers/cpu/text/string_normalizer.cc @@ -220,7 +220,14 @@ class Utf8ConverterGeneric { } private: +#if __cplusplus >= 202002L +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif std::codecvt_utf8 converter_; +#if __cplusplus >= 202002L +#pragma GCC diagnostic pop +#endif }; // We need to specialize for MS as there is diff --git a/onnxruntime/core/providers/cuda/math/topk_impl.cuh b/onnxruntime/core/providers/cuda/math/topk_impl.cuh index cbde6da457fdb..8958f58e5fb78 100644 --- a/onnxruntime/core/providers/cuda/math/topk_impl.cuh +++ b/onnxruntime/core/providers/cuda/math/topk_impl.cuh @@ -421,7 +421,7 @@ Status TopKImpl(const CudaKernel* kernel, bool use_deterministic_compute, }); } - auto XPT = static_cast(ceil(static_cast(dimension) / GridDim::maxThreadsPerBlock)); + auto XPT = static_cast(ceil(static_cast(dimension) / static_cast(GridDim::maxThreadsPerBlock))); if (BT * 2 >= K || 0 == sorted) { RadixTopK<<>>( input_x_ptr, output_v_ptr, output_i, elem_nums, size, axis, K, largest, sorted, dimension, XPT, @@ -452,8 +452,8 @@ Status TopKImpl(const CudaKernel* kernel, bool use_deterministic_compute, CUDA_RETURN_IF_ERROR(cub::DeviceRadixSort::SortPairs(nullptr, temp_bytes, input_key, output_key, input_value, output_value, dimension, 0, sizeof(T) * 8, stream)); auto temp_storage_buffer = kernel->GetScratchBuffer(temp_bytes, ort_stream); auto* temp_storage = temp_storage_buffer.get(); - auto blocks_per_grid_D = (int)(ceil(static_cast(dimension) / BT)); - auto blocks_per_grid_K = (int)(ceil(static_cast(K) / BT)); + auto blocks_per_grid_D = (int)(ceil(static_cast(dimension) / static_cast(BT))); + auto blocks_per_grid_K = (int)(ceil(static_cast(K) / static_cast(BT))); for (int64_t i = 0; i < N; i++) { FillInput<<>>(input_x_ptr, input_key, input_value, elem_nums, size, axis, K, i, dimension); CUDA_RETURN_IF_ERROR(1 == largest ? cub::DeviceRadixSort::SortPairsDescending(temp_storage, temp_bytes, input_key, output_key, input_value, output_value, dimension, 0, sizeof(T) * 8, stream) diff --git a/onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc b/onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc index 90dfa49c73c9a..602799cc7facd 100644 --- a/onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc +++ b/onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc @@ -1210,7 +1210,7 @@ Status MIGraphXExecutionProvider::Compile(const std::vector& map_input_index_[fused_node.Name()] = input_name_index; map_no_input_shape_[fused_node.Name()] = no_input_shape; NodeComputeInfo compute_info; - compute_info.create_state_func = [=](ComputeContext* context, FunctionState* state) { + compute_info.create_state_func = [=,this](ComputeContext* context, FunctionState* state) { std::unique_ptr p = std::make_unique(); *p = {context->allocate_func, context->release_func, context->allocator_handle, map_progs_[context->node_name], map_onnx_string_[context->node_name], options, t_, map_input_index_[context->node_name], &mgx_mu_, diff --git a/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc b/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc index c3d010ac9fcd7..288af2ed27e5f 100644 --- a/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc +++ b/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc @@ -3381,7 +3381,7 @@ Status TensorrtExecutionProvider::CreateNodeComputeInfoFromGraph(const GraphView // Create function state // TODO: remove default capture NodeComputeInfo compute_info; - compute_info.create_state_func = [=](ComputeContext* context, FunctionState* state) { + compute_info.create_state_func = [=, this](ComputeContext* context, FunctionState* state) { std::unique_ptr p = std::make_unique(); // translate tactic sources string to nvinfer1::TacticSources nvinfer1::TacticSources tactics = 0; @@ -3408,7 +3408,7 @@ Status TensorrtExecutionProvider::CreateNodeComputeInfoFromGraph(const GraphView }; // Create compute function - compute_info.compute_func = [this](FunctionState state, const OrtApi* api, OrtKernelContext* context) { + compute_info.compute_func = [=, this](FunctionState state, const OrtApi* api, OrtKernelContext* context) { Ort::KernelContext ctx(context); TensorrtFuncState* trt_state = reinterpret_cast(state); @@ -4056,7 +4056,7 @@ Status TensorrtExecutionProvider::CreateNodeComputeInfoFromPrecompiledEngine(con // Create function state // TODO: remove default capture NodeComputeInfo compute_info; - compute_info.create_state_func = [=](ComputeContext* context, FunctionState* state) { + compute_info.create_state_func = [=, this](ComputeContext* context, FunctionState* state) { std::unique_ptr p = std::make_unique(); *p = {context->allocate_func, context->release_func, @@ -4079,7 +4079,7 @@ Status TensorrtExecutionProvider::CreateNodeComputeInfoFromPrecompiledEngine(con }; // Create compute function - compute_info.compute_func = [this](FunctionState state, const OrtApi* api, OrtKernelContext* context) { + compute_info.compute_func = [=, this](FunctionState state, const OrtApi* api, OrtKernelContext* context) { Ort::KernelContext ctx(context); TensorrtShortFuncState* trt_state = reinterpret_cast(state); diff --git a/onnxruntime/core/session/inference_session.cc b/onnxruntime/core/session/inference_session.cc index b9e017df5baa3..83f11f9bfad3e 100644 --- a/onnxruntime/core/session/inference_session.cc +++ b/onnxruntime/core/session/inference_session.cc @@ -2770,7 +2770,18 @@ common::Status InferenceSession::RunAsync(const RunOptions* run_options, if (!tp || concurrency::ThreadPool::DegreeOfParallelism(tp) < 2) { return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT, "intra op thread pool must have at least one thread for RunAsync"); } +#if __cplusplus >= 202002L + std::function run_fn = [=, this]() { +#else +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated" +#endif std::function run_fn = [=]() { +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif +#endif Status status = Status::OK(); ORT_TRY { if (run_options) { diff --git a/onnxruntime/test/onnx/microbenchmark/eigen.cc b/onnxruntime/test/onnx/microbenchmark/eigen.cc index 230a57740d448..ce1605d74b649 100644 --- a/onnxruntime/test/onnx/microbenchmark/eigen.cc +++ b/onnxruntime/test/onnx/microbenchmark/eigen.cc @@ -8,6 +8,7 @@ #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-result" #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#pragma GCC diagnostic ignored "-Wdeprecated" // _deps/eigen-src/unsupported/Eigen/CXX11/../../../Eigen/src/Core/arch/NEON/PacketMath.h:1671:9: // error: ‘void* memcpy(void*, const void*, size_t)’ copying an object of non-trivial type ‘Eigen::internal::Packet4c’ diff --git a/onnxruntime/test/onnx/microbenchmark/tptest.cc b/onnxruntime/test/onnx/microbenchmark/tptest.cc index e51b12454294f..bc45801ca3400 100644 --- a/onnxruntime/test/onnx/microbenchmark/tptest.cc +++ b/onnxruntime/test/onnx/microbenchmark/tptest.cc @@ -102,7 +102,14 @@ static void BM_ThreadPoolSimpleParallelFor(benchmark::State& state) { for (auto _ : state) { for (int j = 0; j < 100; j++) { ThreadPool::TrySimpleParallelFor(tp.get(), len, [&](size_t) { +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wvolatile" for (volatile size_t x = 0; x < body; x++) { +#pragma GCC diagnostic pop +#else + for (volatile size_t x = 0; x < body; x++) { +#endif } }); }