-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathrunners.sh
89 lines (76 loc) · 3.25 KB
/
runners.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Copyright (C) 2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
HEKIT_DIR="$HOME/.hekit/components"
HEKIT_EXAMPLES="$HEKIT_DIR/examples"
HEKIT_SAMPLE_KERNELS="$HEKIT_DIR/sample-kernels"
__run_cmd() {
(
set -e
eval "$@"
)
}
run_lr_example() {
(
set -e
cd "$HEKIT_EXAMPLES/logistic-regression/build"
OMP_NUM_THREADS="$(nproc)" ./lr_test "$@"
)
}
run_psi_example() {
__run_cmd "$HEKIT_EXAMPLES"/psi/build/psi --server "$HEKIT_EXAMPLES"/psi/build/datasets/fruits.set "$@"
}
run_query_example() {
(
echo -n "Initialize SEAL BFV scheme with default parameters[Y(default)|N]: "
read -r params
echo -n "Input file to use for database or press enter to use default[us_state_capitals.csv]: "
read -r database
echo -n "Input key value to use for database query: "
read -r query
set -e
OMP_NUM_THREADS="$(nproc)" "$HEKIT_EXAMPLES"/secure-query/build/secure-query <<- EOF
${params}
${database}
${query}
EOF
)
}
run_sample_kernels_palisade() {
__run_cmd KMP_WARNINGS=0 OMP_NUM_THREADS="$(nproc)" "$HEKIT_SAMPLE_KERNELS"/palisade/build/sample-kernels-palisade --benchmark_min_time=2
}
run_sample_kernels_seal() {
__run_cmd KMP_WARNINGS=0 OMP_NUM_THREADS="$(nproc)" "$HEKIT_SAMPLE_KERNELS"/seal/build/sample-kernels-seal --benchmark_min_time=2
}
run_tests() {
__run_cmd OMP_NUM_THREADS="$(nproc)" "$HEKIT_SAMPLE_KERNELS"/palisade/build/test/unit-test
__run_cmd OMP_NUM_THREADS="$(nproc)" "$HEKIT_SAMPLE_KERNELS"/seal/build/test/unit-test
}
welcome_message() {
cat << EOF
There are several bash functions sourced that you can run,
1. run_sample_kernels_[palisade|seal]: This will run several HE sample
kernels including Matrix Multiplication and Logistic Regression. The
script will display Wall time, CPU time, and the number of iterations that
were run.
2. run_tests: This will run several unit tests to confirm the validity of the
above sample kernels by comparing against the same operation in the non-HE
space.
3. run_query_example: This will run a "Secure Query" example allowing users
to query on a database of the 50 U.S. States while controlling
(optionally) the crypto-parameters used. When prompted, enter a State and,
if present, the corresponding City will be decoded and printed.
4. run_lr_example: This will run a "Logistic Regression" (LR) example
allowing users to see a faster and more scalable method for LR in HE.
Unlike the LR code available before in the sample-kernels, this version
takes extra steps to utilize as many slots as possible in the ciphertexts.
5. run_psi_example: this will execute an example that uses the HElib library
and the BGV scheme to compute the intersection of two given sets. The
program requires as input, a file with the client set, this is mandatory
parameter, so the user must create this file before executing the example.
Use the flag "-h" for usage information.
The bash functions are run via command line by name, e.g. run_tests. When done,
you can terminate the docker container with the "exit" command or temporarily
leave the docker container typing Ctrl+p then Ctrl+q. To re-enter a detached
docker container you can reattach using \`docker attach <container-id|container-name>\`.
EOF
}