ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/JSOC/make_basic.mk
Revision: 1.93
Committed: Sun Nov 20 00:47:00 2022 UTC (10 months ago) by kehcheng
Branch: MAIN
CVS Tags: HEAD
Changes since 1.92: +45 -3 lines
Log Message:
add linux_avx2 support

File Contents

# Content
1 #***********************************************************************************************#
2 #
3 # INITIALIZATION
4 #
5
6 VPATH = $(SRCDIR)
7 STATIC =
8 DBMS = POSTGRESQL
9 CUSTOMSW =
10
11 # Run a script to determine the machine on which make is being run. This
12 # MAY return a machine type, if the host found falls into one of several
13 # categories (like dbserver).
14 MACHTYPE = $(shell hostname)
15
16 # If MACH was set when the make command was issued (eg., make MACH='N02'), then
17 # use its value for the output/obj directory and use the drmsparams.mk variables
18 # relevant to its value. Otherwise, use $(JSOC_MACHINE).
19 ifeq ($(MACH),)
20 MACH = $(JSOC_MACHINE)
21 endif
22
23 #***********************************************************************************************#
24 #
25 # COMPILER SELECTION
26 #
27 COMPILER = icc
28 FCOMPILER = ifort
29 ifeq ($(JSOC_MACHINE), linux_avx2)
30 MPICOMPILER = mpiicc
31 MPIFCOMPILER = mpiifort
32 else
33 MPICOMPILER = $(MPI_PATH)/mpicc
34 MPIFCOMPILER = $(MPI_PATH)/mpif90
35 endif
36
37 # can set through drmsparams.mk or through environment
38 ifneq ($(JSOC_COMPILER),)
39 COMPILER = $(JSOC_COMPILER)
40 endif
41
42 ifneq ($(JSOC_FCOMPILER),)
43 FCOMPILER = $(JSOC_FCOMPILER)
44 endif
45 #***********************************************************************************************#
46
47 #***********************************************************************************************#
48 # This optional file has custom definitions created by the configure script.
49 # Do this after compiler selection since drmsparams.mk might use $COMPILER or $FCOMPILER.
50 # drmsparams.mk might also set compiler (through moreconfigure.pl)
51 -include $(SRCDIR)/$(LOCALIZATIONDIR)/drmsparams.mk
52 #***********************************************************************************************#
53
54 #***********************************************************************************************#
55 #
56 # DEBUGGING
57 #
58 # Check for debug vs. release build - release is default.
59 # To do a debug build, either set the environment variable JSOC_DEBUG to 1, OR
60 # modify the following line so that DEBUG = 1. The environment variable takes precedence.
61 #
62 DEBUG = 0
63
64 ifdef JSOC_DEBUG
65 ifeq ($(JSOC_DEBUG), 1)
66 DEBUG = 1
67 else
68 DEBUG = 0
69 endif
70 endif
71 #***********************************************************************************************#
72
73
74 #***********************************************************************************************#
75 #
76 # WARNINGS
77 #
78 # Warnings ARE displayed, by default, for a release build.
79 #
80 WARN = 1
81
82 # Builder can request warnings via environment variable (setenv JSOC_WARN 1).
83 # The environment variable takes precedence.
84 ifdef JSOC_WARN
85 ifeq ($(JSOC_WARN), 1)
86 WARN = 1
87 else
88 WARN = 0
89 endif
90 endif
91
92 ICC_WARNMORE =
93 ifdef JSOC_WARNICC
94 ifeq ($(COMPILER), icc)
95 ICC_WARNMORE = $(JSOC_WARNICC)
96 endif
97 endif
98
99 #***********************************************************************************************#
100
101
102 #***********************************************************************************************#
103 #
104 # THIRD-PARTY LIBRARIES
105 #
106 # This section contains make variables that hold the paths to and names of third-party libraries.
107 # Variables that end in 'H' contain the -I link flags that contain the include paths
108 # for the library headers, variables that end in 'L' contain the -L link flags that
109 # contain the paths to the library binaries, and variables
110 # that end in "LIBS" contain the full link cmd (the -L flag plus the -l flag)
111 #
112
113 # PostgreSQL
114 PGH = -I$(POSTGRES_INCS)
115
116 # For use of dynamic library
117 PGLIBS = $(POSTGRES_LIBS)/lib$(POSTGRES_LIB).so
118
119 # CFITSIO
120 CFITSIOH = -I$(CFITSIO_INCS)
121 CFITSIOL = -L$(CFITSIO_LIBS)
122 CFITSIOLIBNAME = $(CFITSIO_LIB)
123 # make sure to use static library so we don't have to deal with locating the dynamic one at run time
124 # set back to dynamic (the default) for the other libraries that could follow cfitsio
125 CFITSIOLIBS = $(CFITSIOL) -Wl,-Bstatic -l$(CFITSIOLIBNAME) -Wl,-Bdynamic
126 # end CFITSIO
127
128 # GSL
129 GSLH = -I$(GSL_INCS)
130 GSLL = -L$(GSL_LIBS)
131 GSLLIBS = $(GSLL) -lgsl
132
133 # FFTW
134 ifeq ($(JSOC_MACHINE), linux_avx2)
135 FFTWH =
136 FFTWL =
137 FFTW3LIBS =
138 FFTW3FLIBS =
139 else
140 FFTWH = -I$(FFTW_INCS)
141 FFTWL = -L$(FFTW_LIBS)
142 FFTW3LIBS = $(FFTWL) -lfftw3
143 FFTW3FLIBS = $(FFTWL) -lfftw3f
144 endif
145
146 # TAR
147 LIBTARH = -I$(TAR_INCS)
148 LIBTARL = -L$(TAR_LIBS) -ltar
149
150 # Python
151 LIBPYH = -I$(PY_INCS)
152 LIBPYL = -L$(PY_LIBS) -l$(PY_LIB)
153 PYTHONHOME = "\"$(PY_HOME)\""
154
155 #***********************************************************************************************#
156
157
158 #***********************************************************************************************#
159 #
160 # CUSTOM BUILDS
161 #
162 # Compilation define customizations (eg., for remote DRMS builds)
163 ifneq ($(DRMS_DEFAULT_RETENTION),)
164 # CUSTOMSW = $(CUSTOMSW) -DDRMS_DEFAULT_RETENTION="\"$(DRMS_DEFAULT_RETENTION)\""
165 CUSTOMSW := $(CUSTOMSW) -DDRMS_DEFAULT_RETENTION=$(DRMS_DEFAULT_RETENTION)
166 endif
167
168 # Due to legacy code, the name __LOCALIZED_DEFS__ must be used for NetDRMS builds.
169 # Despite the name, this macro has nothing to do with localized definitions. It means
170 # "not Stanford JSOC-SDP" (it essentially means NetDRMS). So, if __LOCALIZED_DEFS__ is set, then
171 # the binaries were built for use outside of Stanford.
172 # For future use, we also define the NETDRMS_BUILD as a synonym, but with a more appropriate name.
173 # __LOCALIZED_DEFS__ is deprecated and should not be used in new code.
174 ifeq ($(BUILD_TYPE),NETDRMS)
175 CUSTOMSW := $(CUSTOMSW) -DNETDRMS_BUILD -D__LOCALIZED_DEFS__
176 endif
177
178 # Stanford builds are marked by the JSOC_SDP_BUILD macro.
179 ifeq ($(BUILD_TYPE),JSOC_SDP)
180 CUSTOMSW := $(CUSTOMSW) -DJSOC_SDP_BUILD
181 endif
182
183 #
184 #***********************************************************************************************#
185
186 #***********************************************************************************************#
187 #
188 # Global flags
189 #
190 # All modules must be able to find libdsds.so. The define DRMS_LIBDIR specifies the path to
191 # all libraries.
192
193 GLOBALSW = -DDRMS_ARCH="\"$(MACH)\"" -DDRMS_MAKE_ROOT_DIRECTORY="\"$(SRCDIR)\""
194 #
195 #***********************************************************************************************#
196
197 #***********************************************************************************************#
198 #
199 # WARNINGS
200 #
201 # NO LONGER USED - Disable several warnings/remarks when compiling with icc - icc's Wall is a bit picky, it
202 # complains about extern declarations in .c files.
203 # 1418 (remark) - external function definition with no prior declaration
204 # 1419 (warning) - external declaration in primary source file
205 # 310 (remark) - old style function declaration (pre-ANSI)
206 # 279 ?
207 # 981 (remark) - operands are evaluted in unspecified order
208
209 # list of warnings to turn into errors
210 ICC_WARNTOERR = -we266
211
212 ifeq ($(WARN), 1)
213 # Show warnings (always true for a debug build).
214 ICC_WARN = $(ICC_WARNMORE)
215 GCC_WARN = -Wno-comment
216 FCOMPILER_WARN =
217 else
218 # Don't show warnings.
219 ICC_WARN = -w0 -vec-report0 -Wno-comment $(ICC_WARNTOERR)
220 GCC_WARN = -Wno-comment
221 ifeq ($(FCOMPILER), ifort)
222 FCOMPILER_WARN = -vec-report0
223 else
224 FCOMPILER_WARN =
225 endif
226 endif
227
228 #***********************************************************************************************#
229
230
231 #***********************************************************************************************#
232 #
233 # GLOBAL LINK FLAGS
234 #
235 # Link flags for all targets
236 #
237 ifeq ($(JSOC_MACHINE), linux_avx2)
238 LL_ALL = $(SYSLIBS) -lcurl -ltirpc
239 else
240 LL_ALL = $(SYSLIBS) -lcurl
241 endif
242
243 ifeq ($(JSOC_MACHINE), linux_avx2)
244 GCC_LF_ALL = $(STATIC) -Wl,--copy-dt-needed-entries
245 ICC_LF_ALL = $(STATIC) -qopenmp -Wl,-export-dynamic -Wl,--copy-dt-needed-entries
246 else ifeq ($(JSOC_MACHINE), linux_avx)
247 GCC_LF_ALL = $(STATIC) -Wl,--copy-dt-needed-entries
248 ICC_LF_ALL = -diag-disable 10237 $(STATIC) -openmp -static-intel -Wl,-export-dynamic -Wl,--copy-dt-needed-entries
249 else
250 GCC_LF_ALL = $(STATIC)
251 ICC_LF_ALL = -diag-disable 10237 $(STATIC) -openmp -static-intel -Wl,-export-dynamic
252 endif
253
254 # Fortran global LINK flags
255 ifeq ($(FCOMPILER), ifort)
256 ifeq ($(JSOC_MACHINE), linux_avx2)
257 F_LF_ALL = -nofor-main -qopenmp -Wl,-export-dynamic
258 else
259 F_LF_ALL = -diag-disable 10237 -nofor-main -openmp -static-intel -Wl,-export-dynamic
260 endif
261 endif
262 #***********************************************************************************************#
263
264 #***********************************************************************************************#
265 #
266 # GLOBAL COMPILE FLAGS
267 #
268 GCC_CF_GCCCOMP = -DGCCCOMP
269 ifeq ($(JSOC_MACHINE), linux_avx2)
270 ICC_CF_ICCCOMP = -DICCCOMP -qopenmp
271 else
272 ICC_CF_ICCCOMP = -DICCCOMP -openmp
273 endif
274
275 # can't figure out how to get stupid make to do if/else if/else
276 ifeq ($(DEBUG), 0)
277 GCC_CF_ALL = -I$(SRCDIR)/base/include -std=gnu99 -O2 $(GCC_WARN) $(GCC_CF_GCCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG
278
279 ifeq ($(JSOC_MACHINE), linux_x86_64)
280 ICC_CF_ALL = -I$(SRCDIR)/base/include -std=c99 -D_GNU_SOURCE $(ICC_WARN) $(ICC_CF_ICCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG
281 GCC_CF_ALL = -I$(SRCDIR)/base/include -std=gnu99 -O2 -march=opteron $(GCC_WARN) $(GCC_CF_GCCCOMP) $(CUSTOMSW) $(GLOBALSW)
282 endif
283
284 ifeq ($(JSOC_MACHINE), linux_avx2)
285 ICC_CF_ALL = -diag-disable=cpu-dispatch,warn,10441 -axcore-avx512,core-avx2 -I/usr/include/tirpc -I$(SRCDIR)/base/include -std=c99 -D_GNU_SOURCE $(ICC_WARN) $(ICC_CF_ICCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG
286 endif
287
288 ifeq ($(JSOC_MACHINE), linux_avx)
289 ICC_CF_ALL = -xavx -I$(SRCDIR)/base/include -std=c99 -D_GNU_SOURCE $(ICC_WARN) $(ICC_CF_ICCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG
290 endif
291
292 ifeq ($(JSOC_MACHINE), linux_ia64)
293 ICC_CF_ALL = -I$(SRCDIR)/base/include -std=c99 -D_GNU_SOURCE $(ICC_WARN) $(ICC_CF_ICCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG
294 endif
295
296 ifeq ($(JSOC_MACHINE), linux_ia32)
297 GCC_CF_ALL = -I$(SRCDIR)/base/include -std=gnu99 -O2 -march=i686 $(GCC_WARN) $(GCC_CF_GCCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG
298 endif
299
300 else
301 # -g tells the icc and gcc compilers to generate full debugging information
302 ifeq ($(JSOC_MACHINE), linux_avx2)
303 GCC_CF_ALL = -I/usr/include/tirpc -I$(SRCDIR)/base/include -std=gnu99 -g $(GCC_WARN) $(GCC_CF_GCCCOMP) $(CUSTOMSW) $(GLOBALSW)
304 ICC_CF_ALL = -I/usr/include/tirpc -I$(SRCDIR)/base/include -std=c99 -g -D_GNU_SOURCE $(ICC_WARN) $(ICC_CF_ICCCOMP) $(CUSTOMSW) $(GLOBALSW)
305 else
306 GCC_CF_ALL = -I$(SRCDIR)/base/include -std=gnu99 -g $(GCC_WARN) $(GCC_CF_GCCCOMP) $(CUSTOMSW) $(GLOBALSW)
307 ICC_CF_ALL = -I$(SRCDIR)/base/include -std=c99 -D_GNU_SOURCE -g $(ICC_WARN) $(ICC_CF_ICCCOMP) $(CUSTOMSW) $(GLOBALSW)
308 endif
309 endif
310
311 # Fortran global COMPILE flags
312 ifeq ($(JSOC_MACHINE), linux_avx2)
313 ifeq ($(FCOMPILER), ifort)
314 F_CF_ALL := -diag-disable=cpu-dispatch,warn -axcore-avx512,core-avx2 -qopenmp
315 endif
316 endif
317
318 ifeq ($(JSOC_MACHINE), linux_avx)
319 ifeq ($(FCOMPILER), ifort)
320 F_CF_ALL := -xavx -openmp
321 endif
322 endif
323
324 ifeq ($(JSOC_MACHINE), linux_x86_64)
325 ifeq ($(FCOMPILER), ifort)
326 F_CF_ALL := -openmp
327 endif
328 endif
329
330 # Other compiler-specific Fortran COMPILE flags
331 ifeq ($(FCOMPILER), ifort)
332 FCFLAGS_INIT := -ftrapuv
333 else
334 # must be gfortran
335 FCFLAGS_INIT :=
336 endif
337
338 ifeq ($(DEBUG), 0)
339 # -xW optimizes ifort compilation for Pentium 4
340 # -ftrapuv initializes stack local variables to an unusual value to aid error detection.
341 F_CF_ALL := $(F_CF_ALL) $(FCOMPILER_WARN)
342 else
343 F_CF_ALL := $(F_CF_ALL) -g $(FCFLAGS_INIT) $(FCOMPILER_WARN)
344 endif
345 #***********************************************************************************************#
346
347
348 #***********************************************************************************************#
349 #
350 # BUILD TOOLS
351 #
352 # The C compiler named here must output full (header) dependencies in $(@).d.
353 # It may be necessary to create a script similar to ccd-gcc for your compiler.
354 #
355 GCC_CMPLR = $(SRCDIR)/build/ccd-gcc
356 ICC_CMPLR = $(SRCDIR)/build/ccd-icc
357 ARCHIVE = ar crus $@ $^
358
359 ECPG = ecpg -o $@ -c $<
360 SWIG = swig -perl5 -o $@ $<
361
362 GCC_COMP = $(GCC_CMPLR) $(GCC_CF_ALL) $(CF_TGT) -o $@ -c $<
363 ICC_COMP = $(ICC_CMPLR) $(ICC_CF_ALL) $(CF_TGT) -o $@ -c $<
364
365 GCC_LINK = $(GCC_CMPLR) $(GCC_LF_ALL) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LL_ALL)
366 ICC_LINK = $(ICC_CMPLR) $(ICC_LF_ALL) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LL_ALL)
367
368 GCC_COMPLINK = $(GCC_CMPLR) $(GCC_CF_ALL) $(CF_TGT) $(GCC_LF_ALL) $(LF_TGT) -o $@ $< $(LL_TGT) $(LL_ALL)
369 ICC_COMPLINK = $(ICC_CMPLR) $(GCC_CF_ALL) $(CF_TGT) $(ICC_LF_ALL) $(LF_TGT) -o $@ $< $(LL_TGT) $(LL_ALL)
370
371 ifneq ($(COMPILER), icc)
372 COMP = $(GCC_COMP)
373 LINK = $(GCC_LINK)
374 COMPLINK = $(GCC_COMPLINK)
375 else
376 COMP = $(ICC_COMP)
377 LINK = $(ICC_LINK)
378 COMPLINK = $(ICC_COMPLINK)
379 endif
380
381 FCOMP = $(FCOMPILER) $(F_CF_ALL) $(FF_TGT) -o $@ -c $<
382 FLINK = $(FCOMPILER) $(F_LF_ALL) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LL_ALL)
383
384 SLBIN = ln -sf ../../_$(MACH)/$@ ../bin/$(MACH)/
385 SLLIB = ln -sf ../../_$(MACH)/$@ ../lib/$(MACH)/
386 #***********************************************************************************************#
387
388
389 #***********************************************************************************************#
390 #
391 # LIBRARY COLLECTIONS
392 #
393 ALL_LIBS_FPIC = $(LIBDRMSCLIENT_FPIC) $(LIBDBCLIENT_FPIC) $(LIBCMDPARAMS_FPIC) $(LIBTHREADUTIL_FPIC) $(LIBRICECOMP_FPIC) $(LIBDEFS_FPIC) $(LIBMISC_FPIC) $(LIBDSTRUCT_FPIC) $(LIBTIMEIO_FPIC) $(LIBFITSRW_FPIC)
394 ALL_LIBS_PY_FPIC = $(LIBDRMS_SERVER_FPIC) $(LIBDB_SERVER_FPIC) $(LIBCMDPARAMS_FPIC) $(LIBTHREADUTIL_FPIC) $(LIBRICECOMP_FPIC) $(LIBDEFS_FPIC) $(LIBMISC_FPIC) $(LIBDSTRUCT_FPIC) $(LIBTIMEIO_FPIC) $(LIBFITSRW_FPIC)
395
396 ### Standard parts
397 #
398 include $(SRCDIR)/Rules.mk
399
400 # Libraries from src/util linked with all programs.
401 ifneq ($(COMPILER), icc)
402 SYSLIBS = -lz -ldl -lpthread -lm -lutil
403 else
404 SYSLIBS = -lz -ldl -lpthread -lutil
405 endif
406 SRCLIBS = $(LIBTHREADUTIL) $(LIBRICECOMP) $(LIBCMDPARAMS) $(LIBTIMEIO) $(LIBFITSRW) $(LIBERRLOG) $(LIBEXPDRMS) $(LIBEXPUTL) $(LIBMISC) $(LIBDSTRUCT) $(LIBSTATS)
407 FSRCLIBS = $(LIBTHREADUTIL) $(LIBRICECOMP) $(LIBCMDPARAMSF) $(LIBTIMEIO) $(LIBFITSRW) $(LIBERRLOG) $(LIBEXPDRMS) $(LIBEXPUTL) $(LIBMISC) $(LIBDSTRUCT) $(LIBSTATS)
408
409 ########## Libraries to link for server executables, ##############
410 ########## standalone executables and pipeline modules. ##############
411
412 # SERVERLIBS: Libraries linked with "server" programs that
413 # need direct access to the DRMS databases.
414 SERVERLIBS = $(LIBDRMS) $(LIBDEFSSERVER) $(LIBDB) $(LIBSUMSAPI) $(LIBCJSON) $(SRCLIBS)
415
416 # EXELIBS: Libraries linked with standalone executables.
417 EXELIBS = $(LIBDRMSCLIENT) $(LIBDEFSCLIENT) $(LIBDBCLIENT) $(SRCLIBS)
418
419 # MODLIBS: Libraries linked with DRMS modules.
420 MODLIBS = $(LIBJSOC_MAIN) $(SERVERLIBS)
421
422 # MODLIBS_SOCK: Libraries linked with DRMS modules with socket connection to a drms_server
423 MODLIBS_SOCK = $(LIBJSOC_MAIN_SOCK) $(LIBDRMSCLIENT) $(LIBDEFSCLIENT) $(LIBDBCLIENT) $(LIBSUMSAPI) $(LIBCJSON) $(SRCLIBS)
424
425 # FMODLIBS: Libraries linked with DRMS Fortran modules
426 FMODLIBS_SOCK = $(LIBJSOC_MAIN_SOCK_F) $(LIBINTHANDLESF) $(LIBDRMSCLIENT) $(LIBDEFSCLIENT) $(LIBDBCLIENT) $(FSRCLIBS)
427 #***********************************************************************************************#
428
429
430 #***********************************************************************************************#
431 #
432 # PROJECT MAKE RULES
433 #
434 # Make rules that apply to all projects outside of the base DRMS/SUMS system
435 -include $(SRCDIR)/$(LOCALIZATIONDIR)/make_basic.mk
436 #***********************************************************************************************#
437
438
439 #***********************************************************************************************#
440 #
441 # MODULE TYPES
442 #
443 # Make rules that apply to all projects, inside and outside of the base DRMS/SUMS system
444 $(CEXE): %: %.o $(EXELIBS)
445 $(LINK)
446 $(SLBIN)
447
448 $(FEXE): %: %.o
449 $(FLINK)
450 $(SLBIN)
451
452 $(SERVEREXE): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS)
453 $(SERVEREXE): %: %.o $(SERVERLIBS)
454 $(LINK)
455 $(SLBIN)
456
457 $(MODEXE): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS)
458 $(MODEXE): %: %.o $(MODLIBS)
459 $(LINK)
460 $(SLBIN)
461
462 $(MODEXE_SOCK): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS)
463 $(MODEXE_SOCK): %_sock: %.o $(MODLIBS_SOCK)
464 $(LINK)
465 $(SLBIN)
466 # FMODEXE_SOCK contains all Fortran modules - the DoIt() function is defined inside a .f file.
467 # These are socket-connect modules only. Assume they use third-party Fortran libraries
468 # (although this may not be the case).
469 $(FMODEXE_SOCK): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS)
470 $(FMODEXE_SOCK): %_sock: %.o $(FMODLIBS_SOCK)
471 $(FLINK)
472 $(SLBIN)
473
474 # MODEXE_USEF contains all C direct-connect modules that use third-party Fortran libraries.
475 $(MODEXE_USEF): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS)
476 $(MODEXE_USEF): %: %.o $(MODLIBS)
477 $(FLINK)
478 $(SLBIN)
479 # MODEXE_USEF contains all C socket-connect modules that use third-party Fortran libraries.
480 $(MODEXE_USEF_SOCK): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS)
481 $(MODEXE_USEF_SOCK): %_sock: %.o $(MODLIBS_SOCK)
482 $(FLINK)
483 $(SLBIN)
484 #***********************************************************************************************#