-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsrc_standard_compiler_var_ifort
118 lines (100 loc) · 3.77 KB
/
src_standard_compiler_var_ifort
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
# Define variables we typically need for compilation
#
# This is included in the user make script -- and in unusual cases, variables
# can be overwritten by redefining them.
#
# Preprocessor options passed to compiler
SWALS_PREPROCESSOR_FLAGS ?=
# Flag to run in parallel using a default setup.
# If defined then this will compile a distributed memory version of the code,
# with default compiler options below.
# To use other options, do not set this variable, but instead manually define
# SWALS_FC, SWALS_PREPROCESSOR_FLAGS
SWALS_BUILD_WITH_PARALLEL_DEFAULTS ?=
# Flag to turn off link time optimization
NO_LTO ?= -no-ipo
#
# C compiler and gdal libraries
#
SWALS_CC ?= gcc -O3
SWALS_GDAL_LIBS ?= `gdal-config --libs`
SWALS_GDAL_CFLAGS ?= `gdal-config --cflags`
#
# NVCC and associated flags
#
## First check that we have nvcc. If not avoid using it
##CUDA_C_TEST := `command -v nvcc`
# Never use CUDA
SWALS_CUDA_C_TEST :=
ifeq ($(SWALS_CUDA_C_TEST),)
# Not using cuda
SWALS_CUDA_CC_ACTIVE :=
SWALS_CUDA_CC :=
SWALS_CUDA_CC_INCLUDE :=
SWALS_CUDA_CC_LIBS :=
else
# Append GPU specific preprocesser var
SWALS_PREPROCESSOR_FLAGS := $(SWALS_PREPROCESSOR_FLAGS) -DUSE_GPU
SWALS_CUDA_CC_ACTIVE := true
SWALS_CUDA_CC ?= nvcc -c -O3 --default-stream per-thread
# Make sure preprocessor flags go to cuda compiler
SWALS_CUDA_CC := $(SWALS_CUDA_CC) $(SWALS_PREPROCESSOR_FLAGS)
SWALS_CUDA_CC_INCLUDE ?= -I/usr/include/ -I.
SWALS_CUDA_CC_LIBS ?= -L/usr/lib/cuda/lib64 -L/usr/lib/cuda/nvvm -lcuda -lcudart
endif
#
# NETCDF
#
ifeq ($(findstring DNONETCDF, $(SWALS_PREPROCESSOR_FLAGS)), DNONETCDF)
# Not using netcdf if -DNONETCDF is a preprocessor flag
SWALS_NETCDF_FINCLUDE :=
SWALS_NETCDF_FLIBS :=
else
# The netcdf fortran include/lib paths might be in either nc-config, or nf-config.
# Here we test for that and adapt accordingly
SWALS_NC_TEST := $(nc-config --fflags)
SWALS_NETCDF_FINCLUDE ?= `nc-config --fflags`
SWALS_NETCDF_FLIBS ?= `nc-config --flibs`
ifeq ($(SWALS_NC_TEST),)
SWALS_NETCDF_FINCLUDE ?= `nf-config --fflags`
SWALS_NETCDF_FLIBS ?= `nf-config --flibs`
endif
endif
#
# Fortran compiler
#
ifeq ($(findstring true, $(SWALS_BUILD_WITH_PARALLEL_DEFAULTS)), true)
# Parallel compiler defaults.
SWALS_FC ?= mpif90
SWALS_PREPROCESSOR_FLAGS := $(SWALS_PREPROCESSOR_FLAGS) -DTIMER -DCOARRAY -DCOARRAY_PROVIDE_CO_ROUTINES -DCOARRAY_USE_MPI_FOR_INTENSIVE_COMMS
else
SWALS_FC ?= ifort
endif
# If -DNOOPENMP was passed to the preprocessor, we should not link with openmp.
ifeq ($(findstring DNOOPENMP, $(SWALS_PREPROCESSOR_FLAGS)),)
# Case with openmp
# For coarray (e.g. 32 images), use SWALS_FC=mpif90 as the compiler, and add
# -coarray=distributed -coarray-num-images=32 to the SWALS_FC_FLAGS
# and -DCOARRAY -DCOARRAY_PROVIDE_CO_ROUTINES
SWALS_FC_FLAGS ?= -O3 -qopenmp -fpp -fPIC
else
# Case without openmp
SWALS_FC_FLAGS ?= -O3 -fpp -fPIC
endif
# Make it easier to append flags for hardware-specific optimization, such as
# -xHost or -xSKYLAKE . Better not to have these by default, because
# they can be sub-optimal in some situations (e.g. when compiling on one
# machine and running on another)
SWALS_FC_ARCH_FLAGS ?=
SWALS_FC_FLAGS := $(SWALS_FC_FLAGS) $(SWALS_FC_ARCH_FLAGS)
SWALS_FC_INCLUDE ?=
SWALS_FC_INCLUDE := $(SWALS_FC_INCLUDE) $(SWALS_CUDA_CC_INCLUDE) $(SWALS_NETCDF_FINCLUDE)
# Fortran linking commands
SWALS_FC_LIBS ?=
# Add in other libraries required above
SWALS_FC_LIBS := $(SWALS_FC_LIBS) $(SWALS_NETCDF_FLIBS) $(SWALS_GDAL_LIBS) $(SWALS_CUDA_CC_LIBS)
# This is the full compiler call
SWALS_FORTRAN := $(SWALS_FC) $(SWALS_FC_FLAGS) $(SWALS_PREPROCESSOR_FLAGS) $(SWALS_FC_INCLUDE)
# Use this to make the $(SWALS_LIBRARY)
SWALS_LIBRARY ?= libSWE.a
SWALS_AR ?= ar rcs