Skip to content

Commit

Permalink
[HACKATHON 6th][CMake Optimization] use CMAKE_CXX_COMPILER_ID instead…
Browse files Browse the repository at this point in the history
… CMAKE_COMPILER_IS_XXX etc (#62473)
  • Loading branch information
silverling authored Mar 7, 2024
1 parent 1208cd3 commit b684e1a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 35 deletions.
20 changes: 6 additions & 14 deletions cmake/external/eigen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,19 @@ elseif(LINUX)
endif()
endif()

if(CMAKE_COMPILER_IS_GNUCC)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/eigen/TensorRandom.h.patch
tensor_random_header)
# See: [Why calling some `git` commands before `patch`?]
set(EIGEN_PATCH_COMMAND
git checkout -- . && git checkout ${EIGEN_TAG} && patch -Nd
${SOURCE_DIR}/unsupported/Eigen/CXX11/src/Tensor <
${tensor_random_header})
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpfullversion -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION})
list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR)
list(GET GCC_VERSION_COMPONENTS 1 GCC_MINOR)
set(GCC_VERSION "${GCC_MAJOR}.${GCC_MINOR}")
if(GCC_VERSION GREATER_EQUAL 12.0)
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/eigen/Complex.h.patch
complex_header)
set(EIGEN_PATCH_COMMAND
${EIGEN_PATCH_COMMAND} && patch -Nd
${SOURCE_DIR}/Eigen/src/Core/arch/SSE/ < ${complex_header})
endif()
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/eigen/Complex.h.patch
complex_header)
set(EIGEN_PATCH_COMMAND
${EIGEN_PATCH_COMMAND} && patch -Nd
${SOURCE_DIR}/Eigen/src/Core/arch/SSE/ < ${complex_header})
endif()

set(EIGEN_INCLUDE_DIR ${SOURCE_DIR})
Expand Down
28 changes: 10 additions & 18 deletions cmake/external/gloo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,16 @@ if(WITH_GPU)
endif()
endif()

if(CMAKE_COMPILER_IS_GNUCC)
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpfullversion -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION})
list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR)
list(GET GCC_VERSION_COMPONENTS 1 GCC_MINOR)
set(GCC_VERSION "${GCC_MAJOR}.${GCC_MINOR}")
if(GCC_VERSION GREATER_EQUAL "12.0")
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/gloo/device.cc.patch
native_dst)
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/gloo/types.h.patch
types_header)
# See: [Why calling some `git` commands before `patch`?]
set(GLOO_PATCH_COMMAND
git checkout -- . && git checkout ${GLOO_TAG} && patch -Nd
${SOURCE_DIR}/gloo/transport/tcp < ${native_dst} && patch -Nd
${SOURCE_DIR}/gloo/ < ${types_header})
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/gloo/device.cc.patch
native_dst)
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/gloo/types.h.patch
types_header)
# See: [Why calling some `git` commands before `patch`?]
set(GLOO_PATCH_COMMAND
git checkout -- . && git checkout ${GLOO_TAG} && patch -Nd
${SOURCE_DIR}/gloo/transport/tcp < ${native_dst} && patch -Nd
${SOURCE_DIR}/gloo/ < ${types_header})
endif()

file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/gloo/linux.cc.patch
Expand Down
4 changes: 1 addition & 3 deletions cmake/simd.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
include(CheckCXXSourceRuns)
include(CheckCXXSourceCompiles)

if(CMAKE_COMPILER_IS_GNUCC
OR CMAKE_COMPILER_IS_GNUCXX
OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(MMX_FLAG "-mmmx")
set(SSE2_FLAG "-msse2")
set(SSE3_FLAG "-msse3")
Expand Down

0 comments on commit b684e1a

Please sign in to comment.