Skip to content

Commit

Permalink
Merge pull request #24 from intel-sandbox/ipcl/integration
Browse files Browse the repository at this point in the history
Add Support for Batching and Multiple QAT Devices/Instances
  • Loading branch information
fdiasmor authored Aug 5, 2022
2 parents 902aa39 + 0808b9f commit 2d027ca
Show file tree
Hide file tree
Showing 47 changed files with 5,232 additions and 572 deletions.
9 changes: 9 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
BasedOnStyle: Google
Language: Cpp
DerivePointerAlignment: false
PointerAlignment: Left
IndentWidth: 4
AccessModifierOffset: -4
IndentCaseLabels: false
SortIncludes: false
ColumnLimit: 80
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
build
.vscode/
.vs/


build*/
install

cmake/he_qat-*.*.*/HE_QATConfig.cmake
*.log
Doxyfile

**.swp
257 changes: 177 additions & 80 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,91 +1,188 @@
cmake_minimum_required(VERSION 3.13)

project(QATModExp LANGUAGES C CXX)
# The hekat or heqat (transcribed HqA.t) was an ancient Egyptian volume unit
# used to measure grain, bread, and beer.
project(HE_QAT VERSION 0.1.0 LANGUAGES C CXX)

set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED ON) set(
CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CMakePackageConfigHelpers)

include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) include(
CMakePackageConfigHelpers)
if(CMAKE_BUILD_TYPE)
set(RELEASE_TYPES
Debug
Release
RelWithDebInfo
MinSizeRel)
list(FIND RELEASE_TYPES ${CMAKE_BUILD_TYPE} INDEX_FOUND)
if(${INDEX_FOUND} EQUAL -1)
message(
FATAL_ERROR
"CMAKE_BUILD_TYPE must be one of Debug, Release, RelWithDebInfo, or MinSizeRel"
)
endif()
else()
set(CMAKE_BUILD_TYPE Release)
endif()

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_C_FLAGS "-O2")
set(CMAKE_CXX_FLAGS "-O2 -fpermissive")

# What does it do?
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# When to use it? To build with shared libraries.
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Why?
set(CMAKE_INSTALL_MESSAGE LAZY)

# Why?
set(CMAKE_INSTALL_RPATH "\$ORIGIN")

if(NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR}/install)
endif()
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")

# Which features or functions does it bring?
include(GNUInstallDirs)

# Location where to unpack and pack static libraries
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR})

# -------------------------------------------------------------------

option(HE_QAT_MISC "Enable miscellaneous features" ON)
option(HE_QAT_SYNC "Enable synchronous mode execution" OFF)
option(HE_QAT_PERF "Show request performance" OFF)
option(HE_QAT_TEST "Enable testing" OFF)
option(HE_QAT_SAMPLES "Enable examples" ON)
option(HE_QAT_BENCHMARK "Enable benchmark" OFF)
option(HE_QAT_DOCS "Enable document building" OFF)
option(HE_QAT_SHARED "Build shared library" ON)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(HE_QAT_DEBUG ON)
add_definitions(-DHE_QAT_DEBUG)
else()
set(HE_QAT_DEBUG OFF)
endif()

# Why?
set(HE_QAT_CMAKE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/he_qat")

set(HE_QAT_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})
set(HE_QAT_SRC_DIR ${HE_QAT_ROOT_DIR}/he_qat)
set(HE_QAT_INC_DIR ${HE_QAT_ROOT_DIR}/he_qat/include)

if(HE_QAT_MISC)
# IPP Crypto installation
if(IPPCP_PREFIX_PATH)
list(APPEND CMAKE_PREFIX_PATH "${IPPCP_PREFIX_PATH}")
set(IPPCP_DIR "${IPPCP_PREFIX_PATH}/../../../")
message(STATUS "IPPCP_DIR=${IPPCP_DIR}")
else()
# Default to this
set(IPPCP_DIR "/opt/ipp-crypto")
set(IPPCP_PREFIX_PATH "${IPPCP_DIR}/lib/cmake")
list(APPEND CMAKE_PREFIX_PATH "${IPPCP_PREFIX_PATH}")
message(STATUS "Else IPPCP_DIR=${IPPCP_DIR}")
endif()
find_package(IPPCP REQUIRED)
message(STATUS "IPPCP_LIBRARIES ${IPPCP_LIBRARIES}")
endif()

if(HE_QAT_SYNC)
add_definitions(-DHE_QAT_SYNC_MODE)
endif()

if(HE_QAT_PERF)
add_definitions(-DHE_QAT_PERF)
endif()

set(HE_QAT_FORWARD_CMAKE_ARGS
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_STANDARD=${CMAKE_C_STANDARD}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
-DCMAKE_CXX_STANDARD_REQUIRED=${CMAKE_CXX_STANDARD_REQUIRED}
-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}
-DCMAKE_EXPORT_COMPILE_COMMANDS=${CMAKE_EXPORT_COMPILE_COMMANDS}
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
)

