Skip to content

Commit

Permalink
add IAA gzip codec
Browse files Browse the repository at this point in the history
  • Loading branch information
marin-ma committed Nov 17, 2023
1 parent ea5785b commit 5a56d2f
Show file tree
Hide file tree
Showing 9 changed files with 668 additions and 2 deletions.
56 changes: 56 additions & 0 deletions CMake/Findqpl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
include(ExternalProject)

macro(build_qpl)
message(STATUS "Building QPL from source")
set(QPL_BUILD_VERSION "v1.3.1")
set(QPL_BUILD_SHA256_CHECKSUM
"6ae537f9b84c222212e1ca8edaa275d1e1923d179a691353da38856ed8f4e5c4")
set(QPL_SOURCE_URL
"https://github.com/intel/qpl/archive/refs/tags/v1.3.1.tar.gz")
set(QPL_LIB_NAME "qpl")

set(QPL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/qpl_ep-install")
set(QPL_SOURCE_DIR "${QPL_PREFIX}/src/qpl_ep")
set(QPL_INCLUDE_DIR "${QPL_PREFIX}/include")
set(QPL_LIB_DIR "${QPL_PREFIX}/lib")
set(QPL_STATIC_LIB_NAME
"${CMAKE_STATIC_LIBRARY_PREFIX}${QPL_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}${QPL_STATIC_LIB_MAJOR_VERSION}"
)
set(QPL_STATIC_LIB_TARGETS "${QPL_LIB_DIR}/${QPL_STATIC_LIB_NAME}")
ExternalProject_Add(
qpl_ep
PREFIX ${QPL_PREFIX}
URL ${QPL_SOURCE_URL}
URL_HASH "SHA256=${QPL_BUILD_SHA256_CHECKSUM}"
SOURCE_DIR ${QPL_SOURCE_DIR}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${QPL_PREFIX}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DQPL_BUILD_TESTS=OFF
-DLOG_HW_INIT=ON
BUILD_BYPRODUCTS ${QPL_STATIC_LIB_TARGETS})

# The include directory must exist before it is referenced by a target.
file(MAKE_DIRECTORY "${QPL_INCLUDE_DIR}")

add_library(qpl::qpl STATIC IMPORTED)
set_target_properties(
qpl::qpl
PROPERTIES IMPORTED_LOCATION "${QPL_LIB_DIR}/${QPL_STATIC_LIB_NAME}"
INTERFACE_INCLUDE_DIRECTORIES "${QPL_INCLUDE_DIR}")

add_dependencies(qpl::qpl qpl_ep)
endmacro()

build_qpl()
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ if(VELOX_ENABLE_REMOTE_FUNCTIONS)
find_package(FBThrift CONFIG REQUIRED)
endif()

if(VELOX_ENABLE_IAA)
find_package(qpl REQUIRED)
add_definitions(-DVELOX_ENABLE_IAA)
endif()

# define processor variable for conditional compilation
if(${VELOX_CODEGEN_SUPPORT})
add_compile_definitions(CODEGEN_ENABLED=1)
Expand Down
4 changes: 4 additions & 0 deletions velox/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,7 @@ endif()
if(${VELOX_ENABLE_SUBSTRAIT})
add_subdirectory(substrait)
endif()

if(${VELOX_ENABLE_IAA})
add_subdirectory(common/compression/v2/iaa)
endif()
13 changes: 11 additions & 2 deletions velox/common/compression/v2/Compression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include "velox/common/compression/v2/SnappyCompression.h"
#include "velox/common/compression/v2/ZstdCompression.h"

#ifdef VELOX_ENABLE_IAA
#include "velox/common/compression/v2/iaa/IaaCompression.h"
#endif

namespace facebook::velox::common {

namespace {
Expand Down Expand Up @@ -127,11 +131,16 @@ std::unique_ptr<Codec> Codec::create(
codec = makeLz4HadoopRawCodec();
break;
case CompressionKind::CompressionKind_GZIP: {
auto opt = dynamic_cast<const GzipCodecOptions*>(&codecOptions);
if (opt) {
if (auto opt = dynamic_cast<const GzipCodecOptions*>(&codecOptions)) {
codec = makeGzipCodec(compressionLevel, opt->format, opt->windowBits);
break;
}
#ifdef VELOX_ENABLE_IAA
if (auto opt =
dynamic_cast<const iaa::IaaGzipCodecOptions*>(&codecOptions)) {
codec = iaa::makeIaaGzipCodec(compressionLevel, opt->maxJobNumber);
}
#endif
codec = makeGzipCodec(compressionLevel);
break;
}
Expand Down
17 changes: 17 additions & 0 deletions velox/common/compression/v2/iaa/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

target_sources(velox_common_compression_v2 PRIVATE IaaCompression.cpp
QplJobPool.cpp)
target_link_libraries(velox_common_compression_v2 qpl::qpl)
Loading

0 comments on commit 5a56d2f

Please sign in to comment.