-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
122 lines (95 loc) · 3.3 KB
/
Makefile
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
ifdef gpu
SRC = SECPK1/IntGroup.cpp main.cpp SECPK1/Random.cpp \
Timer.cpp SECPK1/Int.cpp SECPK1/IntMod.cpp \
SECPK1/Point.cpp SECPK1/SECP256K1.cpp \
GPU/GPUEngine.o Kangaroo.cpp HashTable.cpp \
Backup.cpp Thread.cpp Check.cpp Network.cpp Merge.cpp PartMerge.cpp
OBJDIR = obj
OBJET = $(addprefix $(OBJDIR)/, \
SECPK1/IntGroup.o main.o SECPK1/Random.o \
Timer.o SECPK1/Int.o SECPK1/IntMod.o \
SECPK1/Point.o SECPK1/SECP256K1.o \
GPU/GPUEngine.o Kangaroo.o HashTable.o Thread.o \
Backup.o Check.o Network.o Merge.o PartMerge.o)
else
SRC = SECPK1/IntGroup.cpp main.cpp SECPK1/Random.cpp \
Timer.cpp SECPK1/Int.cpp SECPK1/IntMod.cpp \
SECPK1/Point.cpp SECPK1/SECP256K1.cpp \
Kangaroo.cpp HashTable.cpp Thread.cpp Check.cpp \
Backup.cpp Network.cpp Merge.cpp PartMerge.cpp
OBJDIR = obj
OBJET = $(addprefix $(OBJDIR)/, \
SECPK1/IntGroup.o main.o SECPK1/Random.o \
Timer.o SECPK1/Int.o SECPK1/IntMod.o \
SECPK1/Point.o SECPK1/SECP256K1.o \
Kangaroo.o HashTable.o Thread.o Check.o Backup.o \
Network.o Merge.o PartMerge.o)
endif
CXX = g++
CUDA = /usr/local/cuda
CXXCUDA = /usr/bin/g++
NVCC = $(CUDA)/bin/nvcc
all: driverquery bsgs
ifdef gpu
ifndef ccap
driverquery:
. ./detect_cuda.sh
ccap=$(shell cat cuda_version.txt)
else
driverquery:
@echo "Compiling against manually selected CUDA version ${ccap}"
endif
else
driverquery:
endif
ifdef gpu
ifdef debug
CXXFLAGS = -DWITHGPU -m64 -mssse3 -Wno-unused-result -Wno-write-strings -g -I. -I$(CUDA)/include
else
CXXFLAGS = -DWITHGPU -m64 -mssse3 -Wno-unused-result -Wno-write-strings -O2 -I. -I$(CUDA)/include
endif
LFLAGS = -lpthread -L$(CUDA)/lib64 -lcudart
else
ifdef cpu
CXXFLAGS = -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -pthread -ftree-vectorize -flto -O3 -funroll-loops -finline-functions -I.
LFLAGS = -lpthread
else
ifdef debug
CXXFLAGS = -m64 -mssse3 -Wno-unused-result -Wno-write-strings -g -I. -I$(CUDA)/include
else
CXXFLAGS = -m64 -mssse3 -Wno-unused-result -Wno-write-strings -O2 -I. -I$(CUDA)/include
endif
LFLAGS = -lpthread
endif
endif
#--------------------------------------------------------------------
ifdef gpu
ifdef debug
$(OBJDIR)/GPU/GPUEngine.o: GPU/GPUEngine.cu
$(NVCC) -G -maxrregcount=0 --ptxas-options=-v --compile --compiler-options -fPIC -ccbin $(CXXCUDA) -m64 -g -I$(CUDA)/include -gencode=arch=compute_$(ccap),code=sm_$(ccap) -o $(OBJDIR)/GPU/GPUEngine.o -c GPU/GPUEngine.cu
else
$(OBJDIR)/GPU/GPUEngine.o: GPU/GPUEngine.cu
$(NVCC) -maxrregcount=0 --ptxas-options=-v --compile --compiler-options -fPIC -ccbin $(CXXCUDA) -m64 -O2 -I$(CUDA)/include -gencode=arch=compute_$(ccap),code=sm_$(ccap) -o $(OBJDIR)/GPU/GPUEngine.o -c GPU/GPUEngine.cu
endif
endif
$(OBJDIR)/%.o : %.cpp
$(CXX) $(CXXFLAGS) -o $@ -c $<
bsgs: $(OBJET)
@echo Making Kangaroo-256...
$(CXX) $(OBJET) $(LFLAGS) -o kangaroo-256
$(OBJET): | $(OBJDIR) $(OBJDIR)/SECPK1 $(OBJDIR)/GPU
$(OBJDIR):
mkdir -p $(OBJDIR)
$(OBJDIR)/GPU: $(OBJDIR)
cd $(OBJDIR) && mkdir -p GPU
$(OBJDIR)/SECPK1: $(OBJDIR)
cd $(OBJDIR) && mkdir -p SECPK1
clean:
@echo Cleaning...
@rm -f kangaroo-256
@rm -f obj/*.o
@rm -f obj/GPU/*.o
@rm -f obj/SECPK1/*.o
@rm -f deviceQuery/*.o
@rm -f cuda_version.txt
@rm -f deviceQuery/cuda_build_log.txt