From 23e4294747627aee3d4953571cdc728ecc8c8603 Mon Sep 17 00:00:00 2001 From: John Shumway Date: Tue, 22 Jul 2025 11:52:10 -0600 Subject: [PATCH] Switch to C++20 standard for all CMake targets. (#2536) All our platforms support C++20 now, so update to C++20 standard for language features such as concepts, designated initializers, range-based for initializers, and consteval. This PR only switches the compiler flags to C++20, no other changes. [ROCm/composable_kernel commit: 67b282162345effdfea44b7cec2348416f990cf9] --- client_example/CMakeLists.txt | 2 +- codegen/CMakeLists.txt | 2 +- codegen/test/rtc/src/compile_kernel.cpp | 4 ++-- script/cmake-ck-dev.sh | 2 +- test/block_swizzle_test/rebuild.sh | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client_example/CMakeLists.txt b/client_example/CMakeLists.txt index 8fdd60f5d5..f27e557cc3 100644 --- a/client_example/CMakeLists.txt +++ b/client_example/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.15) project(ck_app) -add_compile_options(-std=c++17) +add_compile_options(-std=c++20) if (DTYPES) add_definitions(-DDTYPES) diff --git a/codegen/CMakeLists.txt b/codegen/CMakeLists.txt index 35b5cf0367..2b2e6e2949 100644 --- a/codegen/CMakeLists.txt +++ b/codegen/CMakeLists.txt @@ -22,7 +22,7 @@ file(GLOB_RECURSE KERNEL_FILES CONFIGURE_DEPENDS add_embed_library(ck_headers ${KERNEL_FILES} RELATIVE ${CK_ROOT}/include) -add_compile_options(-std=c++17) +add_compile_options(-std=c++20) file(GLOB SOURCES CONFIGURE_DEPENDS src/*.cpp) # TODO: Use object library diff --git a/codegen/test/rtc/src/compile_kernel.cpp b/codegen/test/rtc/src/compile_kernel.cpp index 262e6bae46..fac92ded7d 100644 --- a/codegen/test/rtc/src/compile_kernel.cpp +++ b/codegen/test/rtc/src/compile_kernel.cpp @@ -94,7 +94,7 @@ kernel clang_compile_kernel(const std::vector& srcs, compile_options o assert(not srcs.empty()); tmp_dir td{"compile"}; options.flags += " -I. -O3"; - options.flags += " -std=c++17"; + options.flags += " -std=c++20"; options.flags += " --offload-arch=" + get_device_name(); std::string out; @@ -278,7 +278,7 @@ std::vector> compile_hip_src_with_hiprtc(const std::vector& srcs, compile_options options) { options.flags += " -I. -O3"; - options.flags += " -std=c++17"; + options.flags += " -std=c++20"; options.flags += " -DCK_CODE_GEN_RTC"; options.flags += " --offload-arch=" + get_device_name(); auto cos = compile_hip_src_with_hiprtc(srcs, options); diff --git a/script/cmake-ck-dev.sh b/script/cmake-ck-dev.sh index 151c2a22ff..c45bb4330d 100755 --- a/script/cmake-ck-dev.sh +++ b/script/cmake-ck-dev.sh @@ -31,7 +31,7 @@ fi cmake \ -D CMAKE_PREFIX_PATH=/opt/rocm/ \ -D CMAKE_CXX_COMPILER=/opt/rocm/llvm/bin/clang++ \ --D CMAKE_CXX_FLAGS="-std=c++17 -O3 -ftemplate-backtrace-limit=0 -fPIE -Wno-gnu-line-marker" \ +-D CMAKE_CXX_FLAGS="-std=c++20 -O3 -ftemplate-backtrace-limit=0 -fPIE -Wno-gnu-line-marker" \ -D CMAKE_BUILD_TYPE=Release \ -D BUILD_DEV=ON \ -D GPU_TARGETS=$GPU_TARGETS \ diff --git a/test/block_swizzle_test/rebuild.sh b/test/block_swizzle_test/rebuild.sh index b07eb55048..553d1900d4 100644 --- a/test/block_swizzle_test/rebuild.sh +++ b/test/block_swizzle_test/rebuild.sh @@ -1,3 +1,3 @@ CC=g++ -$CC -Wall -std=c++17 -Iinclude -O3 block_swizzle_test.cpp -o block_swizzle_test.exe \ No newline at end of file +$CC -Wall -std=c++20 -Iinclude -O3 block_swizzle_test.cpp -o block_swizzle_test.exe \ No newline at end of file