diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e25f10e7f13..00632f8d71d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -439,9 +439,9 @@ include(cmake/utils/CCache.cmake) include(CheckCXXCompilerFlag) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CUDA_STANDARD_REQUIRED ON) -set(CMAKE_CUDA_STANDARD 17) +set(CMAKE_CUDA_STANDARD 20) # Module rules include(cmake/modules/CUDA.cmake) diff --git a/cmake/utils/FindLLVM.cmake b/cmake/utils/FindLLVM.cmake index 2bf229eca756..1f54ded1d5e9 100644 --- a/cmake/utils/FindLLVM.cmake +++ b/cmake/utils/FindLLVM.cmake @@ -254,9 +254,9 @@ macro(find_llvm use_llvm) # compiler-appropriate form so the probe works under MSVC as well. if(NOT CMAKE_CXX_STANDARD) if(MSVC) - set(CMAKE_REQUIRED_FLAGS "/std:c++17") + set(CMAKE_REQUIRED_FLAGS "/std:c++20") else() - set(CMAKE_REQUIRED_FLAGS "-std=c++17") + set(CMAKE_REQUIRED_FLAGS "-std=c++20") endif() endif() check_cxx_source_compiles(" diff --git a/docs/install/from_source.rst b/docs/install/from_source.rst index a970bf5c1e9e..392fdc5cfc5e 100644 --- a/docs/install/from_source.rst +++ b/docs/install/from_source.rst @@ -35,11 +35,15 @@ Apache TVM requires the following dependencies: - CMake (>= 3.24.0) - LLVM (recommended >= 15) - Git -- A recent C++ compiler supporting C++ 17, at the minimum - - GCC 7.1 - - Clang 5.0 - - Apple Clang 9.3 - - Visual Studio 2019 (v16.7) +- A recent C++ compiler supporting C++ 20, at the minimum + - GCC 10 + - Clang 10 + - Apple Clang 14 + - Visual Studio 2022 + + Optional dependencies that use newer C++20 standard library facilities, such + as ``std::format``, may require a newer standard library (for example GCC 13 + or newer on Linux). - Python (>= 3.10) - (Optional) Conda (Strongly Recommended) diff --git a/include/tvm/tirx/op.h b/include/tvm/tirx/op.h index 60b292bbb265..231b129b94be 100644 --- a/include/tvm/tirx/op.h +++ b/include/tvm/tirx/op.h @@ -825,7 +825,8 @@ inline bool IsPointerType(const Type& type, const DataType& element_type) { * \param span The location of this operation in the source. */ template ::value>::type> + typename = typename std::enable_if::value && + std::is_trivial::value>::type> inline PrimExpr make_const(DataType t, ValueType value, Span span = Span()); /*! * \brief Make a const zero expr. diff --git a/src/relax/transform/run_codegen.cc b/src/relax/transform/run_codegen.cc index bc99196169e7..efd90d6696d7 100644 --- a/src/relax/transform/run_codegen.cc +++ b/src/relax/transform/run_codegen.cc @@ -155,7 +155,7 @@ class CodeGenRunner : ExprMutator { if (opt_codegen) { auto ext_symbol = GetExtSymbol(func); size_t count = 0; - PostOrderVisit(func->body, [=, &count](Expr e) { + PostOrderVisit(func->body, [=, this, &count](Expr e) { if (e->IsInstance()) { // Make sure to pick a unique name auto name = ext_symbol + "_" + opt_codegen.value() + "_const_" + std::to_string(count++); diff --git a/src/runtime/extra/contrib/cudnn/cudnn_json_runtime.cc b/src/runtime/extra/contrib/cudnn/cudnn_json_runtime.cc index df38f960d294..a7cf1ec2b318 100644 --- a/src/runtime/extra/contrib/cudnn/cudnn_json_runtime.cc +++ b/src/runtime/extra/contrib/cudnn/cudnn_json_runtime.cc @@ -162,7 +162,7 @@ class cuDNNJSONRuntime : public JSONRuntimeBase { conv_dtype, false, &best_algo); int algo = best_algo.cast(); - std::function op_exec = [=]() { + std::function op_exec = [=, this]() { int device_id; CUDA_CALL(cudaGetDevice(&device_id)); cudaStream_t stream = static_cast(TVMFFIEnvGetStream(kDLCUDA, device_id)); @@ -223,7 +223,7 @@ class cuDNNJSONRuntime : public JSONRuntimeBase { auto runner = tvm::contrib::CuDNNSDPARunner::Create(); runner->Init(batch, seq_len, num_heads, num_kv_heads, head_size, head_size_v, scale, dtype, layout); - return [=]() { + return [=, this]() { auto qkv = GetInput(node, 0); auto workspace = const_cast(GetInput(node, 1)); auto out = const_cast(data_entry_[EntryID(outputs_[0])]); diff --git a/src/runtime/extra/disco/protocol.h b/src/runtime/extra/disco/protocol.h index 25662051dcb4..a26b3060bc2a 100644 --- a/src/runtime/extra/disco/protocol.h +++ b/src/runtime/extra/disco/protocol.h @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -78,7 +79,8 @@ struct DiscoProtocol { /*!\ brief Arena used by RPCReference to allocate POD memory */ template T* ArenaAlloc(int count) { - static_assert(std::is_pod::value, "need to be trival"); + static_assert(std::is_standard_layout::value && std::is_trivial::value, + "need to be trivial"); return arena_.template allocate_(count); } diff --git a/src/runtime/rpc/rpc_endpoint.cc b/src/runtime/rpc/rpc_endpoint.cc index a6950117d611..0402430251e5 100644 --- a/src/runtime/rpc/rpc_endpoint.cc +++ b/src/runtime/rpc/rpc_endpoint.cc @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -312,7 +313,8 @@ class RPCEndpoint::EventHandler : public support::Stream { template T* ArenaAlloc(int count) { - static_assert(std::is_pod::value, "need to be trival"); + static_assert(std::is_standard_layout::value && std::is_trivial::value, + "need to be trivial"); return arena_.template allocate_(count); } diff --git a/src/s_tir/transform/compact_buffer_region.cc b/src/s_tir/transform/compact_buffer_region.cc index d02e90701696..640a18d594cf 100644 --- a/src/s_tir/transform/compact_buffer_region.cc +++ b/src/s_tir/transform/compact_buffer_region.cc @@ -129,6 +129,8 @@ class BufferAccessRegionCollector : public StmtExprVisitor { } private: + using StmtExprVisitor::VisitBufferDef; + struct BufferAccessInfo { /*! \brief The buffer. */ Buffer buffer; diff --git a/src/s_tir/transform/inject_software_pipeline.cc b/src/s_tir/transform/inject_software_pipeline.cc index d9da151f392f..5099f66cd030 100644 --- a/src/s_tir/transform/inject_software_pipeline.cc +++ b/src/s_tir/transform/inject_software_pipeline.cc @@ -707,7 +707,7 @@ class PipelineRewriter : public StmtExprMutator { } } - auto wait_count = [=, &ana_normalized]() { + auto wait_count = [=, this, &ana_normalized]() { auto sum = PrimExpr(0); for (auto producer_head : producer_head_per_commit) { if (producer_head && ana_normalized->CanProve(producer_head.value() >= 0)) { diff --git a/src/target/llvm/codegen_params.cc b/src/target/llvm/codegen_params.cc index fccc92a22830..6d8684a87eda 100644 --- a/src/target/llvm/codegen_params.cc +++ b/src/target/llvm/codegen_params.cc @@ -61,7 +61,8 @@ struct LLVMConstantGetter::value>> static llvm::Constant* getElement(llvm::Type* ty, T t) { return llvm::ConstantFP::get(ty, t); } }; -template ::value>> +template ::value && std::is_trivial::value>> void BuildLLVMVector(llvm::Type* element_type, void* tensor_data, size_t num_elements, std::vector* elements) { elements->resize(num_elements, nullptr);