Skip to content

Commit

Permalink
[VL] Enable using static link for QAT (#3863)
Browse files Browse the repository at this point in the history
  • Loading branch information
marin-ma authored Nov 29, 2023
1 parent 2528841 commit 94e6051
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
22 changes: 17 additions & 5 deletions cpp/CMake/BuildQATZstd.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@

include(ExternalProject)

if("${MAKE}" STREQUAL "")
if(NOT MSVC)
find_program(MAKE make)
endif()
endif()

macro(build_qatzstd)
# Find ZSTD
include(FindZstd)
Expand All @@ -41,7 +47,7 @@ macro(build_qatzstd)
GIT_TAG ${QATZSTD_SOURCE_BRANCH}
SOURCE_DIR ${QATZSTD_SOURCE_DIR}
CONFIGURE_COMMAND ""
BUILD_COMMAND $(MAKE) ${QATZSTD_MAKE_ARGS}
BUILD_COMMAND ${MAKE} ${QATZSTD_MAKE_ARGS}
INSTALL_COMMAND ""
BUILD_BYPRODUCTS ${QATZSTD_STATIC_LIB_TARGETS}
BUILD_IN_SOURCE 1)
Expand All @@ -57,8 +63,10 @@ macro(build_qatzstd)

set(QATZSTD_LINK_LIBRARIES
"${ZSTD_LIBRARY}"
"${QAT_LIBRARY}"
"${USDM_DRV_LIBRARY}"
"${QAT_S_LIBRARY}")
"${ADF_LIBRARY}"
"${OSAL_LIBRARY}")

set_target_properties(qatzstd::qatzstd
PROPERTIES IMPORTED_LOCATION
Expand All @@ -71,11 +79,15 @@ macro(build_qatzstd)
add_dependencies(qatzstd::qatzstd qatzstd_ep)
endmacro()

find_library(USDM_DRV_LIBRARY REQUIRED NAMES usdm_drv_s PATHS "$ENV{ICP_ROOT}/build" NO_DEFAULT_PATH)
find_library(QAT_S_LIBRARY REQUIRED NAMES qat_s PATHS "$ENV{ICP_ROOT}/build" NO_DEFAULT_PATH)
find_library(QAT_LIBRARY REQUIRED NAMES qat PATHS "$ENV{ICP_ROOT}/build" NO_DEFAULT_PATH)
find_library(USDM_DRV_LIBRARY REQUIRED NAMES usdm_drv PATHS "$ENV{ICP_ROOT}/build" NO_DEFAULT_PATH)
find_library(ADF_LIBRARY REQUIRED NAMES adf PATHS "$ENV{ICP_ROOT}/build" NO_DEFAULT_PATH)
find_library(OSAL_LIBRARY REQUIRED NAMES osal PATHS "$ENV{ICP_ROOT}/build" NO_DEFAULT_PATH)

message(STATUS "Found qat: ${QAT_LIBRARY}")
message(STATUS "Found usdm_drv: ${USDM_DRV_LIBRARY}")
message(STATUS "Found qat_s: ${QAT_S_LIBRARY}")
message(STATUS "Found adf: ${ADF_LIBRARY}")
message(STATUS "Found osal: ${OSAL_LIBRARY}")

build_qatzstd()

20 changes: 15 additions & 5 deletions cpp/CMake/BuildQATzip.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@

include(ExternalProject)

if("${MAKE}" STREQUAL "")
if(NOT MSVC)
find_program(MAKE make)
endif()
endif()

macro(build_qatzip)
message(STATUS "Building QATzip from source")
set(QATZIP_BUILD_VERSION "v1.1.1")
Expand All @@ -43,7 +49,7 @@ macro(build_qatzip)
URL_HASH "SHA256=${QATZIP_BUILD_SHA256_CHECKSUM}"
SOURCE_DIR ${QATZIP_SOURCE_DIR}
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env QZ_ROOT=${QATZIP_SOURCE_DIR} ./configure ${QATZIP_CONFIGURE_ARGS}
BUILD_COMMAND $(MAKE) all
BUILD_COMMAND ${MAKE} all
BUILD_BYPRODUCTS ${QATZIP_STATIC_LIB_TARGETS}
BUILD_IN_SOURCE 1)

Expand All @@ -60,8 +66,10 @@ macro(build_qatzip)
"${ZLIB_LIBRARY}"
"${LZ4_LIBRARY}"
"${UDEV_LIBRARY}"
"${QAT_LIBRARY}"
"${USDM_DRV_LIBRARY}"
"${QAT_S_LIBRARY}"
"${ADF_LIBRARY}"
"${OSAL_LIBRARY}"
Threads::Threads)

add_library(qatzip::qatzip STATIC IMPORTED)
Expand All @@ -82,14 +90,16 @@ find_package(Threads REQUIRED)
find_library(ZLIB_LIBRARY REQUIRED NAMES z)
find_library(LZ4_LIBRARY REQUIRED NAMES lz4)
find_library(UDEV_LIBRARY REQUIRED NAMES udev)
find_library(USDM_DRV_LIBRARY REQUIRED NAMES usdm_drv_s PATHS "$ENV{ICP_ROOT}/build" NO_DEFAULT_PATH)
find_library(QAT_S_LIBRARY REQUIRED NAMES qat_s PATHS "$ENV{ICP_ROOT}/build" NO_DEFAULT_PATH)
find_library(USDM_DRV_LIBRARY REQUIRED NAMES usdm_drv PATHS "$ENV{ICP_ROOT}/build" NO_DEFAULT_PATH)
find_library(QAT_LIBRARY REQUIRED NAMES qat PATHS "$ENV{ICP_ROOT}/build" NO_DEFAULT_PATH)
find_library(OSAL_LIBRARY REQUIRED NAMES osal PATHS "$ENV{ICP_ROOT}/build" NO_DEFAULT_PATH)
find_library(ADF_LIBRARY REQUIRED NAMES adf PATHS "$ENV{ICP_ROOT}/build" NO_DEFAULT_PATH)

message(STATUS "Found zlib: ${ZLIB_LIBRARY}")
message(STATUS "Found lz4: ${LZ4_LIBRARY}")
message(STATUS "Found udev: ${UDEV_LIBRARY}")
message(STATUS "Found usdm_drv: ${USDM_DRV_LIBRARY}")
message(STATUS "Found qat_s: ${QAT_S_LIBRARY}")
message(STATUS "Found qat: ${QAT_LIBRARY}")

build_qatzip()

2 changes: 1 addition & 1 deletion cpp/CMake/FindZstd.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# ZSTD_FOUND: whether zstd has been found

if (NOT "$ENV{ZSTD_HOME}" STREQUAL "")
file(TO_CMAKE_PATH "${ZSTD_HOME}" _zstd_path)
file(TO_CMAKE_PATH "$ENV{ZSTD_HOME}" _zstd_path)
message(STATUS "ZSTD_HOME: ${_zstd_path}")
else()
set(_zstd_path "/usr/local")
Expand Down
9 changes: 9 additions & 0 deletions dev/vcpkg/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@
"dependencies": [
"memkind"
]
},
"qat": {
"description": "QAT",
"dependencies": [
{
"name": "zstd",
"version>=": "1.5.4"
}
]
}
},
"overrides": [
Expand Down

0 comments on commit 94e6051

Please sign in to comment.