Skip to content

Commit

Permalink
HElib v2.2.1
Browse files Browse the repository at this point in the history
* Improved NTT bechmark code
* CI update
* Improvements to partial match logic
* Bug fixes

Co-authored-by: Fabian Boemer <[email protected]>
Co-authored-by: Jack Crawford <[email protected]>
Co-authored-by: Hamish Hunt <[email protected]>
  • Loading branch information
4 people authored Oct 1, 2021
2 parents ca470eb + e69aa98 commit f0e3e01
Show file tree
Hide file tree
Showing 10 changed files with 202 additions and 159 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/github-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright (C) 2021 Intel Corporation
# 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.

name: helib
on:
# By default this will run when the activity type is "opened", "synchronize",
# or "reopened".
pull_request:
branches:
- master
# Manually run this workflow on any specified branch.
workflow_dispatch:


###################
# Define env vars #
###################
env:
INSTALL_PREFIX: $GITHUB_WORKSPACE

jobs:
library_build:
runs-on: '${{ matrix.os }}'
name: 'os=${{ matrix.os }} package_build=${{ matrix.package_build }} hexl=${{ matrix.hexl }} compiler=${{ matrix.cxx_compiler}}'
defaults:
run:
shell: bash
strategy:
matrix:
# TODO: shared builds
package_build: [ON, OFF]
hexl: [ON, OFF]
c_compiler: [gcc, clang]
os: [macos-latest, ubuntu-20.04]
include: # Use g++ with gcc only and clang++ with clang only
- c_compiler: gcc
cxx_compiler: g++
- c_compiler: clang
cxx_compiler: clang++
exclude: # Skip HEXL package build
- package_build: ON
hexl: ON
steps:
- uses: actions/checkout@v2
- run: |
set -x
env
./ci/install_deps.sh "${{ matrix.package_build }}" "${{ matrix.os }}" \
"${{ matrix.c_compiler }}" "${{ matrix.cxx_compiler }}" "${{ matrix.hexl }}"
./ci/build_install_lib.sh "${{ matrix.package_build }}" ${{ env.INSTALL_PREFIX }} \
${{ matrix.c_compiler }} ${{ matrix.cxx_compiler }} \
${{ matrix.hexl }} "./hexl/lib/cmake/hexl-1.2.1"
./ci/test_lib.sh
./ci/build_test_consumer.sh "examples" "${{ matrix.package_build }}" ${{ env.INSTALL_PREFIX }}
./ci/build_test_consumer.sh "utils" "${{ matrix.package_build }}" ${{ env.INSTALL_PREFIX }}
114 changes: 0 additions & 114 deletions .travis.yml

This file was deleted.

9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Release Changes
===============

HElib 2.2.1, October 2021
=========================
(tagged as v2.2.1)

* Improved NTT bechmark code
* CI update
* Improvements to partial match logic
* Bug fixes

HElib 2.2.0, September 2021
=========================
(tagged as v2.2.0)
Expand Down
11 changes: 5 additions & 6 deletions benchmarks/fft_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ static void helib_fft_forward(benchmark::State& state, Meta& meta)
long q = prime_generator.next();
helib::Cmodulus cmod(zms, q, 0);

NTL::ZZX poly;
poly.SetLength(N);
for (long i = 0; i < N; ++i)
poly[i] = i;
NTL::zz_pX poly(N, 1);

NTL::vec_long transformed;
for (auto _ : state)
NTL::vec_long transformed(NTL::INIT_SIZE, N);

for (auto _ : state) {
cmod.FFT(transformed, poly);
}
}

static void helib_fft_inverse(benchmark::State& state, Meta& meta)
Expand Down
30 changes: 27 additions & 3 deletions ci/build_install_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,45 @@
# See the License for the specific language governing permissions and
# limitations under the License. See accompanying LICENSE file.

# Copyright (C) 2021 Intel Corporation
# 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.

set -xe

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

PACKAGE_BUILD="${1}"
CMAKE_INSTALL_PREFIX="${2}"
C_COMPILER="${3}"
CXX_COMPILER="${4}"
USE_INTEL_HEXL="${5}"
INTEL_HEXL_DIR="${6}"
ROOT_DIR="$(pwd)"

