未验证 提交 856c54a8 编写于 作者: S Sanbu 提交者: GitHub

[cmake] add cusparselt third_party cache (#54388)

* [cmake] add cusparselt third_party cache

* fix

* fix ci

* fix ci
上级 12d04ab2
...@@ -22,7 +22,8 @@ if(WITH_ARM OR WIN32) ...@@ -22,7 +22,8 @@ if(WITH_ARM OR WIN32)
endif() endif()
include(ExternalProject) include(ExternalProject)
set(CUSPARSELT_DOWNLOAD_DIR
${PADDLE_SOURCE_DIR}/third_party/cusparselt/${CMAKE_SYSTEM_NAME})
set(CUSPARSELT_PROJECT "extern_cusparselt") set(CUSPARSELT_PROJECT "extern_cusparselt")
set(CUSPARSELT_P "https://developer.download.nvidia.com/compute") set(CUSPARSELT_P "https://developer.download.nvidia.com/compute")
set(CUSPARSELT_F "libcusparse_lt-linux-x86_64-0.2.0.1.tar.gz") set(CUSPARSELT_F "libcusparse_lt-linux-x86_64-0.2.0.1.tar.gz")
...@@ -37,22 +38,60 @@ set(CUSPARSELT_INC_DIR ...@@ -37,22 +38,60 @@ set(CUSPARSELT_INC_DIR
set(CUSPARSELT_LIB_DIR set(CUSPARSELT_LIB_DIR
"${CUSPARSELT_INSTALL_DIR}/lib64" "${CUSPARSELT_INSTALL_DIR}/lib64"
CACHE PATH "sparselt lib directory." FORCE) CACHE PATH "sparselt lib directory." FORCE)
set(CUSPARSELT_CACHE_FILENAME "${CUSPARSELT_F}")
set(CUSPARSELT_URL_MD5 "4f72f469e9cb1a85b09017fbace733d7")
set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1) set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1)
include_directories(${CUSPARSELT_INC_DIR}) include_directories(${CUSPARSELT_INC_DIR})
function(download_cusparselt)
message(
STATUS
"Downloading ${CUSPARSELT_URL} to ${CUSPARSELT_DOWNLOAD_DIR}/${CUSPARSELT_CACHE_FILENAME}"
)
# NOTE: If the version is updated, consider emptying the folder; maybe add timeout
file(
DOWNLOAD ${CUSPARSELT_URL}
${CUSPARSELT_DOWNLOAD_DIR}/${CUSPARSELT_CACHE_FILENAME}
EXPECTED_MD5 ${CUSPARSELT_URL_MD5}
STATUS ERR)
if(ERR EQUAL 0)
message(STATUS "Download ${CUSPARSELT_CACHE_FILENAME} success")
else()
message(
FATAL_ERROR
"Download failed, error: ${ERR}\n You can try downloading ${CUSPARSELT_CACHE_FILENAME} again"
)
endif()
endfunction()
find_file(
LOCAL_CUSPARSELT_LIB_ZIP
NAMES ${CUSPARSELT_CACHE_FILENAME}
PATHS ${CUSPARSELT_DOWNLOAD_DIR}
NO_DEFAULT_PATH)
if(LOCAL_CUSPARSELT_LIB_ZIP)
file(MD5 ${CUSPARSELT_DOWNLOAD_DIR}/${CUSPARSELT_CACHE_FILENAME}
CUSPARSELT_MD5)
if(NOT CUSPARSELT_MD5 EQUAL CUSPARSELT_URL_MD5)
download_cusparselt()
endif()
else()
download_cusparselt()
endif()
ExternalProject_Add( ExternalProject_Add(
${CUSPARSELT_PROJECT} ${CUSPARSELT_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS}
URL ${CUSPARSELT_URL} URL ${CUSPARSELT_DOWNLOAD_DIR}/${CUSPARSELT_CACHE_FILENAME}
PREFIX ${CUSPARSELT_PREFIX_DIR} PREFIX ${CUSPARSELT_PREFIX_DIR}
DOWNLOAD_DIR ${CUSPARSELT_DOWNLOAD_DIR}
DOWNLOAD_NO_PROGRESS 1 DOWNLOAD_NO_PROGRESS 1
SOURCE_DIR ${CUSPARSELT_INSTALL_DIR}
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""
INSTALL_COMMAND INSTALL_COMMAND ""
${CMAKE_COMMAND} -E copy_directory
${CUSPARSELT_PREFIX_DIR}/src/extern_cusparselt/lib64 ${CUSPARSELT_LIB_DIR}
&& ${CMAKE_COMMAND} -E copy_directory
${CUSPARSELT_PREFIX_DIR}/src/extern_cusparselt/include ${CUSPARSELT_INC_DIR}
UPDATE_COMMAND "") UPDATE_COMMAND "")
add_library(cusparselt INTERFACE) add_library(cusparselt INTERFACE)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册