Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
116 lines (91 loc) · 3.72 KB
/
Copy pathMakefile
File metadata and controls
116 lines (91 loc) · 3.72 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
CC = gcc
ZKW ?= 11
CFLAGS = -O3 -march=native -maes -mavx512dq -std=c11 -Wall -Wextra \
-Wno-unused-function \
-D_POSIX_C_SOURCE=200112L \
-Icompress -Iutils \
-pthread -fopenmp -DZKW=$(ZKW) $(EXTRA)
LDFLAGS = -pthread -fopenmp -lm -lgmp
BUILD = build
vpath %.c . plhe channel server client compress utils
# Detect AVX-512 IFMA52 from the *actual* CFLAGS -- on IFMA-capable boxes we
# pick _m512.c (uses mont.h primitives), otherwise fall back to _gmpz.c
# (default). Both files implement the same public symbols from compress.h,
# so only one is linked.
HAS_IFMA := $(shell echo | $(CC) $(CFLAGS) -dM -E -x c - 2>/dev/null | grep -q __AVX512IFMA__ && echo 1)
ifeq ($(HAS_IFMA),1)
COMPRESS_PATH_OBJ = $(BUILD)/_m512.o
COMPRESS_PATH_SMALL_OBJ = $(BUILD)/_m512_small.o
else
COMPRESS_PATH_OBJ = $(BUILD)/_gmpz.o
COMPRESS_PATH_SMALL_OBJ = $(BUILD)/_gmpz_small.o
endif
OBJS = $(BUILD)/plhe.o \
$(BUILD)/memory.o \
$(BUILD)/server.o \
$(BUILD)/client.o \
$(COMPRESS_PATH_OBJ) \
$(BUILD)/bench.o
SMALL_FLAGS = -DPLHE_LAMBDA=128 -DPLHE_N1=8 -DPLHE_MR1=16 -DPLHE_MC1=16 \
-DBLOCK_KIB=1 \
-DSERVER_THREADS=2 -DAGG_BATCH=2 \
-DCLIENT_THREADS=2 \
-DPLHE_SIGMA_X10=32
SMALL_OBJS = $(BUILD)/plhe_small.o \
$(BUILD)/memory_small.o \
$(BUILD)/server_small.o \
$(BUILD)/client_small.o \
$(COMPRESS_PATH_SMALL_OBJ) \
$(BUILD)/bench_small.o
.PHONY: all small clean
all: bench
small: bench_small
bench: $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
bench_small: $(SMALL_OBJS)
$(CC) $(CFLAGS) $(SMALL_FLAGS) -o $@ $^ $(LDFLAGS)
# test_comp -- combined: Mont modmul micro-bench + compress pipeline test.
test_comp: $(COMPRESS_PATH_OBJ) $(BUILD)/test_comp.o
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
# test_noise -- v1 layer-1 noise budget (no Mont / no GMP / no PIR pipeline).
test_noise: $(BUILD)/test_noise.o
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
# _demo -- small end-to-end run of the protocol (paper Examples 1-4).
# other sizes: make -B _demo DEMO="-DDEMO_N=4 -DDEMO_M=5"
_demo: _demo.c plhe/plhe.c plhe/plhe.h plhe/params.h
$(CC) $(CFLAGS) $(DEMO) -o $@ $< -lm
$(BUILD)/%.o: %.c | $(BUILD)
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/%_small.o: %.c | $(BUILD)
$(CC) $(CFLAGS) $(SMALL_FLAGS) -c -o $@ $<
$(BUILD):
mkdir -p $(BUILD)
# Header dependencies
$(BUILD)/plhe.o $(BUILD)/plhe_small.o \
$(BUILD)/memory.o $(BUILD)/memory_small.o \
$(BUILD)/server.o $(BUILD)/server_small.o \
$(BUILD)/client.o $(BUILD)/client_small.o \
$(BUILD)/bench.o $(BUILD)/bench_small.o: plhe/params.h
$(BUILD)/plhe.o $(BUILD)/plhe_small.o \
$(BUILD)/server.o $(BUILD)/server_small.o \
$(BUILD)/client.o $(BUILD)/client_small.o \
$(BUILD)/bench.o $(BUILD)/bench_small.o: plhe/plhe.h
$(BUILD)/memory.o $(BUILD)/memory_small.o \
$(BUILD)/server.o $(BUILD)/server_small.o \
$(BUILD)/client.o $(BUILD)/client_small.o \
$(BUILD)/bench.o $(BUILD)/bench_small.o: channel/channel.h
$(BUILD)/server.o $(BUILD)/server_small.o \
$(BUILD)/bench.o $(BUILD)/bench_small.o: server/server.h
$(BUILD)/client.o $(BUILD)/client_small.o \
$(BUILD)/bench.o $(BUILD)/bench_small.o: client/client.h
$(BUILD)/client.o $(BUILD)/client_small.o \
$(BUILD)/server.o $(BUILD)/server_small.o: utils/barrier.h
$(BUILD)/_m512.o $(BUILD)/_m512_small.o \
$(BUILD)/_gmpz.o $(BUILD)/_gmpz_small.o \
$(BUILD)/server.o $(BUILD)/server_small.o \
$(BUILD)/client.o $(BUILD)/client_small.o \
$(BUILD)/memory.o $(BUILD)/memory_small.o \
$(BUILD)/bench.o $(BUILD)/bench_small.o \
$(BUILD)/test_comp.o: compress/compress.h compress/mont.h compress/mont_n80.h compress/mont_n40.h
clean:
rm -rf $(BUILD) bench bench_small test_comp test_noise _demo