forked from bbuhrow/yafu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.gcc
746 lines (610 loc) · 18.7 KB
/
Makefile.gcc
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
# 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.
# --bbuhrow@gmail.com 7/28/09
# ----------------------------------------------------------------------*/
# override from command line
WIN = 0
WIN64 = 0
VBITS = 64
CC = gcc-11.1.0
CFLAGS = -fno-common -g -m64 -std=gnu99 -DUSE_SSE2 -fPIE -DNFS
WARN_FLAGS = -Wall -Wconversion
OPT_FLAGS = -O2 -D_FILE_OFFSET_BITS=64 -DNDEBUG -D_LARGEFILE64_SOURCE -DVBITS=$(VBITS)
OBJ_EXT = .o
# ===================== path options =============================
# standard search directories for headers/libraries within yafu.
# These should normally not be modified.
INC = -I. -Iinclude -Ims_include -Itop/aprcl -Itop/cmdParser -Itop/ -Ifactor/gmp-ecm \
-Iytools -Iysieve -Iaprcl -Ignfs -Ignfs/poly -Ignfs/poly/stage1
LIBS = -L.
# we require additional search directories for gmp and gmp-ecm,
# for libraries and headers. Change
# these if your installation locations differ.
INC += -I/users/buhrow/src/c/gmp_install/6.2.0-gcc/include
LIBS += -L/users/buhrow/src/c/gmp_install/6.2.0-gcc/lib
INC += -I/users/buhrow/src/c/ecm_install/7.0.5-gcc/include/
LIBS += -L/users/buhrow/src/c/ecm_install/7.0.5-gcc/lib/
# ===================== compiler options =========================
ifeq ($(COMPILER),icc)
CC = icc
INC += -L/usr/lib/gcc/x86_64-redhat-linux/4.4.4
CFLAGS += -qopt-report=5
endif
# ===================== msieve feature options =======================
MSIEVE_LIBS = -L. -L../gmp_install/gmp_6.2.0/lib
ifeq ($(OMP),1)
CFLAGS += -fopenmp -DHAVE_OMP
endif
ifeq ($(ECM),1)
CFLAGS += -DHAVE_GMP_ECM
MSIEVE_LIBS += -lecm
endif
ifeq ($(WIN),1)
else
MSIEVE_LIBS += -ldl
endif
ifdef CUDA
ifeq ($(CUDA),1)
SM = 80
else
SM = $(CUDA)
endif
ifeq ($(WIN),1)
CUDA_ROOT = $(shell echo $$CUDA_PATH)
NVCC = "$(CUDA_ROOT)/bin/nvcc"
ifeq ($(WIN64),1)
CUDA_LIBS = "$(CUDA_ROOT)/lib/x64/cuda.lib"
else
CUDA_LIBS = "$(CUDA_ROOT)/lib/win32/cuda.lib"
endif
else
NVCC = "$(shell which nvcc)"
CUDA_ROOT = $(shell dirname $(NVCC))/../
CUDA_LIBS = -lcuda
endif
CFLAGS += -I"$(CUDA_ROOT)/include" -Icub -DHAVE_CUDA
MSIEVE_LIBS += $(CUDA_LIBS)
ifeq ($(CUDAAWARE),1)
CFLAGS += -DHAVE_CUDAAWARE_MPI
endif
endif
ifeq ($(MPI),1)
CC = mpicc
CFLAGS += -DHAVE_MPI
endif
ifeq ($(BOINC),1)
# fill in as appropriate
BOINC_INC_DIR = .
BOINC_LIB_DIR = .
CFLAGS += -I$(BOINC_INC_DIR) -DHAVE_BOINC
MSIEVE_LIBS += -L$(BOINC_LIB_DIR) -lboinc_api -lboinc
endif
ifeq ($(NO_ZLIB),1)
CFLAGS += -DNO_ZLIB
else
MSIEVE_LIBS += -lz
endif
# Note to MinGW users: the library does not use pthreads calls in
# win32 or win64, so it's safe to pull libpthread into the link line.
# Of course this does mean you have to install the minGW pthreads bundle...
MSIEVE_LIBS += -lgmp -lm -lpthread
# ===================== architecture features =========================
# several functions in yafu can take advantage of advanced processor
# features (instruction sets). Specify on the command line, e.g.,
# USE_AVX2=1
ifeq ($(USE_SSE41),1)
CFLAGS += -DUSE_SSE41 -msse4.1
endif
ifeq ($(USE_AVX2),1)
USE_SSE41=1
CFLAGS += -DUSE_AVX2 -DUSE_SSE41
ifeq ($(COMPILER),icc)
CFLAGS += -march=core-avx2
else
CFLAGS += -mavx2
endif
endif
ifeq ($(ICELAKE),1)
CFLAGS += -DUSE_BMI2 -DUSE_AVX2 -DUSE_AVX512F -DUSE_AVX512BW -DSKYLAKEX -DIFMA -march=icelake-client
SKYLAKEX = 1
else
ifeq ($(SKYLAKEX),1)
CFLAGS += -DUSE_BMI2 -DUSE_AVX2 -DUSE_AVX512F -DUSE_AVX512BW -DSKYLAKEX -march=skylake-avx512
endif
endif
ifeq ($(USE_BMI2),1)
# -mbmi enables _blsr_u64 and -mbmi2 enables _pdep_u64 when using gcc
CFLAGS += -mbmi2 -mbmi -DUSE_BMI2
endif
ifeq ($(KNL),1)
ifneq ($(USE_AVX2),1)
CFLAGS += -DUSE_AVX2 -DUSE_SSE41
endif
CFLAGS += -DTARGET_KNL -DUSE_AVX512F -DUSE_AVX512PF -DSMALL_SIQS_INTERVALS
BINNAME = yafu_knl
ifeq ($(COMPILER),icc)
CFLAGS += -xMIC-AVX512
else
CFLAGS += -march=knl
endif
endif
# ===================== feature options =========================
ifeq ($(SMALLINT),1)
CFLAGS += -DSMALL_SIQS_INTERVALS
endif
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 ($(FORCE_GENERIC),1)
CFLAGS += -DFORCE_GENERIC
endif
# make sure we get the correct libgmp linked by using an absolute path
LIBS += -lecm -lgmp
ifeq ($(SKYLAKEX),1)
# define KNL now for skylakex, after handling an actual command line KNL
KNL=1
endif
# attempt to get static builds to work... unsuccessful so far
ifeq ($(STATIC),1)
# https://software.intel.com/en-us/articles/error-ld-cannot-find-lm
CFLAGS += -static-intel -static
LIBS += -L/usr/lib/x86_64-redhat-linux6E/lib64/ -lpthread -lm
else
LIBS += -lpthread -lm
endif
ifeq ($(MINGW),1)
# not needed with mingw
# -ldl
else
LIBS += -ldl
endif
ifeq ($(COMPILER),icc)
LIBS += -lsvml
endif
CFLAGS += $(OPT_FLAGS) $(WARN_FLAGS) $(INC)
x86: CFLAGS += -m32
#---------------------------Msieve/yafu file lists --------------------
MSIEVE_YAFU_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_YAFU_OBJS = $(MSIEVE_YAFU_SRCS:.c=$(OBJ_EXT))
#---------------------------YAFU file lists -------------------------
YAFU_SRCS = \
top/driver.c \
top/test.c \
factor/tune.c \
factor/autofactor.c \
top/cmdParser/cmdOptions.c \
top/cmdParser/calc.c
COMMON_SRCS = \
factor/factor_common.c \
factor/rho.c \
factor/squfof.c \
factor/trialdiv.c \
arith/arith.c \
arith/monty.c \
arith/fftmul.c \
factor/gmp-ecm/tinyecm.c \
factor/gmp-ecm/micropm1.c \
factor/gmp-ecm/microecm.c \
ytools/threadpool.c \
ytools/util.c \
ysieve/presieve.c \
ysieve/count.c \
ysieve/offsets.c \
ysieve/primes.c \
ysieve/roots.c \
ysieve/linesieve.c \
ysieve/soe.c \
ysieve/tiny.c \
ysieve/worker.c \
ysieve/soe_util.c \
ysieve/wrapper.c \
top/aprcl/mpz_aprcl.c \
ECM_SRCS = \
factor/gmp-ecm/ecm.c \
factor/gmp-ecm/pp1.c \
factor/gmp-ecm/pm1.c \
factor/avx-ecm/avxecm.c \
factor/avx-ecm/avxppm1.c \
factor/avx-ecm/avx_ecm_main.c \
factor/avx-ecm/vec_common.c \
factor/avx-ecm/vecarith.c \
factor/avx-ecm/vecarith52.c \
factor/avx-ecm/vecarith52_special.c \
factor/avx-ecm/vecarith52_common.c
YAFU_SIQS_SRCS = \
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/qs/siqs_aux.c \
factor/qs/smallmpqs.c \
factor/qs/SIQS.c \
factor/qs/med_sieve_32k.c \
factor/qs/poly_roots_32k.c \
factor/prime_sieve.c \
factor/batch_factor.c \
factor/qs/cofactorize_siqs.c
SIQS_BIN_SRCS = factor/qs/qs_demo/siqs_demo.c \
factor/qs/qs_demo/cmdOptions.c \
factor/qs/qs_demo/calc.c
ECM_BIN_SRCS = factor/ecm_demo/ecm_demo.c \
factor/ecm_demo/cmdOptions.c \
factor/ecm_demo/calc.c
ifeq ($(USE_AVX2),1)
YAFU_SIQS_SRCS += factor/qs/tdiv_med_32k_avx2.c
YAFU_SIQS_SRCS += factor/qs/update_poly_roots_32k_avx2.c
YAFU_SIQS_SRCS += factor/qs/med_sieve_32k_avx2.c
YAFU_SIQS_SRCS += factor/qs/tdiv_resieve_32k_avx2.c
endif
ifeq ($(USE_SSE41),1)
# these files require SSE4.1 to compile
YAFU_SIQS_SRCS += factor/qs/update_poly_roots_32k_sse4.1.c
YAFU_SIQS_SRCS += factor/qs/med_sieve_32k_sse4.1.c
endif
ifeq ($(KNL),1)
YAFU_SIQS_SRCS += factor/qs/update_poly_roots_32k_knl.c
endif
YAFU_SIQS_SRCS += factor/qs/update_poly_roots_32k.c
YAFU_SIQS_SRCS += factor/qs/tdiv_med_32k.c
YAFU_SIQS_SRCS += factor/qs/tdiv_resieve_32k.c
YAFU_OBJS = $(YAFU_SRCS:.c=$(OBJ_EXT))
YAFU_SIQS_OBJS = $(YAFU_SIQS_SRCS:.c=$(OBJ_EXT))
YAFU_ECM_OBJS = $(ECM_SRCS:.c=$(OBJ_EXT))
YAFU_COMMON_OBJS = $(COMMON_SRCS:.c=$(OBJ_EXT))
SIQS_BIN_OBJS = $(SIQS_BIN_SRCS:.c=$(OBJ_EXT))
#---------------------------YAFU NFS file lists -----------------------
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 \
factor/nfs/nfs.c
YAFU_NFS_OBJS = $(YAFU_NFS_SRCS:.c=$(OBJ_EXT))
#---------------------------Header file lists -------------------------
COMMON_HEAD = include/gmp_xface.h \
include/monty.h \
include/arith.h \
include/common.h \
top/aprcl/jacobi_sum.h \
include/factor.h \
ytools/ytools.h \
ytools/threadpool.h \
ysieve/soe.h \
ysieve/soe_impl.h \
top/aprcl/mpz_aprcl.h \
ECM_HEAD = include/yafu_ecm.h \
factor/avx-ecm/avx_ecm.h \
factor/gmp-ecm/microecm.h
SIQS_HEAD = include/qs.h \
include/qs_impl.h \
factor/qs/poly_macros_32k.h \
factor/qs/poly_macros_common.h \
factor/qs/sieve_macros_32k.h \
factor/qs/tdiv_macros_common.h \
include/lanczos.h \
include/prime_sieve.h \
include/batch_factor.h \
include/cofactorize.h
SIQS_BIN_HEAD = factor/qs_demo/siqs_demo.h \
factor/qs_demo/calc.h \
factor/qs_demo/cmdOptions.h
YAFU_HEAD = include/yafu.h \
top/cmdParser/cmdOptions.h \
top/cmdParser/calc.h
NFS_HEAD = include/nfs.h \
include/nfs_impl.h \
include/msieve_common.h \
include/gnfs-yafu.h
ifeq ($(USE_AVX2),1)
SIQS_HEAD += factor/qs/poly_macros_common_avx2.h
else
ifeq ($(USE_SSE41),1)
# these files require SSE4.1 to compile
SIQS_HEAD += factor/qs/poly_macros_common_sse4.1.h
SIQS_HEAD += factor/qs/sieve_macros_32k_sse4.1.h
endif
endif
#--------------------------- msieve file lists -----------------------
COMMON_HDR = \
common/lanczos/lanczos.h \
common/filter/filter.h \
common/filter/filter_priv.h \
common/filter/merge_util.h \
ms_include/ms_batch_factor.h \
ms_include/ms_common.h \
ms_include/cuda_xface.h \
ms_include/cuda_xface_la.h \
ms_include/dd.h \
ms_include/ddcomplex.h \
ms_include/ms_gmp_xface.h \
ms_include/integrate.h \
ms_include/ms_msieve.h \
ms_include/mp.h \
ms_include/polyroot.h \
ms_include/thread.h \
ms_include/util.h \
aprcl/mpz_aprcl32.h \
COMMON_GPU_HDR = \
common/lanczos/gpu/lanczos_kernel.cu \
common/lanczos/gpu/lanczos_gpu.h \
common/lanczos/gpu/lanczos_gpu_core.h
COMMON_NOGPU_HDR = \
common/lanczos/cpu/lanczos_cpu.h
MSIEVE_COMMON_SRCS = \
common/filter/clique.c \
common/filter/filter.c \
common/filter/merge.c \
common/filter/merge_post.c \
common/filter/merge_pre.c \
common/filter/merge_util.c \
common/filter/singleton.c \
common/lanczos/lanczos.c \
common/lanczos/lanczos_io.c \
common/lanczos/lanczos_matmul.c \
common/lanczos/lanczos_pre.c \
common/lanczos/matmul_util.c \
common/smallfact/gmp_ecm.c \
common/smallfact/smallfact.c \
common/smallfact/squfof.c \
common/smallfact/tinyqs.c \
common/batch_factor.c \
common/cuda_xface.c \
common/cuda_xface_la.c \
common/dickman.c \
common/driver.c \
common/expr_eval.c \
common/hashtable.c \
common/integrate.c \
common/minimize.c \
common/minimize_global.c \
common/mp.c \
common/polyroot.c \
common/prime_delta.c \
common/prime_sieve.c \
common/savefile.c \
common/strtoll.c \
common/thread.c \
common/util.c \
aprcl/mpz_aprcl32.c \
COMMON_GPU_SRCS = \
common/lanczos/gpu/lanczos_matmul_gpu.c \
common/lanczos/gpu/lanczos_vv.c
COMMON_NOGPU_SRCS = \
common/lanczos/cpu/lanczos_matmul0.c \
common/lanczos/cpu/lanczos_matmul1.c \
common/lanczos/cpu/lanczos_matmul2.c \
common/lanczos/cpu/lanczos_vv.c
ifdef CUDA
MSIEVE_COMMON_SRCS += $(COMMON_GPU_SRCS)
COMMON_HDR += $(COMMON_GPU_HDR)
GPU_OBJS += \
lanczos_kernel.ptx
else
MSIEVE_COMMON_SRCS += $(COMMON_NOGPU_SRCS)
COMMON_HDR += $(COMMON_NOGPU_HDR)
endif
MSIEVE_COMMON_OBJS = $(MSIEVE_COMMON_SRCS:.c=.o)
COMMON_GPU_OBJS = $(COMMON_GPU_SRCS:.c=.o)
COMMON_NOGPU_OBJS = $(COMMON_NOGPU_SRCS:.c=.o)
#---------------------------------- QS file lists -------------------------
QS_HDR = mpqs/mpqs.h
QS_SRCS = \
mpqs/gf2.c \
mpqs/mpqs.c \
mpqs/poly.c \
mpqs/relation.c \
mpqs/sieve.c \
mpqs/sieve_core.c \
mpqs/sqrt.c
QS_OBJS = \
mpqs/gf2.qo \
mpqs/mpqs.qo \
mpqs/poly.qo \
mpqs/relation.qo \
mpqs/sieve.qo \
mpqs/sqrt.qo \
mpqs/sieve_core_generic_32k.qo \
mpqs/sieve_core_generic_64k.qo
#---------------------------------- GPU file lists -------------------------
GPU_OBJS += \
stage1_core.ptx \
cub/built
#---------------------------------- NFS file lists -------------------------
NFS_HDR = \
gnfs/filter/filter.h \
gnfs/poly/poly.h \
gnfs/poly/poly_skew.h \
gnfs/poly/stage1/stage1.h \
gnfs/poly/stage2/stage2.h \
gnfs/sieve/sieve.h \
gnfs/sqrt/sqrt.h \
gnfs/gnfs.h
NFS_GPU_HDR = \
gnfs/poly/stage1/stage1_core_gpu/stage1_core.cu \
gnfs/poly/stage1/stage1_core_gpu/cuda_intrinsics.h \
gnfs/poly/stage1/stage1_core_gpu/stage1_core.h
NFS_NOGPU_HDR = \
gnfs/poly/stage1/cpu_intrinsics.h
NFS_SRCS = \
gnfs/poly/poly.c \
gnfs/poly/poly_param.c \
gnfs/poly/poly_skew.c \
gnfs/poly/polyutil.c \
gnfs/poly/root_score.c \
gnfs/poly/size_score.c \
gnfs/poly/stage1/stage1.c \
gnfs/poly/stage1/stage1_roots.c \
gnfs/poly/stage2/optimize.c \
gnfs/poly/stage2/optimize_deg6.c \
gnfs/poly/stage2/root_sieve.c \
gnfs/poly/stage2/root_sieve_deg45_x.c \
gnfs/poly/stage2/root_sieve_deg5_xy.c \
gnfs/poly/stage2/root_sieve_deg6_x.c \
gnfs/poly/stage2/root_sieve_deg6_xy.c \
gnfs/poly/stage2/root_sieve_deg6_xyz.c \
gnfs/poly/stage2/root_sieve_line.c \
gnfs/poly/stage2/root_sieve_util.c \
gnfs/poly/stage2/stage2.c \
gnfs/filter/duplicate.c \
gnfs/filter/filter.c \
gnfs/filter/singleton.c \
gnfs/sieve/sieve_line.c \
gnfs/sieve/sieve_util.c \
gnfs/sqrt/sqrt.c \
gnfs/sqrt/sqrt_a.c \
gnfs/fb.c \
gnfs/ffpoly.c \
gnfs/gf2.c \
gnfs/gnfs.c \
gnfs/relation.c
NFS_OBJS = $(NFS_SRCS:.c=.no)
NFS_GPU_SRCS = \
gnfs/poly/stage1/stage1_sieve_gpu.c
NFS_GPU_OBJS = $(NFS_GPU_SRCS:.c=.no)
NFS_NOGPU_SRCS = \
gnfs/poly/stage1/stage1_sieve_cpu.c
NFS_NOGPU_OBJS = $(NFS_NOGPU_SRCS:.c=.no)
ifeq ($(CUDA),1)
NFS_HDR += $(NFS_GPU_HDR)
NFS_SRCS += $(NFS_GPU_SRCS)
NFS_OBJS += $(NFS_GPU_OBJS)
else
NFS_HDR += $(NFS_NOGPU_HDR)
NFS_SRCS += $(NFS_NOGPU_SRCS)
NFS_OBJS += $(NFS_NOGPU_OBJS)
GPU_OBJS =
endif
#---------------------------Make Targets -------------------------
help:
@echo "to build msieve:"
@echo "make msieve"
@echo "add 'WIN=1 if building on windows"
@echo "add 'WIN64=1 if building on 64-bit windows"
@echo "add 'ECM=1' if GMP-ECM is available (enables ECM)"
@echo "add 'CUDA=1' for Nvidia graphics card support"
@echo "add 'MPI=1' for parallel processing using MPI"
@echo "add 'BOINC=1' to add BOINC wrapper"
@echo "add 'NO_ZLIB=1' if you don't have zlib"
@echo "add 'VBITS=X' for linear algebra with X-bit vectors (64, 128, 256)"
@echo "to build yafu:"
@echo "make yafu"
@echo "add 'USE_SSE41=1' to include sse4.1 vectorization instruction support"
@echo "add 'USE_AVX2=1' to include AVX2 vectorization instruction support"
@echo "add 'USE_BMI2=1' to include BMI2 instruction support"
@echo "add 'SKYLAKEX=1' to include AVX512F,VL,DQ,BW vectorization instruction support"
@echo "add 'ICELAKE=1' to include SKYLAKEX + AVX512IFMA vectorization instruction support"
@echo ""
@echo "For either build, add COMPILER=icc to build with the icc compiler (if installed)"
msieve: $(MSIEVE_COMMON_OBJS) $(QS_OBJS) $(NFS_OBJS) $(GPU_OBJS)
rm -f libmsieve.a
ar r libmsieve.a $(MSIEVE_COMMON_OBJS) $(QS_OBJS) $(NFS_OBJS)
ranlib libmsieve.a
$(CC) $(CFLAGS) demo.c -o msieve $(LDFLAGS) \
libmsieve.a $(MSIEVE_LIBS)
yafu: $(MSIEVE_YAFU_OBJS) $(YAFU_SIQS_OBJS) $(YAFU_OBJS) $(YAFU_NFS_OBJS) $(YAFU_ECM_OBJS) $(YAFU_COMMON_OBJS) \
$(MSIEVE_COMMON_OBJS) $(QS_OBJS) $(NFS_OBJS)
rm -f libmsieve.a
ar r libmsieve.a $(MSIEVE_COMMON_OBJS) $(QS_OBJS) $(NFS_OBJS)
ranlib libmsieve.a
rm -f libysiqs.a
ar r libysiqs.a $(YAFU_SIQS_OBJS) $(YAFU_COMMON_OBJS) $(MSIEVE_YAFU_OBJS)
ranlib libysiqs.a
rm -f libyecm.a
ar r libyecm.a $(YAFU_ECM_OBJS) $(YAFU_COMMON_OBJS)
ranlib libyecm.a
rm -f libynfs.a
ar r libynfs.a $(YAFU_NFS_OBJS) $(YAFU_COMMON_OBJS)
ranlib libynfs.a
$(CC) $(CFLAGS) $(YAFU_OBJS) -o yafu -lysiqs -lyecm -lynfs -lmsieve $(LIBS)
siqs: $(MSIEVE_YAFU_OBJS) $(YAFU_SIQS_OBJS) $(YAFU_COMMON_OBJS) $(SIQS_BIN_OBJS)
rm -f libysiqs.a
ar r libysiqs.a $(YAFU_SIQS_OBJS) $(YAFU_COMMON_OBJS) $(MSIEVE_YAFU_OBJS)
ranlib libysiqs.a
$(CC) $(CFLAGS) $(SIQS_BIN_OBJS) -o siqs_demo -lysiqs $(LIBS)
ecm: $(YAFU_ECM_OBJS) $(YAFU_COMMON_OBJS) $(ECM_BIN_OBJS)
rm -f libyecm.a
ar r libyecm.a $(YAFU_ECM_OBJS) $(YAFU_COMMON_OBJS)
ranlib libyecm.a
$(CC) $(CFLAGS) $(ECM_BIN_OBJS) -o ecm_demo -libyecm.a $(LIBS)
clean:
rm -f $(MSIEVE_YAFU_OBJS) $(YAFU_OBJS) $(YAFU_NFS_OBJS) $(YAFU_SIQS_OBJS) $(YAFU_ECM_OBJS) $(YAFU_COMMON_OBJS) \
msieve msieve.exe libmsieve.a $(MSIEVE_COMMON_OBJS) $(QS_OBJS) \
$(NFS_OBJS) $(NFS_GPU_OBJS) $(NFS_NOGPU_OBJS) *.ptx
#---------------------------Build Rules -------------------------
#%$(OBJ_EXT): %.c $(SIQS_BIN_HEAD) $(COMMON_HEAD) $(NFS_HEAD) $(ECM_HEAD) $(YAFU_HEAD) $(SIQS_HEAD)
# $(CC) $(CFLAGS) -c -o $@ $<
#
#
%.o: %.c $(COMMON_HDR)
$(CC) $(CFLAGS) -c -o $@ $<
%$(OBJ_EXT): %.c $(COMMON_HEAD)
$(CC) $(CFLAGS) -c -o $@ $<
%$(OBJ_EXT): %.c $(NFS_HEAD)
$(CC) $(CFLAGS) -c -o $@ $<
%$(OBJ_EXT): %.c $(ECM_HEAD)
$(CC) $(CFLAGS) -c -o $@ $<
%$(OBJ_EXT): %.c $(YAFU_HEAD)
$(CC) $(CFLAGS) -c -o $@ $<
%$(OBJ_EXT): %.c $(SIQS_HEAD)
$(CC) $(CFLAGS) -c -o $@ $<
%$(OBJ_EXT): %.c $(SIQS_BIN_HEAD)
$(CC) $(CFLAGS) -c -o $@ $<
# QS build rules
mpqs/sieve_core_generic_32k.qo: mpqs/sieve_core.c $(COMMON_HDR) $(QS_HDR)
$(CC) $(CFLAGS) -DBLOCK_KB=32 -DHAS_SSE2 \
-DROUTINE_NAME=qs_core_sieve_generic_32k \
-c -o $@ mpqs/sieve_core.c
mpqs/sieve_core_generic_64k.qo: mpqs/sieve_core.c $(COMMON_HDR) $(QS_HDR)
$(CC) $(CFLAGS) -DBLOCK_KB=64 -DHAS_SSE2 \
-DROUTINE_NAME=qs_core_sieve_generic_64k \
-c -o $@ mpqs/sieve_core.c
%.qo: %.c $(COMMON_HDR) $(QS_HDR)
$(CC) $(CFLAGS) -c -o $@ $<
# NFS build rules
%.no: %.c $(COMMON_HDR) $(NFS_HDR)
$(CC) $(CFLAGS) -Ignfs -c -o $@ $<
# GPU build rules
stage1_core.ptx: $(NFS_GPU_HDR)
$(NVCC) -arch sm_$(SM) -ptx -o $@ $<
lanczos_kernel.ptx: $(COMMON_GPU_HDR)
$(NVCC) -arch sm_$(SM) -ptx -DVBITS=$(VBITS) -o $@ $<
cub/built:
cd cub && make WIN=$(WIN) WIN64=$(WIN64) VBITS=$(VBITS) sm=$(SM)0 && cd ..