2023-12-05 22:47:18 +00:00
# Intel® QuickAssist Technology ZSTD Plugin (QAT ZSTD Plugin) is a plugin to Zstandard*(ZSTD*) for accelerating compression by QAT.
2023-12-20 15:12:24 +00:00
# ENABLE_QAT_OUT_OF_TREE_BUILD = 1 means kernel don't have native support, user will build and install driver from external package: https://www.intel.com/content/www/us/en/download/765501.html
2023-12-12 16:15:11 +00:00
# meanwhile, user need to set ICP_ROOT environment variable which point to the root directory of QAT driver source tree.
2023-12-20 15:12:24 +00:00
# ENABLE_QAT_OUT_OF_TREE_BUILD = 0 means kernel has built-in qat driver, QAT-ZSTD-PLUGIN just has dependency on qatlib.
2023-12-05 22:47:18 +00:00
2023-12-13 16:02:06 +00:00
if ( ENABLE_QAT_OUT_OF_TREE_BUILD )
2023-12-20 15:12:24 +00:00
message ( STATUS "Intel QATZSTD out-of-tree build, ICP_ROOT:${ICP_ROOT}" )
2023-12-05 22:47:18 +00:00
2023-12-20 15:12:24 +00:00
set ( QATZSTD_SRC_DIR "${ClickHouse_SOURCE_DIR}/contrib/QAT-ZSTD-Plugin/src" )
set ( QATZSTD_SRC "${QATZSTD_SRC_DIR}/qatseqprod.c" )
set ( ZSTD_LIBRARY_DIR "${ClickHouse_SOURCE_DIR}/contrib/zstd/lib" )
set ( QAT_INCLUDE_DIR "${ICP_ROOT}/quickassist/include" )
set ( QAT_DC_INCLUDE_DIR "${ICP_ROOT}/quickassist/include/dc" )
set ( QAT_AL_INCLUDE_DIR "${ICP_ROOT}/quickassist/lookaside/access_layer/include" )
set ( QAT_USDM_INCLUDE_DIR "${ICP_ROOT}/quickassist/utilities/libusdm_drv" )
set ( USDM_LIBRARY "${ICP_ROOT}/build/libusdm_drv_s.so" )
set ( QAT_S_LIBRARY "${ICP_ROOT}/build/libqat_s.so" )
if ( ENABLE_QAT_USDM_DRIVER )
add_definitions ( -DENABLE_USDM_DRV )
endif ( )
add_library ( _qatzstd_plugin ${ QATZSTD_SRC } )
target_link_libraries ( _qatzstd_plugin PUBLIC ${ USDM_LIBRARY } ${ QAT_S_LIBRARY } )
target_include_directories ( _qatzstd_plugin
S Y S T E M P U B L I C " $ { Q A T Z S T D _ S R C _ D I R } "
P R I V A T E $ { Q A T _ I N C L U D E _ D I R }
$ { Q A T _ D C _ I N C L U D E _ D I R }
$ { Q A T _ A L _ I N C L U D E _ D I R }
$ { Q A T _ U S D M _ I N C L U D E _ D I R }
$ { Z S T D _ L I B R A R Y _ D I R } )
2024-01-08 16:05:36 +00:00
target_compile_definitions ( _qatzstd_plugin PRIVATE -DDEBUGLEVEL=0 PUBLIC -DENABLE_ZSTD_QAT_CODEC )
2023-12-20 15:12:24 +00:00
add_library ( ch_contrib::qatzstd_plugin ALIAS _qatzstd_plugin )
2024-01-07 16:47:12 +00:00
else ( ) # In-tree build
2023-12-20 15:12:24 +00:00
message ( STATUS "Intel QATZSTD in-tree build" )
set ( QATZSTD_SRC_DIR "${ClickHouse_SOURCE_DIR}/contrib/QAT-ZSTD-Plugin/src" )
set ( QATZSTD_SRC "${QATZSTD_SRC_DIR}/qatseqprod.c" )
set ( ZSTD_LIBRARY_DIR "${ClickHouse_SOURCE_DIR}/contrib/zstd/lib" )
2023-12-05 22:47:18 +00:00
2023-12-20 15:12:24 +00:00
# please download&build ICP package from: https://www.intel.com/content/www/us/en/download/765501.html
set ( ICP_ROOT "${ClickHouse_SOURCE_DIR}/contrib/qatlib" )
set ( QAT_INCLUDE_DIR "${ICP_ROOT}/quickassist/include" )
set ( QAT_DC_INCLUDE_DIR "${ICP_ROOT}/quickassist/include/dc" )
set ( QAT_AL_INCLUDE_DIR "${ICP_ROOT}/quickassist/lookaside/access_layer/include" )
set ( QAT_USDM_INCLUDE_DIR "${ICP_ROOT}/quickassist/utilities/libusdm_drv" )
set ( USDM_LIBRARY "${ICP_ROOT}/build/libusdm_drv_s.so" )
set ( QAT_S_LIBRARY "${ICP_ROOT}/build/libqat_s.so" )
set ( LIBQAT_ROOT_DIR "${ClickHouse_SOURCE_DIR}/contrib/qatlib" )
set ( LIBQAT_HEADER_DIR "${CMAKE_CURRENT_BINARY_DIR}/include" )
2023-12-05 22:47:18 +00:00
2023-12-20 15:12:24 +00:00
file ( MAKE_DIRECTORY
" $ { L I B Q A T _ H E A D E R _ D I R } / q a t "
)
file ( COPY "${LIBQAT_ROOT_DIR}/quickassist/include/cpa.h"
D E S T I N A T I O N " $ { L I B Q A T _ H E A D E R _ D I R } / q a t / "
)
file ( COPY "${LIBQAT_ROOT_DIR}/quickassist/include/dc/cpa_dc.h"
D E S T I N A T I O N " $ { L I B Q A T _ H E A D E R _ D I R } / q a t / "
)
file ( COPY "${LIBQAT_ROOT_DIR}/quickassist/lookaside/access_layer/include/icp_sal_poll.h"
D E S T I N A T I O N " $ { L I B Q A T _ H E A D E R _ D I R } / q a t / "
)
file ( COPY "${LIBQAT_ROOT_DIR}/quickassist/lookaside/access_layer/include/icp_sal_user.h"
D E S T I N A T I O N " $ { L I B Q A T _ H E A D E R _ D I R } / q a t / "
)
file ( COPY "${LIBQAT_ROOT_DIR}/quickassist/utilities/libusdm_drv/qae_mem.h"
D E S T I N A T I O N " $ { L I B Q A T _ H E A D E R _ D I R } / q a t / "
)
2023-12-05 22:47:18 +00:00
2023-12-20 15:12:24 +00:00
if ( ENABLE_QAT_USDM_DRIVER )
add_definitions ( -DENABLE_USDM_DRV )
endif ( )
2023-12-05 22:47:18 +00:00
2023-12-20 15:12:24 +00:00
add_library ( _qatzstd_plugin ${ QATZSTD_SRC } )
target_link_libraries ( _qatzstd_plugin PUBLIC ch_contrib::qatlib ch_contrib::usdm )
target_include_directories ( _qatzstd_plugin PRIVATE
$ { Q A T _ I N C L U D E _ D I R }
$ { Q A T _ D C _ I N C L U D E _ D I R }
$ { Q A T _ A L _ I N C L U D E _ D I R }
$ { Q A T _ U S D M _ I N C L U D E _ D I R }
$ { Z S T D _ L I B R A R Y _ D I R }
$ { L I B Q A T _ H E A D E R _ D I R } )
2024-01-07 17:47:31 +00:00
target_compile_definitions ( _qatzstd_plugin PRIVATE -DDEBUGLEVEL=0 PUBLIC -DENABLE_ZSTD_QAT_CODEC -DINTREE )
2023-12-20 15:12:24 +00:00
target_include_directories ( _qatzstd_plugin SYSTEM PUBLIC $< BUILD_INTERFACE:${QATZSTD_SRC_DIR} > $< INSTALL_INTERFACE:include > )
add_library ( ch_contrib::qatzstd_plugin ALIAS _qatzstd_plugin )
2023-12-05 22:47:18 +00:00
endif ( )