mkdir build
cd build
# We assume PACKAGE_BUILD argument to be a valid cmake option
cmake -DPACKAGE_BUILD="${PACKAGE_BUILD}" -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}" -DBUILD_SHARED=ON -DENABLE_TEST=ON -DTARGET_ARCHITECTURE=x86-64 ..
cmake -DPACKAGE_BUILD="${PACKAGE_BUILD}" \
-DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}" \
-DUSE_INTEL_HEXL="${USE_INTEL_HEXL}" \
-DCMAKE_C_COMPILER="${C_COMPILER}" \
-DCMAKE_CXX_COMPILER="${CXX_COMPILER}" \
-DHEXL_DIR="${INTEL_HEXL_DIR}" \
-DBUILD_SHARED=OFF \
-DENABLE_TEST=ON \
-DTARGET_ARCHITECTURE=x86-64 \
..
make -j4 VERBOSE=1
make install
cd "${ROOT_DIR}"
63 changes: 40 additions & 23 deletions ci/install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,50 @@
# See the License for the specific language governing permissions and
# limitations under the License. See accompanying LICENSE file.

# Copyright (C) 2021 Intel Corporation
# 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.

set -xe

if [ "$#" -ne 5 ]; then
echo "Wrong parameter number. Usage ./${0} <PACKAGE_BUILD> <RUNNER_OS> <C_COMPILER> <CXX_COMPILER> <USE_INTEL_HEXL>"
exit 1
fi

PACKAGE_BUILD="${1}"
RUNNER_OS="${2}"
C_COMPILER="${3}"
CXX_COMPILER="${4}"
USE_INTEL_HEXL="${5}"

if [ "${USE_INTEL_HEXL}" == "ON" ]; then
git clone https://github.com/intel/hexl.git -b v1.2.1
cd hexl
cmake -B build \
-DCMAKE_INSTALL_PREFIX=./ \
-DHEXL_SHARED_LIB=OFF \
-DCMAKE_C_COMPILER="${C_COMPILER}" \
-DCMAKE_CXX_COMPILER="${CXX_COMPILER}"
cmake --build build -j4 --target install
cd ../
fi

cd $HOME

if [ "${PACKAGE_BUILD}" == "OFF" ]; then
if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
if [ "${TRAVIS_DIST}" == "bionic" ]; then
sudo apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install m4 libgmp-dev
curl -O "https://libntl.org/ntl-11.4.3.tar.gz"
tar --no-same-owner -xf ntl-11.4.3.tar.gz
cd "$HOME/ntl-11.4.3/src"
./configure SHARED=on NTL_GMP_LIP=on NTL_THREADS=on NTL_THREAD_BOOST=on
make -j4
sudo make install
else
sudo apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install libgmp-dev libntl-dev
fi
elif [ "${TRAVIS_OS_NAME}" == "osx" ]; then
# GMP will be installed as a dependency to NTL (if it is not already present)
brew install ntl
fi
else
if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
sudo apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install patchelf m4
elif [ "${TRAVIS_OS_NAME}" == "osx" ]; then
brew install m4
fi
if [ "${RUNNER_OS}" == "ubuntu-20.04" ]; then
sudo apt-get -yq --no-install-suggests --no-install-recommends install libgmp-dev libntl-dev bats
fi

if [ "${RUNNER_OS}" == "macos-latest" ]; then
brew install ntl
fi

cd "$HOME"
17 changes: 17 additions & 0 deletions include/helib/CModulus.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@
* See the License for the specific language governing permissions and
* limitations under the License. See accompanying LICENSE file.
*/

/* Intel HEXL integration.
* Copyright (C) 2021 Intel Corporation
* 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.
*/

#ifndef HELIB_CMODULUS_H
#define HELIB_CMODULUS_H
/**
Expand Down Expand Up @@ -123,6 +137,9 @@ class Cmodulus
void FFT(NTL::vec_long& y, const NTL::ZZX& x) const;
// y = FFT(x)
void FFT(NTL::vec_long& y, const zzX& x) const;
// y = FFT(x)
void FFT(NTL::vec_long& y, NTL::zz_pX& x) const;


// expects zp context to be set externally
// x = FFT^{-1}(y)
Expand Down
Loading

0 comments on commit f0e3e01

Please sign in to comment.