-
Notifications
You must be signed in to change notification settings - Fork 29
/
Makefile
297 lines (244 loc) · 7.62 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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# This source distribution is placed in the public domain by its author,
# Ben Buhrow. You may use it for any purpose, free of charge,
# without having to notify anyone. I disclaim any responsibility for any
# errors.
#
# Optionally, please be nice and tell me if you find this source to be
# useful. Again optionally, if you add to the functionality present here
# please consider making those additions public too, so that others may
# benefit from your work.
#
# Some parts of the code (and also this header), included in this
# distribution have been reused from other sources. In particular I
# have benefitted greatly from the work of Jason Papadopoulos's msieve @
# www.boo.net/~jasonp, Scott Contini's mpqs implementation, and Tom St.
# Denis Tom's Fast Math library. Many thanks to their kind donation of
# code to the public domain.
# [email protected] 7/28/09
# ----------------------------------------------------------------------*/
CC = gcc
#CC = x86_64-w64-mingw32-gcc-4.5.1
#CFLAGS = -march=core2 -mtune=core2
CFLAGS = -g
WARN_FLAGS = -Wall # -Wconversion
OPT_FLAGS = -O3
INC = -I. -Iinclude
BINNAME = yafu
# ===================== compiler options =========================
ifeq ($(COMPILER),icc)
CC = icc
INC += -L/usr/lib/gcc/x86_64-redhat-linux/4.4.4
endif
# ===================== architecture options =========================
# if this option is specified then compile *both* the sse2 and sse4.1 versions of the
# appropriate files. The executable will then choose between them based on the runtime
# capability of the user's cpu. In other words, sse4.1 capability is required on the
# host cpu in order to compile the fat binary, but once it is compiled it should run
# to the capability of the target user cpu.
ifeq ($(USE_SSE41),1)
CFLAGS += -DUSE_SSE41
endif
ifeq ($(USE_AVX2),1)
USE_SSE41=1
CFLAGS += -DUSE_AVX2 -msse4 -msse4.1 -mavx2 -mavx
endif
ifeq ($(MIC),1)
CFLAGS += -mmic -DTARGET_MIC
BINNAME := ${BINNAME:%=%_mic}
OBJ_EXT = .mo
INC += -I../msieve/zlib
INC += -I../gmp/include
LIBS += -L../gmp/lib/linux/phi
INC += -I../gmp-ecm/include/linux
LIBS += -L../gmp-ecm/lib/phi/lib
else
OBJ_EXT = .o
INC += -I../gmp/include
LIBS += -L../gmp/lib/linux/x86_64
INC += -I../gmp-ecm/include/linux
LIBS += -L../gmp-ecm/lib/linux/x86_64
endif
# ===================== feature options =========================
ifeq ($(PROFILE),1)
CFLAGS += -pg
CFLAGS += -DPROFILING
BINNAME := ${BINNAME:%=%_prof}
else
OPT_FLAGS += -fomit-frame-pointer
endif
ifeq ($(OPT_DEBUG),1)
CFLAGS += -DOPT_DEBUG
endif
ifeq ($(TIMING),1)
CFLAGS += -DQS_TIMING
endif
ifeq ($(NFS),1)
CFLAGS += -DUSE_NFS
# modify the following line for your particular msieve installation
LIBS += -L../msieve/lib/linux/x86_64
LIBS += -lmsieve
endif
# modify these for your particular cuda installation
ifeq ($(CUDA),1)
CFLAGS += -DHAVE_CUDA
# INC += -I/users/buhrow/NVIDIA_GPU_Computing_SDK/C/common/inc
INC += -I/usr/local/cuda/include/
LIBS += -L/usr/lib64 -lcuda
# LIBS += /users/buhrow/NVIDIA_GPU_Computing_SDK/C/lib/libcutil_x86_64.a
endif
ifeq ($(FORCE_MODERN),1)
CFLAGS += -DFORCE_MODERN
endif
LIBS += -lecm -lgmp
# attempt to get static builds to work... unsuccessful so far
ifeq ($(STATIC),1)
CFLAGS += -static
# LIBS += -Wl,-Bstatic -lm -Wl,Bdynamic -pthread
LIBS += -L/usr/lib/x86_64-redhat-linux5E/lib64/ -lpthread -lm
else
LIBS += -lpthread -lm -ldl
endif
CFLAGS += $(OPT_FLAGS) $(WARN_FLAGS) $(INC)
x86: CFLAGS += -m32
#---------------------------Msieve file lists -------------------------
MSIEVE_SRCS = \
factor/qs/msieve/lanczos.c \
factor/qs/msieve/lanczos_matmul0.c \
factor/qs/msieve/lanczos_matmul1.c \
factor/qs/msieve/lanczos_matmul2.c \
factor/qs/msieve/lanczos_pre.c \
factor/qs/msieve/sqrt.c \
factor/qs/msieve/savefile.c \
factor/qs/msieve/gf2.c
MSIEVE_OBJS = $(MSIEVE_SRCS:.c=$(OBJ_EXT))
#---------------------------YAFU file lists -------------------------
YAFU_SRCS = \
top/driver.c \
top/utils.c \
top/stack.c \
top/calc.c \
top/test.c \
top/aprcl/mpz_aprcl.c \
factor/factor_common.c \
factor/rho.c \
factor/squfof.c \
factor/trialdiv.c \
factor/tune.c \
factor/qs/filter.c \
factor/qs/tdiv.c \
factor/qs/tdiv_small.c \
factor/qs/tdiv_large.c \
factor/qs/tdiv_scan.c \
factor/qs/large_sieve.c \
factor/qs/new_poly.c \
factor/qs/siqs_test.c \
factor/tinyqs/tinySIQS.c \
factor/qs/siqs_aux.c \
factor/qs/smallmpqs.c \
factor/qs/SIQS.c \
factor/gmp-ecm/ecm.c \
factor/gmp-ecm/pp1.c \
factor/gmp-ecm/pm1.c \
factor/nfs/nfs.c \
arith/arith0.c \
arith/arith1.c \
arith/arith2.c \
arith/arith3.c \
top/eratosthenes/count.c \
top/eratosthenes/offsets.c \
top/eratosthenes/primes.c \
top/eratosthenes/roots.c \
top/eratosthenes/linesieve.c \
top/eratosthenes/soe.c \
top/eratosthenes/tiny.c \
top/eratosthenes/worker.c \
top/eratosthenes/soe_util.c \
top/eratosthenes/wrapper.c
ifeq ($(MIC),1)
# just add 32k versions of these files
YAFU_SRCS += factor/qs/tdiv_med_32k.c \
factor/qs/tdiv_resieve_32k.c \
factor/qs/med_sieve_32k.c \
factor/qs/poly_roots_32k.c \
factor/qs/update_poly_roots_32k.c
else
# add both versions
YAFU_SRCS += factor/qs/tdiv_med_32k.c \
factor/qs/tdiv_med_64k.c \
factor/qs/tdiv_resieve_32k.c \
factor/qs/tdiv_resieve_64k.c \
factor/qs/med_sieve_32k.c \
factor/qs/med_sieve_64k.c \
factor/qs/poly_roots_32k.c \
factor/qs/poly_roots_64k.c \
factor/qs/update_poly_roots_32k.c \
factor/qs/update_poly_roots_64k.c
endif
ifeq ($(USE_SSE41),1)
# these files require SSE4.1 to compile
YAFU_SRCS += factor/qs/update_poly_roots_32k_sse4.1.c
YAFU_SRCS += factor/qs/med_sieve_32k_sse4.1.c
endif
YAFU_OBJS = $(YAFU_SRCS:.c=$(OBJ_EXT))
#---------------------------YAFU NFS file lists -----------------------
ifeq ($(NFS),1)
YAFU_NFS_SRCS = \
factor/nfs/nfs_sieving.c \
factor/nfs/nfs_poly.c \
factor/nfs/nfs_postproc.c \
factor/nfs/nfs_filemanip.c \
factor/nfs/nfs_threading.c \
factor/nfs/snfs.c
YAFU_NFS_OBJS = $(YAFU_NFS_SRCS:.c=$(OBJ_EXT))
else
YAFU_NFS_OBJS =
endif
#---------------------------Header file lists -------------------------
HEAD = include/yafu.h \
include/qs.h \
factor/qs/poly_macros_32k.h \
factor/qs/poly_macros_64k.h \
factor/qs/poly_macros_common.h \
factor/qs/sieve_macros_32k.h \
factor/qs/sieve_macros_64k.h \
factor/qs/tdiv_macros_32k.h \
factor/qs/tdiv_macros_64k.h \
factor/qs/tdiv_macros_common.h \
include/lanczos.h \
include/types.h \
include/calc.h \
include/common.h \
include/factor.h \
include/soe.h \
include/util.h \
include/types.h \
include/yafu_string.h \
top/aprcl/mpz_aprcl.h \
top/aprcl/jacobi_sum.h \
include/arith.h \
include/msieve.h \
include/yafu_stack.h \
include/yafu_ecm.h \
include/gmp_xface.h \
include/nfs.h
ifeq ($(USE_SSE41),1)
# these files require SSE4.1 to compile
HEAD += factor/qs/poly_macros_common_sse4.1.h
HEAD += factor/qs/sieve_macros_32k_sse4.1.h
endif
#---------------------------Make Targets -------------------------
all:
@echo "pick a target:"
@echo "x86 32-bit Intel/AMD systems (required if gcc used)"
@echo "x86_64 64-bit Intel/AMD systems (required if gcc used)"
@echo "add 'TIMING=1' to make with expanded QS timing info (slower) "
@echo "add 'PROFILE=1' to make with profiling enabled (slower) "
x86: $(MSIEVE_OBJS) $(YAFU_OBJS) $(YAFU_NFS_OBJS)
$(CC) -m32 $(CFLAGS) $(MSIEVE_OBJS) $(YAFU_OBJS) $(YAFU_NFS_OBJS) -o $(BINNAME) $(LIBS)
x86_64: $(MSIEVE_OBJS) $(YAFU_OBJS) $(YAFU_NFS_OBJS)
$(CC) $(CFLAGS) $(MSIEVE_OBJS) $(YAFU_OBJS) $(YAFU_NFS_OBJS) -o $(BINNAME) $(LIBS)
clean:
rm -f $(MSIEVE_OBJS) $(YAFU_OBJS) $(YAFU_NFS_OBJS)
#---------------------------Build Rules -------------------------
%$(OBJ_EXT): %.c $(HEAD)
$(CC) $(CFLAGS) -c -o $@ $<