-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
executable file
·149 lines (120 loc) · 6.21 KB
/
Copy pathmakefile
File metadata and controls
executable file
·149 lines (120 loc) · 6.21 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# Run make to see list of commands.
########################## Executable (Meteor.out) arguments ##########################
# arg[0]: Meteor.out
# arg[1]: Party number (0,1,2)
# arg[2]: File containing IP addresses of all parties
# arg[3]: AES key for local randomness generation (each party has a different file)
# arg[4]: AES key for common randomness generation (with next party)
# arg[5]: AES key for common randomness generation (with prev party)
# OPTIONAL ARGUMENTS: If supplied, these arguments take precedence over the ones in src/main.cpp
# Refer to Makefile Parameters section below for details.
# arg[6]: Which predefined network
# arg[7]: What dataset to use
############################## Makefile parameters ######################################
# Location of OPENSSL installation if running over servers without sudo access
# OPEN_SSL_LOC := /data/swagh/conda
# RUN_TYPE {localhost, LAN or WAN}
RUN_TYPE := localhost
# RUN_MODE {unit, inference, preloaded, train}
RUN_MODE := unit
# UNIT_TEST {MeteorRELU, MeteorRELUPrime, MeteorPC, BitProduct, MeteorDotProduct, MeteorSmallDotProduct, MeteorMatMul, MeteorNeighborMultiply, ThunderNMult, MeteorMaxpool, Conv, BN}
UNIT_TEST := MeteorRELU
# NETWORK {SecureML, Sarda, MiniONN, LeNet, AlexNet, and VGG16}
NETWORK := AlexNet
# Dataset {MNIST, CIFAR10, and ImageNet}
DATASET := CIFAR10
# TARGET_ARCH {native, arm64, x86_64}; native uses the host architecture.
TARGET_ARCH ?= native
# Base port for localhost tests. Override when stale local test processes occupy 32000-32008.
PORT_BASE ?= 32000
#########################################################################################
#########################################################################################
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
BUILD_ARCH := $(TARGET_ARCH)
ifeq ($(TARGET_ARCH),native)
BUILD_ARCH := $(UNAME_M)
endif
ARCH_FLAGS :=
ifeq ($(TARGET_ARCH),x86_64)
ARCH_FLAGS := -arch x86_64
endif
ifeq ($(TARGET_ARCH),arm64)
ARCH_FLAGS := -arch arm64
endif
USE_AESNI := 0
ifeq ($(BUILD_ARCH),x86_64)
USE_AESNI := 1
endif
ifeq ($(BUILD_ARCH),amd64)
USE_AESNI := 1
endif
CXX=g++
SRC_CPP_FILES := $(wildcard src/*.cpp)
OBJ_CPP_FILES := $(wildcard util/*.cpp)
ifeq ($(USE_AESNI),0)
SRC_CPP_FILES := $(filter-out src/secCompMultiParty.cpp,$(SRC_CPP_FILES))
OBJ_CPP_FILES := $(filter-out util/TedKrovetzAesNiWrapperC.cpp util/main_gf_funcs.cpp util/cbitvector.cpp,$(OBJ_CPP_FILES))
endif
OBJ_FILES := $(patsubst src/%.cpp, src/%.o,$(SRC_CPP_FILES))
OBJ_FILES += $(patsubst util/%.cpp, util/%.o,$(OBJ_CPP_FILES))
HEADER_FILES = $(wildcard src/*.h)
# FLAGS := -static -g -O0 -w -std=c++11 -pthread -msse4.1 -maes -msse2 -mpclmul -fpermissive -fpic
FLAGS := $(ARCH_FLAGS) -O3 -w -std=c++11 -pthread -fpic
ifeq ($(USE_AESNI),1)
FLAGS += -DMETEOR_AESNI_BACKEND -DMETEOR_ENABLE_GF128 -msse4.1 -maes -msse2 -mpclmul
else
FLAGS += -DMETEOR_PORTABLE_BACKEND
endif
ifeq ($(UNAME_S),Darwin)
LIBS :=
else
LIBS := -lcrypto -lssl
endif
OBJ_INCLUDES := -I 'lib_eigen/' -I 'util/Miracl/' -I 'util/' -I '$(OPEN_SSL_LOC)/include/'
BMR_INCLUDES := -L./ -L$(OPEN_SSL_LOC)/lib/ $(OBJ_INCLUDES)
help: ## Run make or make help to see list of options
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
backend: ## Print selected build backend
@echo "TARGET_ARCH=$(TARGET_ARCH)"
@echo "BUILD_ARCH=$(BUILD_ARCH)"
@echo "USE_AESNI=$(USE_AESNI)"
@echo "FLAGS=$(FLAGS)"
all: Meteor.out ## Just compile the code
Meteor.out: $(OBJ_FILES)
$(CXX) $(FLAGS) -o $@ $(OBJ_FILES) $(BMR_INCLUDES) $(LIBS)
%.o: %.cpp $(HEADER_FILES)
$(CXX) $(FLAGS) -c $< -o $@ $(OBJ_INCLUDES)
clean: ## Run this to clean all files
rm -rf Meteor.out
rm -rf src/*.o util/*.o
################################# Remote runs ##########################################
terminal: Meteor.out ## Run this to print the output of (only) Party 0 to terminal
./Meteor.out 2 files/IP_$(RUN_TYPE) files/keyC files/keyAC files/keyBC >/dev/null &
./Meteor.out 1 files/IP_$(RUN_TYPE) files/keyB files/keyBC files/keyAB >/dev/null &
./Meteor.out 0 files/IP_$(RUN_TYPE) files/keyA files/keyAB files/keyAC
@echo "Execution completed"
file: Meteor.out ## Run this to append the output of (only) Party 0 to file output/3PC.txt
mkdir -p output
./Meteor.out 2 files/IP_$(RUN_TYPE) files/keyC files/keyAC files/keyBC >/dev/null &
./Meteor.out 1 files/IP_$(RUN_TYPE) files/keyB files/keyBC files/keyAB >/dev/null &
./Meteor.out 0 files/IP_$(RUN_TYPE) files/keyA files/keyAB files/keyAC >>output/3PC.txt
@echo "Execution completed"
valg: Meteor.out ## Run this to execute (only) Party 0 using valgrind. Change FLAGS to -O0.
./Meteor.out 2 files/IP_$(RUN_TYPE) files/keyC files/keyAC files/keyBC >/dev/null &
./Meteor.out 1 files/IP_$(RUN_TYPE) files/keyB files/keyBC files/keyAB >/dev/null &
valgrind --tool=memcheck --leak-check=full --track-origins=yes --dsymutil=yes ./Meteor.out 0 files/IP_$(RUN_TYPE) files/keyA files/keyAB files/keyAC
command: Meteor.out ## Run this to use the run parameters specified in the makefile.
METEOR_PORT_BASE=$(PORT_BASE) ./Meteor.out 2 files/IP_$(RUN_TYPE) files/keyC files/keyAC files/keyBC $(RUN_MODE) $(NETWORK) $(DATASET) $(UNIT_TEST) >>P2.txt &
METEOR_PORT_BASE=$(PORT_BASE) ./Meteor.out 1 files/IP_$(RUN_TYPE) files/keyB files/keyBC files/keyAB $(RUN_MODE) $(NETWORK) $(DATASET) $(UNIT_TEST) >>P1.txt &
METEOR_PORT_BASE=$(PORT_BASE) ./Meteor.out 0 files/IP_$(RUN_TYPE) files/keyA files/keyAB files/keyAC $(RUN_MODE) $(NETWORK) $(DATASET) $(UNIT_TEST) >>Meteor_P0.txt
@echo "Execution completed"
################################## tmux runs ############################################
zero: Meteor.out ## Run this to only execute Party 0 (useful for multiple terminal runs)
./Meteor.out 0 files/IP_$(RUN_TYPE) files/keyA files/keyAB files/keyAC
one: Meteor.out ## Run this to only execute Party 1 (useful for multiple terminal runs)
./Meteor.out 1 files/IP_$(RUN_TYPE) files/keyB files/keyBC files/keyAB
two: Meteor.out ## Run this to only execute Party 2 (useful for multiple terminal runs)
./Meteor.out 2 files/IP_$(RUN_TYPE) files/keyC files/keyAC files/keyBC
#########################################################################################
.PHONY: help