set(HE_QAT_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}) set(
HE_QAT_SRC_DIR ${HE_QAT_ROOT_DIR} /
he_qat) set(HE_QAT_INC_DIR ${HE_QAT_ROOT_DIR} / he_qat /
include)

#OpenSSL installation
set(OPENSSL_INC_DIR / opt / openssl /
include) set(OPENSSL_LIB_DIR / opt / openssl / lib)

set(COMMON_INC_DIR ${CMAKE_CURRENT_LIST_DIR} / include)

set(CMAKE_INSTALL_PREFIX "install")

#QAT lib installation
set(ICP_ROOT $ENV{ICP_ROOT}) set(
ICP_BUILDOUTPUT_PATH ${ICP_ROOT} /
build) set(ICP_BUILDSYSTEM_PATH ${
ICP_ROOT} /
quickassist /
build_system) set(ICP_API_DIR ${
ICP_ROOT} /
quickassist)
set(ICP_LAC_DIR ${ICP_ROOT} / quickassist /
lookaside /
access_layer) set(ICP_OSAL_DIR ${
ICP_ROOT} /
quickassist /
utilities / oasl)
set(ICP_ADF_DIR ${ICP_ROOT} /
quickassist / lookaside /
access_layer / src /
qat_direct) set(CMN_ROOT ${
ICP_ROOT} /
quickassist /
utilities /
libusdm_drv)

list(APPEND COMMON_INC_DIR ${
ICP_API_DIR} /
include ${ICP_LAC_DIR} /
include ${ICP_ADF_DIR} /
include ${CMN_ROOT})

#Macros for the test case
add_definitions(-DDO_CRYPTO) add_definitions(
-DUSER_SPACE) add_compile_options(-fPIC)
if(NOT HE_QAT_SHARED)
set(OPENSSL_USE_STATIC_LIBS TRUE)
message(STATUS "OPENSSL_USE_STATIC_LIBS TRUE")
else()
message(STATUS "OPENSSL_USE_STATIC_LIBS FALSE")
endif()
find_package(OpenSSL REQUIRED)

# External dependencies
find_package(Threads REQUIRED)
set(CMAKE_THREAD_PREFER_PTHREAD ON)
set(THREADS_PREFER_PTHREAD_FLAG ON)
#set(OPENSSL_INC_DIR /opt/openssl/include)
#set(OPENSSL_LIB_DIR /opt/openssl/lib)

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/he_qat)
include(heqat-util)

set(COMMON_INC_DIR ${CMAKE_CURRENT_LIST_DIR}/include)
if(NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR}/install)
endif()

# Include QAT lib API support
include(icp/CMakeLists.txt)

#Common utility functions
add_subdirectory(common)

#IPP Crypto installation
set(IPPCP_DIR
"/opt/ipp-crypto")
set(IPPCP_CMAKE_PREFIX_DIR
"${IPPCP_DIR}/"
"lib/cmake")
list(
APPEND
CMAKE_PREFIX_PATH
"${IPPCP_"
"CMAKE_"
"PREFIX_"
"DIR}")
find_package(
ippcp
REQUIRED)

#Helper functions
#set(HE_QAT_MISC_INC_DIR ${COMMON_INC_DIR} ${CMAKE_CURRENT_LIST_DIR})
#set(HE_QAT_MISC_INC_DIR ${COMMON_INC_DIR})
#set(HE_QAT_MISC_SRC ${HE_QAT_SRC_DIR} / he_qat_misc.cpp)
add_subdirectory(
misc)

#Library
add_subdirectory(
he_qat)
add_subdirectory(common)

# Helper functions for BigNumber
if(HE_QAT_MISC)
add_subdirectory(misc)
endif()

# HE_QAT Library
add_subdirectory(he_qat)

if(HE_QAT_TEST)
include(cmake/gtest.cmake)
endif()
if(HE_QAT_BENCHMARK)
include(cmake/gbenchmark.cmake)
endif()

#Validation test examples
add_subdirectory(
examples)
if(HE_QAT_SAMPLES)
add_subdirectory(samples)
endif()

if(HE_QAT_TEST)
add_subdirectory(test)
add_custom_target(unittest COMMAND $<TARGET_FILE:he_qat_unittest> DEPENDS he_qat_unittest)
endif()

if(HE_QAT_BENCHMARK)
add_subdirectory(benchmark)
add_custom_target(benchmark COMMAND $<TARGET_FILE:he_qat_bench> DEPENDS he_qat_bench)
endif()

if(HE_QAT_DOCS)
add_subdirectory(docs)
endif()



Loading

0 comments on commit 2d027ca

Please sign in to comment.