Enabling c++20 on linux - #17816
Conversation
…ERTY LINK_FLAGS " -s ASSERTIONS=2 -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=2")"
…ING PROPERTY LINK_FLAGS " -s ASSERTIONS=2 -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=2")"" This reverts commit c72c40e.
|
We cannot do it for Linux CUDA build yet. Because the compiler we use is GCC 8, which is too low. |
|
Just out of curiosity. Why do you need C++20? Would it crash onnxruntime build in my old conda environment? |
|
For your second question, no. A new C++ standard consists of two things:
The first one doesn't have impact on compatibility. The second one has impacts on non-Windows/non-Linux systems like macOS/iOS. We can avoid the issue by not using the headers that are not supported by the target system. |
|
Wait this #20786 . The PR will update all GCCs to >=11. Now we still have GCC 8. |
|
The GCC version is updated. |
We can use the new C++ features to write better code, and it shouldn't impact our compatibility at runtime. The language features are listed in https://gcc.gnu.org/projects/cxx-status.html in "C++20 Language Features" section |
| template <typename InputType, typename ThresholdType, typename OutputType> | ||
| class TreeAggregatorMax : public TreeAggregator<InputType, ThresholdType, OutputType> { | ||
| public: | ||
| TreeAggregatorMax<InputType, ThresholdType, OutputType>(size_t n_trees, |
There was a problem hiding this comment.
All other similar class like TreeAggregatorMin and TreeAggregatorSum does not include type qualifier.
|
depends on #21071 |
…nux_c++20 # Conflicts: # onnxruntime/contrib_ops/cuda/math/cufft_plan_cache.h # orttraining/orttraining/training_ops/cuda/nn/conv_shared.h # orttraining/orttraining/training_ops/rocm/nn/conv_grad.cc
#pragma clang diagnostic pop #endif
# Conflicts: # onnxruntime/core/providers/cpu/ml/tree_ensemble_aggregator.h
| class OrtMutex { | ||
| #if defined(__clang__) && __cplusplus >= 202002L | ||
| #pragma clang diagnostic push | ||
| #pragma clang diagnostic ignored "-Wdeprecated-pragma" |
There was a problem hiding this comment.
I think this can be fixed - see this patch: e34c91c
| int n = batch_size * sequence_length; | ||
| concurrency::ThreadPool::TryBatchParallelFor( | ||
| #if __cplusplus >= 202002L | ||
| context->GetOperatorThreadPool(), n, [=, this, &failed](ptrdiff_t index) { |
There was a problem hiding this comment.
see this core guideline:
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f54-when-writing-a-lambda-that-captures-this-or-any-class-data-member-dont-use--default-capture
I think they have a point. at least, we should consider how to make the code easier to understand.
|
Now we are using NDK 27? |
# Conflicts: # include/onnxruntime/core/platform/ort_mutex.h # onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc # onnxruntime/core/session/inference_session.cc
| 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<MIGraphXFuncState> p = std::make_unique<MIGraphXFuncState>(); |
There was a problem hiding this comment.
| 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<MIGraphXFuncState> p = std::make_unique<MIGraphXFuncState>(); | |
| NodeComputeInfo compute_info; | |
| compute_info.create_state_func = [=, this](ComputeContext* context, FunctionState* state) { | |
| std::unique_ptr<MIGraphXFuncState> p = std::make_unique<MIGraphXFuncState>(); |
[input_ids_data,
word_embedding_length,
sequence_length,
position_ids_data,
broadcast_position_ids,
position_embedding_data,
word_embedding_data,
segment_ids_data,
segment_embedding_data,
position_embedding_length,
segment_embedding_length,
output_data,
embedding_sum_data,
gamma_data,
beta_data,
epsilon_value,
hidden_size,
&failed](ptrdiff_t index) {
| context->GetOperatorThreadPool(), n, | ||
| [input_ids_data, | ||
| word_embedding_length, | ||
| sequence_length, | ||
| position_ids_data, | ||
| broadcast_position_ids, | ||
| position_embedding_data, | ||
| word_embedding_data, | ||
| segment_ids_data, | ||
| segment_embedding_data, | ||
| position_embedding_length, | ||
| segment_embedding_length, | ||
| output_data, | ||
| embedding_sum_data, | ||
| gamma_data, | ||
| beta_data, | ||
| epsilon_value, | ||
| hidden_size, | ||
| &failed](ptrdiff_t index) { | ||
| #else |
There was a problem hiding this comment.
| context->GetOperatorThreadPool(), n, | |
| [input_ids_data, | |
| word_embedding_length, | |
| sequence_length, | |
| position_ids_data, | |
| broadcast_position_ids, | |
| position_embedding_data, | |
| word_embedding_data, | |
| segment_ids_data, | |
| segment_embedding_data, | |
| position_embedding_length, | |
| segment_embedding_length, | |
| output_data, | |
| embedding_sum_data, | |
| gamma_data, | |
| beta_data, | |
| epsilon_value, | |
| hidden_size, | |
| &failed](ptrdiff_t index) { | |
| #else | |
| context->GetOperatorThreadPool(), n, | |
| [input_ids_data, | |
| word_embedding_length, | |
| sequence_length, | |
| position_ids_data, | |
| broadcast_position_ids, | |
| position_embedding_data, | |
| word_embedding_data, | |
| segment_ids_data, | |
| segment_embedding_data, | |
| position_embedding_length, | |
| segment_embedding_length, | |
| output_data, | |
| embedding_sum_data, | |
| gamma_data, | |
| beta_data, | |
| epsilon_value, | |
| hidden_size, | |
| &failed](ptrdiff_t index) { | |
| #else |
Description
Enabling c++20 on Linux
Currently blocking issue:
Motivation and Context
We want the latest and the greatest features from c++20.
depends on