Skip to content

Commit f0e3e01

Browse files
fabergafboemerjlhcrawfordhamishun
authored
HElib v2.2.1
* Improved NTT bechmark code * CI update * Improvements to partial match logic * Bug fixes Co-authored-by: Fabian Boemer <fabian.boemer@intel.com> Co-authored-by: Jack Crawford <jack.crawford@sky.com> Co-authored-by: Hamish Hunt <hamishun@gmail.com>
2 parents ca470eb + e69aa98 commit f0e3e01

File tree

10 files changed

+202
-159
lines changed

10 files changed

+202
-159
lines changed

.github/workflows/github-ci.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Copyright (C) 2021 Intel Corporation
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS,
8+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
# See the License for the specific language governing permissions and
10+
# limitations under the License.
11+
12+
name: helib
13+
on:
14+
# By default this will run when the activity type is "opened", "synchronize",
15+
# or "reopened".
16+
pull_request:
17+
branches:
18+
- master
19+
# Manually run this workflow on any specified branch.
20+
workflow_dispatch:
21+
22+
23+
###################
24+
# Define env vars #
25+
###################
26+
env:
27+
INSTALL_PREFIX: $GITHUB_WORKSPACE
28+
29+
jobs:
30+
library_build:
31+
runs-on: '${{ matrix.os }}'
32+
name: 'os=${{ matrix.os }} package_build=${{ matrix.package_build }} hexl=${{ matrix.hexl }} compiler=${{ matrix.cxx_compiler}}'
33+
defaults:
34+
run:
35+
shell: bash
36+
strategy:
37+
matrix:
38+
# TODO: shared builds
39+
package_build: [ON, OFF]
40+
hexl: [ON, OFF]
41+
c_compiler: [gcc, clang]
42+
os: [macos-latest, ubuntu-20.04]
43+
include: # Use g++ with gcc only and clang++ with clang only
44+
- c_compiler: gcc
45+
cxx_compiler: g++
46+
- c_compiler: clang
47+
cxx_compiler: clang++
48+
exclude: # Skip HEXL package build
49+
- package_build: ON
50+
hexl: ON
51+
steps:
52+
- uses: actions/checkout@v2
53+
- run: |
54+
set -x
55+
env
56+
./ci/install_deps.sh "${{ matrix.package_build }}" "${{ matrix.os }}" \
57+
"${{ matrix.c_compiler }}" "${{ matrix.cxx_compiler }}" "${{ matrix.hexl }}"
58+
./ci/build_install_lib.sh "${{ matrix.package_build }}" ${{ env.INSTALL_PREFIX }} \
59+
${{ matrix.c_compiler }} ${{ matrix.cxx_compiler }} \
60+
${{ matrix.hexl }} "./hexl/lib/cmake/hexl-1.2.1"
61+
./ci/test_lib.sh
62+
./ci/build_test_consumer.sh "examples" "${{ matrix.package_build }}" ${{ env.INSTALL_PREFIX }}
63+
./ci/build_test_consumer.sh "utils" "${{ matrix.package_build }}" ${{ env.INSTALL_PREFIX }}

.travis.yml

Lines changed: 0 additions & 114 deletions
This file was deleted.

CHANGES.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Release Changes
22
===============
33

4+
HElib 2.2.1, October 2021
5+
=========================
6+
(tagged as v2.2.1)
7+
8+
* Improved NTT bechmark code
9+
* CI update
10+
* Improvements to partial match logic
11+
* Bug fixes
12+
413
HElib 2.2.0, September 2021
514
=========================
615
(tagged as v2.2.0)

benchmarks/fft_bench.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,13 @@ static void helib_fft_forward(benchmark::State& state, Meta& meta)
3434
long q = prime_generator.next();
3535
helib::Cmodulus cmod(zms, q, 0);
3636

37-
NTL::ZZX poly;
38-
poly.SetLength(N);
39-
for (long i = 0; i < N; ++i)
40-
poly[i] = i;
37+
NTL::zz_pX poly(N, 1);
4138

42-
NTL::vec_long transformed;
43-
for (auto _ : state)
39+
NTL::vec_long transformed(NTL::INIT_SIZE, N);
40+
41+
for (auto _ : state) {
4442
cmod.FFT(transformed, poly);
43+
}
4544
}
4645

4746
static void helib_fft_inverse(benchmark::State& state, Meta& meta)

ci/build_install_lib.sh

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,45 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License. See accompanying LICENSE file.
1313

14+
# Copyright (C) 2021 Intel Corporation
15+
# Licensed under the Apache License, Version 2.0 (the "License");
16+
# you may not use this file except in compliance with the License.
17+
# You may obtain a copy of the License at
18+
# http://www.apache.org/licenses/LICENSE-2.0
19+
# Unless required by applicable law or agreed to in writing, software
20+
# distributed under the License is distributed on an "AS IS" BASIS,
21+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
# See the License for the specific language governing permissions and
23+
# limitations under the License.
24+
1425
set -xe
1526

16-
if [ "$#" -ne 2 ]; then
17-
echo "Wrong parameter number. Usage ./${0} <PACKAGE_BUILD> <CMAKE_INSTALL_PREFIX>"
27+
if [ "$#" -ne 6 ]; then
28+
echo "Wrong parameter number. Usage ./${0} <PACKAGE_BUILD> <CMAKE_INSTALL_PREFIX> <C_COMPILER> <CXX_COMPILER> <USE_INTEL_HEXL> <INTEL_HEXL_DIR>"
1829
exit 1
1930
fi
2031

2132
PACKAGE_BUILD="${1}"
2233
CMAKE_INSTALL_PREFIX="${2}"
34+
C_COMPILER="${3}"
35+
CXX_COMPILER="${4}"
36+
USE_INTEL_HEXL="${5}"
37+
INTEL_HEXL_DIR="${6}"
2338
ROOT_DIR="$(pwd)"
2439

