Debian Codegraph @

build_cuda/Makefile

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 # Linux/OS X Makefile for PLINK 2.00.
2 #
3 # Compilation options (leave blank after "=" to disable, put "= 1" to enable):
4 # Do not use AVX2 instructions: NO_AVX2
5 # Do not use SSE4.2 instructions: NO_SSE42
6 # Print clear error message if SSE42/AVX2 needed but missing: CPU_CHECK
7 # Do not link to LAPACK: NO_LAPACK
8 # Use cblas_f77 instead of cblas: FORCE_CBLAS_F77
9 # Use only -O2 optimization for zstd (may be necessary for gcc 4.x): ZSTD_O2
10 # Statically link zlib: STATIC_ZLIB
11 # Statically link zstd: STATIC_ZSTD
12 # Link to MKL with 64-bit indexes (dynamically): DYNAMIC_MKL
13 # (this also requires MKLROOT and MKL_IOMP5_DIR to be defined, and
14 # LD_LIBRARY_PATH to include the appropriate directories)
15 # 32-bit binary (also sets STATIC_ZLIB and ZSTD_O2):
16 # FORCE_32BIT (warning: you may need to add a zconf.h symlink to make that
17 # work)
18 # Debug symbols: set DEBUG to -g
19
20 AVX2_CUDA = 1
21 NO_AVX2 =
22 NO_SSE42 =
23 CPU_CHECK = 1
24 NO_LAPACK =
25 PREFER_CBLAS_F77 =
26 ZSTD_O2 = 1
27 STATIC_ZLIB =
28 STATIC_ZSTD = 1
29 # export LD_LIBRARY_PATH=/opt/intel/mkl/lib/intel64 needed in .profile
30 DYNAMIC_MKL = 1
31 MKLPREROOT = /opt/intel
32 CUDAROOT = /usr/local/cuda
33 FORCE_32BIT =
34 DEBUG =
35 CC ?= gcc
36 CXX ?= g++
37 BASEFLAGS=-DZSTD_MULTITHREAD
38 # ***** end configuration *****
39
40 BASEFLAGS += ${DEBUG}
41 MKLROOT = ${MKLPREROOT}/mkl
42 MKL_IOMP5_DIR = ${MKLPREROOT}/lib/intel64
43
44 include ../Makefile.src
45
46 LINKFLAGS=-lm -lpthread ${DEBUG}
47 ZLIB=
48 ARCH32=
49 CPUCHECK_FLAGS = ${DEBUG}
50
51 ifdef FORCE_32BIT
52 # this is targeted at Scientific Linux 6.
53 STATIC_ZLIB = 1
54 ZSTD_O2 = 1
55 ARCH32 = -m32 -march=i686
56 CXXFLAGS = -std=c++0x
57 else
58 ifdef NO_AVX2
59 ifndef NO_SSE42
60 BASEFLAGS += -msse4.2
61 ifdef CPU_CHECK
62 BASEFLAGS += -DCPU_CHECK_SSE42
63 CPUCHECK_FLAGS = -O2 -DCPU_CHECK_SSE42 ${CXXWARN2}
64 endif
65 endif
66 else
67 BASEFLAGS += -mavx2 -mbmi -mbmi2 -mfma -mlzcnt
68 ifdef AVX2_CUDA
69 BASEFLAGS += -DUSE_CUDA
70 LINKFLAGS += -L${CUDAROOT}/lib64 -lcudart -lcublas
71 endif
72 ifdef CPU_CHECK
73 BASEFLAGS += -DCPU_CHECK_AVX2
74 CPUCHECK_FLAGS = -O2 -DCPU_CHECK_AVX2 ${CXXWARN2}
75 endif
76 endif
77 CXXFLAGS = -std=c++11
78 endif
79 BASEFLAGS += ${ARCH32}
80
81 CFLAGS=-O2 -std=gnu99
82 # zstd appears to be seriously targeted at -O3; see 26 Jul 2016 entry at
83 # cbloom.com/rants.html
84 ifdef ZSTD_O2
85 ZCFLAGS=-O2 -std=gnu99
86 else
87 ZCFLAGS=-O3 -std=gnu99
88 endif
89 # this actually needs to be named "CXXFLAGS"
90 CXXFLAGS += -O2
91
92 ifdef FORCE_CBLAS_F77
93 BASEFLAGS += -DFORCE_CBLAS_F77
94 BLASFLAGS=-llapack -lf77blas -latlas
95 else
96 BLASFLAGS=-llapack -lblas -lcblas -latlas
97 endif
98
99 ifdef STATIC_ZLIB
100 BASEFLAGS += -DSTATIC_ZLIB
101 LINKFLAGS += -L. ../../zlib-${ZLIB_VER}/libz.a
102 else
103 LINKFLAGS += -lz
104 endif
105
106 SKIP_STATIC_ZSTD =
107 ifndef STATIC_ZSTD
108 BASEFLAGS += -DIGNORE_BUNDLED_ZSTD
109 ZCSRC2 =
110 ZSSRC2 =
111 SKIP_STATIC_ZSTD = echo
112 OBJ = $(CSRC:.c=.o) $(CCSRC:.cc=.o)
113 OBJL = $(notdir $(OBJ))
114 LINKFLAGS += -lzstd
115 endif
116
117 UNAME := $(shell uname)
118 ifeq ($(UNAME), Darwin)
119 ifdef FORCE_32BIT
120 $(error 32-bit OS X builds are not supported)
121 endif
122 ifdef DYNAMIC_MKL
123 $(error MKL is not currently supported on OS X)
124 endif
125 BLASFLAGS=-framework Accelerate
126 CXXFLAGS += -stdlib=libc++
127 else
128 ifdef DYNAMIC_MKL
129 ifdef NO_LAPACK
130 $(error DYNAMIC_MKL and NO_LAPACK conflict)
131 endif
132 ifdef FORCE_32BIT
133 $(error DYNAMIC_MKL + FORCE_32BIT not supported)
134 endif
135 BASEFLAGS += -DDYNAMIC_MKL -DLAPACK_ILP64 -I${MKLROOT}/include
136 BLASFLAGS = -L${MKLROOT}/lib/intel64 -L${MKL_IOMP5_DIR} -Wl,--no-as-needed -lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core -liomp5
137 LINKFLAGS += -ldl
138 endif
139 endif
140
141 ifdef NO_LAPACK
142 BASEFLAGS += -DNOLAPACK
143 BLASFLAGS=
144 endif
145
146 CFLAGS += ${BASEFLAGS} ${CWARN2} ${CINCLUDE2}
147 ZCFLAGS += ${BASEFLAGS} ${CWARN2} ${ZSTD_INCLUDE2}
148 CXXFLAGS += ${BASEFLAGS} ${CXXWARN2} ${CXXINCLUDE2}
149
150 ifdef FORCE_32BIT
151 CXXFLAGS += -Wno-sign-compare
152 endif
153
154 all: plink2 pgen_compress
155
156 plink2: $(CSRC2) $(ZCSRC2) $(ZSSRC2) $(CCSRC2) ../plink2_cpu.cc ../cuda/plink2_matrix_cuda.cu
157 $(CC) $(CFLAGS) $(CSRC2) -c
158 $(SKIP_STATIC_ZSTD) gcc $(ZCFLAGS) $(ZCSRC2) $(ZSSRC2) -c
159 nvcc -cudart shared ../cuda/plink2_matrix_cuda.cu -c
160 $(CXX) $(CXXFLAGS) $(CCSRC2) -c
161 $(CXX) $(CPUCHECK_FLAGS) ../plink2_cpu.cc -c
162 $(CXX) $(OBJL) plink2_cpu.o plink2_matrix_cuda.o $(ARCH32) -o plink2 $(BLASFLAGS) $(LINKFLAGS)
163
164 pgen_compress: $(PGCSRC2)
165 $(CXX) $(CXXFLAGS) $(PGCSRC2) -o pgen_compress
166
167 .PHONY: clean
168 clean:
169 rm -f *.o
170 rm -f plink2
171 rm -f pgen_compress