From a04b499e22bff6ecd08551f02c4c762b4f1bc17c Mon Sep 17 00:00:00 2001 From: 6clc Date: Sun, 25 Jun 2023 16:54:35 +0800 Subject: [PATCH] tmp update to c++17 of cinn-only test --- cmake/cinn.cmake | 29 +++++++++++++++++++++-------- cmake/cinn/core.cmake | 2 +- cmake/cinn/external/absl.cmake | 1 + paddle/cinn/pybind/bind.h | 2 -- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/cmake/cinn.cmake b/cmake/cinn.cmake index 9a286968545e9..594eed3e116d2 100644 --- a/cmake/cinn.cmake +++ b/cmake/cinn.cmake @@ -2,6 +2,22 @@ set(CINN_THIRD_PARTY_PATH "${CMAKE_BINARY_DIR}/third_party") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(DOWNLOAD_MODEL_DIR "${CINN_THIRD_PARTY_PATH}/model") +string(REGEX MATCH "-std=(c\\+\\+[^ ]+)" STD_FLAG "${CMAKE_CXX_FLAGS}") +if (NOT STD_FLAG) + if (NOT CMAKE_CXX_STANDARD) + message(STATUS "STD_FLAG and CMAKE_CXX_STANDARD not found, using default flag: -std=c++17") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") + set(CMAKE_CXX_STANDARD 17) + else() + message(STATUS "Got CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}, append -std=c++${CMAKE_CXX_STANDARD} to CMAKE_CXX_FLAGS") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++${CMAKE_CXX_STANDARD}") + endif() +else() + string(REGEX MATCH "([0-9]+)" STD_VALUE "${STD_FLAG}") + message(STATUS "Got STD_FLAG=${STD_FLAG}, set CMAKE_CXX_STANDARD=${STD_VALUE}") + set(CMAKE_CXX_STANDARD ${STD_VALUE}) +endif() + if(NOT DEFINED ENV{runtime_include_dir}) message( STATUS @@ -54,6 +70,7 @@ if(WITH_GPU) cuda_select_nvcc_arch_flags(ARCH_FLAGS Auto) list(APPEND CUDA_NVCC_FLAGS ${ARCH_FLAGS}) + set(CMAKE_CUDA_STANDARD ${CMAKE_CXX_STANDARD}) message( STATUS @@ -64,14 +81,10 @@ if(WITH_GPU) find_library(CUDASTUB libcuda.so HINTS ${CUDA_TOOLKIT_ROOT_DIR}/lib64/stubs/ REQUIRED) - find_library(CUBLAS libcublas.so HINTS ${CUDA_TOOLKIT_ROOT_DIR}/lib64 - /usr/lib REQUIRED) - find_library(CUDNN libcudnn.so HINTS ${CUDA_TOOLKIT_ROOT_DIR}/lib64 /usr/lib - REQUIRED) - find_library(CURAND libcurand.so HINTS ${CUDA_TOOLKIT_ROOT_DIR}/lib64 - /usr/lib REQUIRED) - find_library(CUSOLVER libcusolver.so HINTS ${CUDA_TOOLKIT_ROOT_DIR}/lib64 - /usr/lib REQUIRED) + find_library(CUBLAS libcublas.so HINTS ${CUDA_TOOLKIT_ROOT_DIR}/lib64 /usr/lib /usr/lib64 REQUIRED) + find_library(CUDNN libcudnn.so HINTS ${CUDA_TOOLKIT_ROOT_DIR}/lib64 /usr/lib /usr/lib64 REQUIRED) + find_library(CURAND libcurand.so HINTS ${CUDA_TOOLKIT_ROOT_DIR}/lib64 /usr/lib /usr/lib64 REQUIRED) + find_library(CUSOLVER libcusolver.so HINTS ${CUDA_TOOLKIT_ROOT_DIR}/lib64 /usr/lib /usr/lib64 REQUIRED) endif() set(cinnapi_src CACHE INTERNAL "" FORCE) diff --git a/cmake/cinn/core.cmake b/cmake/cinn/core.cmake index d76b59732827f..2f5019b6eb027 100644 --- a/cmake/cinn/core.cmake +++ b/cmake/cinn/core.cmake @@ -151,7 +151,7 @@ function(cinn_nv_test TARGET_NAME) set(multiValueArgs SRCS DEPS ARGS) cmake_parse_arguments(cinn_nv_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - cuda_add_executable(${TARGET_NAME} ${cinn_nv_test_SRCS}) + cuda_add_executable(${TARGET_NAME} ${cinn_nv_test_SRCS} OPTIONS "-std=c++${CMAKE_CUDA_STANDARD}") get_property(os_dependency_modules GLOBAL PROPERTY OS_DEPENDENCY_MODULES) target_link_libraries( ${TARGET_NAME} diff --git a/cmake/cinn/external/absl.cmake b/cmake/cinn/external/absl.cmake index 93c70c54959d4..b7ded7502e281 100644 --- a/cmake/cinn/external/absl.cmake +++ b/cmake/cinn/external/absl.cmake @@ -12,6 +12,7 @@ set(OPTIONAL_ARGS "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}" + "-DABSL_CXX_STANDARD=17" "-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}" "-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}" "-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}" diff --git a/paddle/cinn/pybind/bind.h b/paddle/cinn/pybind/bind.h index 588f2ea58fa3b..78c8b121580f1 100644 --- a/paddle/cinn/pybind/bind.h +++ b/paddle/cinn/pybind/bind.h @@ -23,8 +23,6 @@ namespace pybind11 { namespace detail { -template -struct type_caster> : variant_caster> {}; template struct type_caster>