2540
mkdir build
2641
cd build
2742
# We assume PACKAGE_BUILD argument to be a valid cmake option
28-
cmake -DPACKAGE_BUILD="${PACKAGE_BUILD}" -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}" -DBUILD_SHARED=ON -DENABLE_TEST=ON -DTARGET_ARCHITECTURE=x86-64 ..
43+
cmake -DPACKAGE_BUILD="${PACKAGE_BUILD}" \
44+
-DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}" \
45+
-DUSE_INTEL_HEXL="${USE_INTEL_HEXL}" \
46+
-DCMAKE_C_COMPILER="${C_COMPILER}" \
47+
-DCMAKE_CXX_COMPILER="${CXX_COMPILER}" \
48+
-DHEXL_DIR="${INTEL_HEXL_DIR}" \
49+
-DBUILD_SHARED=OFF \
50+
-DENABLE_TEST=ON \
51+
-DTARGET_ARCHITECTURE=x86-64 \
52+
..
2953
make -j4 VERBOSE=1
3054
make install
3155
cd "${ROOT_DIR}"

ci/install_deps.sh

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,50 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License. See accompanying LICENSE file.
1313

14+
# Copyright (C) 2021 Intel Corporation
15+
# Licensed under the Apache License, Version 2.0 (the "License");
16+
# you may not use this file except in compliance with the License.
17+
# You may obtain a copy of the License at
18+
# http://www.apache.org/licenses/LICENSE-2.0
19+
# Unless required by applicable law or agreed to in writing, software
20+
# distributed under the License is distributed on an "AS IS" BASIS,
21+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
# See the License for the specific language governing permissions and
23+
# limitations under the License.
24+
1425
set -xe
1526

27+
if [ "$#" -ne 5 ]; then
28+
echo "Wrong parameter number. Usage ./${0} <PACKAGE_BUILD> <RUNNER_OS> <C_COMPILER> <CXX_COMPILER> <USE_INTEL_HEXL>"
29+
exit 1
30+
fi
31+
32+
PACKAGE_BUILD="${1}"
33+
RUNNER_OS="${2}"
34+
C_COMPILER="${3}"
35+
CXX_COMPILER="${4}"
36+
USE_INTEL_HEXL="${5}"
37+
38+
if [ "${USE_INTEL_HEXL}" == "ON" ]; then
39+
git clone https://github.com/intel/hexl.git -b v1.2.1
40+
cd hexl
41+
cmake -B build \
42+
-DCMAKE_INSTALL_PREFIX=./ \
43+
-DHEXL_SHARED_LIB=OFF \
44+
-DCMAKE_C_COMPILER="${C_COMPILER}" \
45+
-DCMAKE_CXX_COMPILER="${CXX_COMPILER}"
46+
cmake --build build -j4 --target install
47+
cd ../
48+
fi
49+
1650
cd $HOME
1751

18-
if [ "${PACKAGE_BUILD}" == "OFF" ]; then
19-
if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
20-
if [ "${TRAVIS_DIST}" == "bionic" ]; then
21-
sudo apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install m4 libgmp-dev
22-
curl -O "https://libntl.org/ntl-11.4.3.tar.gz"
23-
tar --no-same-owner -xf ntl-11.4.3.tar.gz
24-
cd "$HOME/ntl-11.4.3/src"
25-
./configure SHARED=on NTL_GMP_LIP=on NTL_THREADS=on NTL_THREAD_BOOST=on
26-
make -j4
27-
sudo make install
28-
else
29-
sudo apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install libgmp-dev libntl-dev
30-
fi
31-
elif [ "${TRAVIS_OS_NAME}" == "osx" ]; then
32-
# GMP will be installed as a dependency to NTL (if it is not already present)
33-
brew install ntl
34-
fi
35-
else
36-
if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
37-
sudo apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install patchelf m4
38-
elif [ "${TRAVIS_OS_NAME}" == "osx" ]; then
39-
brew install m4
40-
fi
52+
if [ "${RUNNER_OS}" == "ubuntu-20.04" ]; then
53+
sudo apt-get -yq --no-install-suggests --no-install-recommends install libgmp-dev libntl-dev bats
54+
fi
55+
56+
if [ "${RUNNER_OS}" == "macos-latest" ]; then
57+
brew install ntl
4158
fi
4259

4360
cd "$HOME"

include/helib/CModulus.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@
99
* See the License for the specific language governing permissions and
1010
* limitations under the License. See accompanying LICENSE file.
1111
*/
12+
13+
/* Intel HEXL integration.
14+
* Copyright (C) 2021 Intel Corporation
15+
* Licensed under the Apache License, Version 2.0 (the "License");
16+
* you may not use this file except in compliance with the License.
17+
* You may obtain a copy of the License at
18+
* http://www.apache.org/licenses/LICENSE-2.0
19+
* Unless required by applicable law or agreed to in writing, software
20+
* distributed under the License is distributed on an "AS IS" BASIS,
21+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
* See the License for the specific language governing permissions and
23+
* limitations under the License.
24+
*/
25+
1226
#ifndef HELIB_CMODULUS_H
1327
#define HELIB_CMODULUS_H
1428
/**
@@ -123,6 +137,9 @@ class Cmodulus
123137
void FFT(NTL::vec_long& y, const NTL::ZZX& x) const;
124138
// y = FFT(x)
125139
void FFT(NTL::vec_long& y, const zzX& x) const;
140+
// y = FFT(x)
141+
void FFT(NTL::vec_long& y, NTL::zz_pX& x) const;
142+
126143

127144
// expects zp context to be set externally
128145
// x = FFT^{-1}(y)

0 commit comments

Comments
 (0)