Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmake] add libxsmm,lite,openblas third_party cache #54380

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions cmake/external/libxsmm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

include(ExternalProject)

set(LIBXSMM_SOURCE_DIR ${PADDLE_SOURCE_DIR}/third_party/libxsmm)
set(LIBXSMM_TAG 7cc03b5b342fdbc6b6d990b190671c5dbb8489a2)

set(LIBXSMM_PREFIX_DIR ${THIRD_PARTY_PATH}/libxsmm)
set(LIBXSMM_INSTALL_DIR ${THIRD_PARTY_PATH}/install/libxsmm)
set(LIBXSMM_INCLUDE_DIR
Expand All @@ -25,11 +28,31 @@ set(LIBXSMM_LIBRARY_DIR
set(LIBXSMM_LIB "${LIBXSMM_LIBRARY_DIR}/libxsmm.a")
set(LIBXSMMNOBLAS_LIB "${LIBXSMM_LIBRARY_DIR}/libxsmmnoblas.a")

file(GLOB LIBXSMM_SOURCE_FILE_LIST ${LIBXSMM_SOURCE_DIR})
list(LENGTH LIBXSMM_SOURCE_FILE_LIST RES_LEN)
if(RES_LEN EQUAL 0)
execute_process(
COMMAND ${GIT_EXECUTABLE} clone -b ${LIBXSMM_TAG}
"https://github.com/hfp/libxsmm.git" ${LIBXSMM_SOURCE_DIR})
else()
# check git tag
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --abbrev=6 --always --tags
OUTPUT_VARIABLE VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
WORKING_DIRECTORY ${LIBXSMM_SOURCE_DIR})
if(NOT ${VERSION} STREQUAL ${LIBXSMM_TAG})
message(
WARNING "libxsmm version is not ${VERSION}, checkout to ${LIBXSMM_TAG}")
execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${LIBXSMM_TAG}
WORKING_DIRECTORY ${LIBXSMM_SOURCE_DIR})
endif()
endif()

ExternalProject_Add(
extern_libxsmm
${SHALLOW_CLONE}
GIT_REPOSITORY "${GIT_URL}/hfp/libxsmm.git"
GIT_TAG "7cc03b5b342fdbc6b6d990b190671c5dbb8489a2"
${EXTERNAL_PROJECT_LOG_ARGS}
SOURCE_DIR ${LIBXSMM_SOURCE_DIR}
PREFIX ${LIBXSMM_PREFIX_DIR}
UPDATE_COMMAND ""
CONFIGURE_COMMAND ""
Expand Down
31 changes: 25 additions & 6 deletions cmake/external/openblas.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include(ExternalProject)

set(CBLAS_PREFIX_DIR ${THIRD_PARTY_PATH}/openblas)
set(CBLAS_INSTALL_DIR ${THIRD_PARTY_PATH}/install/openblas)
set(CBLAS_REPOSITORY ${GIT_URL}/xianyi/OpenBLAS.git)
set(CBLAS_SOURCE_DIR ${PADDLE_SOURCE_DIR}/third_party/openblas)
set(CBLAS_TAG v0.3.7)

# Why use v0.3.18? The IDG business line encountered a random openblas error,
Expand All @@ -43,6 +43,27 @@ if(WITH_LOONGARCH)
set(CBLAS_TAG v0.3.18)
endif()

file(GLOB CBLAS_SOURCE_FILE_LIST ${CBLAS_SOURCE_DIR})
list(LENGTH CBLAS_SOURCE_FILE_LIST RES_LEN)
if(RES_LEN EQUAL 0)
execute_process(
COMMAND ${GIT_EXECUTABLE} clone -b ${CBLAS_TAG}
"https://github.com/xianyi/OpenBLAS.git" ${CBLAS_SOURCE_DIR})
else()
# check git tag
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --abbrev=6 --always --tags
OUTPUT_VARIABLE VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
WORKING_DIRECTORY ${CBLAS_SOURCE_DIR})
if(NOT ${VERSION} STREQUAL ${CBLAS_TAG})
message(
WARNING "openblas version is not ${VERSION}, checkout to ${CBLAS_TAG}")
execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${CBLAS_TAG}
WORKING_DIRECTORY ${CBLAS_SOURCE_DIR})
endif()
endif()

if(NOT WIN32)
set(CBLAS_LIBRARIES
"${CBLAS_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}openblas${CMAKE_STATIC_LIBRARY_SUFFIX}"
Expand All @@ -64,9 +85,8 @@ if(NOT WIN32)
set(COMMON_ARGS CC=${OPENBLAS_CC} NO_SHARED=1 NO_LAPACK=1 libs)
ExternalProject_Add(
extern_openblas
${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
GIT_REPOSITORY ${CBLAS_REPOSITORY}
GIT_TAG ${CBLAS_TAG}
${EXTERNAL_PROJECT_LOG_ARGS}
SOURCE_DIR ${CBLAS_SOURCE_DIR}
PREFIX ${CBLAS_PREFIX_DIR}
INSTALL_DIR ${CBLAS_INSTALL_DIR}
BUILD_IN_SOURCE 1
Expand All @@ -85,8 +105,7 @@ else()
ExternalProject_Add(
extern_openblas
${EXTERNAL_PROJECT_LOG_ARGS}
GIT_REPOSITORY ${CBLAS_REPOSITORY}
GIT_TAG ${CBLAS_TAG}
SOURCE_DIR ${CBLAS_SOURCE_DIR}
PREFIX ${CBLAS_PREFIX_DIR}
INSTALL_DIR ${CBLAS_INSTALL_DIR}
BUILD_IN_SOURCE 0
Expand Down