Skip to content

Commit

Permalink
tmp update to c++17 of cinn-only test
Browse files Browse the repository at this point in the history
  • Loading branch information
6clc committed Jun 25, 2023
1 parent f370bd5 commit a04b499
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
29 changes: 21 additions & 8 deletions cmake/cinn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmake/cinn/core.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions cmake/cinn/external/absl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 0 additions & 2 deletions paddle/cinn/pybind/bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

namespace pybind11 {
namespace detail {
template <typename... Ts>
struct type_caster<absl::variant<Ts...>> : variant_caster<absl::variant<Ts...>> {};

template <typename Key, typename Value, typename Hash, typename Equal, typename Alloc>
struct type_caster<absl::flat_hash_map<Key, Value, Hash, Equal, Alloc>>
Expand Down

0 comments on commit a04b499

Please sign in to comment.