Skip to content
This repository was archived by the owner on Dec 25, 2023. It is now read-only.

Commit a7cec19

Browse files
authored
added experimental integration with external libraries (#16)
* added experimental bridge to integrate with seal * minor update * update the README.md * added ci for experimental tests * use gbenchmark v1.6.1 * fix hexl-fpga install path
1 parent f3563f5 commit a7cec19

File tree

14 files changed

+862
-1
lines changed

14 files changed

+862
-1
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,31 @@ jobs:
9696
source /disk1/tools/new_env_setup.sh
9797
cd build-examples
9898
RUN_CHOICE=1 make examples
99+
100+
- name: build_experimental_bridges
101+
run: |
102+
pushd experimental/bridge-seal
103+
cmake -S . -B build-seal4.0.0-fpga -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(realpath ${PWD}/../../build/install)" -DCMAKE_INSTALL_PREFIX=seal-fpga-install
104+
cmake --build build-seal4.0.0-fpga -j
105+
popd
106+
107+
- name: build_experimental_tests
108+
run: |
109+
pushd experimental/bridge-seal/tests
110+
cmake -S . -B build -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(realpath ${PWD}/../../../build/install);$(realpath ${PWD}/../seal-fpga-install)"
111+
cmake --build build -j
112+
popd
113+
114+
- name: run_experimental_tests
115+
run: |
116+
source /disk1/tools/init_env.sh
117+
source /disk1/tools/new_env_setup.sh
118+
pushd experimental/bridge-seal/tests/build
119+
echo "Run experimental tests with FPGA bitstream"
120+
export FPGA_DATA_DIR="/disk1/hexl-fpga-data"
121+
export FPGA_BITSTREAM_DIR="${FPGA_DATA_DIR}/bitstreams"
122+
make seal_test
123+
echo "Run experimental tests with emulation"
124+
export FPGA_BITSTREAM_DIR=
125+
RUN_CHOICE=1 make seal_test
126+
popd

cmake/gbenchmark/CMakeLists.txt.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ project(google-benchmark-download NONE)
88
include(ExternalProject)
99
ExternalProject_Add(gbenchmark
1010
GIT_REPOSITORY https://github.com/google/benchmark.git
11-
GIT_TAG main
11+
GIT_TAG v1.6.1
1212
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/gbenchmark-src"
1313
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/gbenchmark-build"
1414
CONFIGURE_COMMAND ""

experimental/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Experimental integration of Intel HE Acceleration Library for FPGAs with external libraries
2+
3+
## Disclaimer: The experimental integration provides sample code to integrate with external libraries. It is for experiments only. You are free to use it at your own risk. Developers bear no liability.
4+
5+
After installing Intel HE Acceleration Library for FPGAs, you can use the library to accelerate operations in an external library in the following way.
6+
7+
## Experimental integration with Microsoft SEAL
8+
The experimental integration of Intel HE Acceleration Library for FPGAs with Microsoft SEAL depends on:
9+
10+
- [Microsoft SEAL version v4.0.0](https://github.com/microsoft/SEAL/tree/v4.0.0)
11+
- [Intel HEXL version v1.2.4](https://github.com/intel/hexl/tree/v1.2.4)
12+
13+
Details on Microsoft SEAL integration can be found at [bridge-seal/README.md](bridge-seal/README.md)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (C) 2020-2021 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.13)
5+
6+
project(seal_bridge VERSION 4.0.0 LANGUAGES CXX)
7+
8+
include(cmake/hexl.cmake)
9+
include(cmake/seal.cmake)

experimental/bridge-seal/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Experimental integration of Intel HE Acceleration Library for FPGAs with Microsoft SEAL
2+
3+
## Disclaimer: The experimental integration provides sample code to integrate with external libraries. It is for experiments only. You are free to use it at your own risk. Developers bear no liability of any form.
4+
5+
After installing Intel HE Acceleration Library for FPGAs, you can use the library to accelerate operations in an external library in the following way.
6+
7+
## Experimental integration with [Microsoft SEAL v4.0.0](https://github.com/microsoft/SEAL/tree/v4.0.0)
8+
9+
The integration with Microsoft SEAL is through a patch. To build SEAL library accelerated with Intel HE Acceleration Library for FPGAs, point ${CMAKE_PREFIX_PATH} to the pre-installed Intel HE Acceleration Library for FPGAs package.
10+
```
11+
cmake -S . -B build-seal4.0.0-fpga -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(realpath ${PWD}/../../hexl-fpga-install)" -DCMAKE_INSTALL_PREFIX=seal-fpga-install
12+
cmake --build build-seal4.0.0-fpga -j
13+
```
14+
15+
## Validate the integration
16+
After building the SEAL library that is accelerated with Intel HE Acceleration Library for FPGAS, the integration can be validated with *tests/keyswitch-example.cpp*.
17+
18+
### Compile the SEAL-based test that accelerated with Intel HE Acceleration Library for FPGAs.
19+
```
20+
pushd tests
21+
cmake -S . -B build -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(realpath ${PWD}/../../../hexl-fpga-install);$(realpath ${PWD}/../seal-fpga-install)"
22+
cmake --build build -j
23+
popd
24+
```
25+
26+
The compiled executable is located in *tests/build* directory.
27+
28+
### Run the test on a FPGA card
29+
```
30+
pushd tests/build
31+
rm -f keyswitch.aocx
32+
ln -s /path-to-fpga-bitstreams/keyswitch.aocx .
33+
RUN_CHOICE=2 make seal_test
34+
popd
35+
```
36+
37+
### Run the test on emulation
38+
```
39+
pushd tests/build
40+
rm -f keyswitch.aocx
41+
ln -s /path-to-emulation/keyswitch.aocx .
42+
RUN_CHOICE=1 make seal_test
43+
popd
44+
```
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright (C) 2020-2021 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
include(ExternalProject)
5+
6+
set(HEXL_GIT_REPO_URL https://github.com/intel/hexl.git)
7+
set(HEXL_GIT_LABEL v1.2.4)
8+
9+
ExternalProject_Add(
10+
ext_hexl
11+
PREFIX ext_hexl
12+
GIT_REPOSITORY ${HEXL_GIT_REPO_URL}
13+
GIT_TAG ${HEXL_GIT_LABEL}
14+
CMAKE_ARGS
15+
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
16+
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
17+
-DCMAKE_INSTALL_LIBDIR=lib
18+
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
19+
-DHEXL_SHARED_LIB=ON
20+
-DHEXL_BENCHMARK=OFF
21+
-DHEXL_TESTING=OFF
22+
-DHEXL_EXPERIMENTAL=ON
23+
-DHEXL_FPGA_COMPATIBILITY=2
24+
EXCLUDE_FROM_ALL TRUE
25+
UPDATE_COMMAND "")
26+
27+
ExternalProject_Get_Property(ext_hexl SOURCE_DIR BINARY_DIR)
28+
29+
set(INTEL_HEXL_HINT_DIR ${CMAKE_INSTALL_PREFIX}/lib/cmake)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright (C) 2020-2021 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
include(ExternalProject)
5+
6+
set(SEAL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/ext_seal)
7+
set(SEAL_SRC_DIR ${SEAL_PREFIX}/src/ext_seal/)
8+
9+
set(SEAL_REPO_URL https://github.com/microsoft/SEAL.git)
10+
set(SEAL_GIT_TAG v4.0.0)
11+
12+
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}/lib/cmake)
13+
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}/share/cmake)
14+
string(REPLACE ";" "|" CMAKE_PREFIX_PATH_ALT_SEP "${CMAKE_PREFIX_PATH}")
15+
16+
ExternalProject_Add(
17+
ext_seal
18+
GIT_REPOSITORY ${SEAL_REPO_URL}
19+
GIT_TAG ${SEAL_GIT_TAG}
20+
PREFIX ${SEAL_PREFIX}
21+
INSTALL_DIR ${SEAL_PREFIX}
22+
LIST_SEPARATOR |
23+
CMAKE_ARGS ${BENCHMARK_FORWARD_CMAKE_ARGS}
24+
-DSEAL_BUILD_DEPS=OFF
25+
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
26+
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH_ALT_SEP}
27+
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
28+
-DCMAKE_INSTALL_LIBDIR=lib
29+
-DCMAKE_INSTALL_INCLUDEDIR=include
30+
-DSEAL_USE_INTEL_HEXL=ON
31+
-DSEAL_USE_INTEL_HEXL_FPGA=ON
32+
-DBUILD_SHARED_LIBS=ON
33+
-DSEAL_USE_ZSTD=OFF
34+
-DSEAL_USE_ZLIB=OFF
35+
-DSEAL_USE_MSGSL=OFF
36+
-DSEAL_BUILD_EXAMPLES=OFF
37+
PATCH_COMMAND git apply ${CMAKE_SOURCE_DIR}/patches/hexl-fpga-BRIDGE-seal-4.0.0.patch
38+
UPDATE_COMMAND ""
39+
DEPENDS ext_hexl)
40+
41+
ExternalProject_Get_Property(ext_seal SOURCE_DIR BINARY_DIR)
42+
43+
add_library(libseal INTERFACE)
44+
add_dependencies(libseal ext_seal)
45+
target_include_directories(libseal INTERFACE ${SEAL_PREFIX}/include/SEAL-4.0)
46+
target_link_libraries(libseal INTERFACE ${SEAL_PREFIX}/lib/libseal.so.4.0)

0 commit comments

Comments
 (0)