-
Notifications
You must be signed in to change notification settings - Fork 24
/
Makefile.in
197 lines (181 loc) · 6.01 KB
/
Makefile.in
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
# Required paths
ifndef LEGION_DIR
$(error LEGION_DIR is not set)
endif
ifndef HTR_DIR
$(error HTR_DIR is not set)
endif
# OS-specific options
ifeq ($(shell uname),Darwin)
DYNLINK_PATH := DYLD_LIBRARY_PATH
C_FLAGS += -DDARWIN
CXX_FLAGS += -DDARWIN
NVCC_FLAGS += -DDARWIN
else
DYNLINK_PATH := LD_LIBRARY_PATH
endif
# CUDA options
USE_CUDA ?= 1
# OpenMP options
USE_OPENMP ?= 1
# HDF options
export USE_HDF ?= 1
export HDF_HEADER ?= hdf5.h
HDF_LIBNAME ?= hdf5
# FFT options
export USE_FFTW ?= $(ELECTRIC_FIELD)
export FFTW_HEADER ?= fftw3.h
FFTW_LIBNAME ?= fftw3 -lfftw3_threads
CUFFT_LIBNAME ?= cufft
######################################################
# Baseline setup
######################################################
# C and CUDA compilers options:
# - Warnings
C_FLAGS += -Wall -Werror -fno-strict-aliasing
CXX_FLAGS += -Wall -Werror -Wno-return-type-c-linkage
# - Include paths
C_FLAGS += -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent -I$(HTR_DIR)/src -I$(HTR_DIR)/src/Mixtures -I$(HTR_DIR)/src/Utils -I$(HTR_DIR)/src/Poisson -I.
CXX_FLAGS += -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent -I$(HTR_DIR)/src -I$(HTR_DIR)/src/Mixtures -I$(HTR_DIR)/src/Utils -I$(HTR_DIR)/src/Poisson -I.
NVCC_FLAGS += -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent -I$(HTR_DIR)/src -I$(HTR_DIR)/src/Mixtures -I$(HTR_DIR)/src/Utils -I$(HTR_DIR)/src/Poisson -I.
# Regent options
export TERRA_PATH := ?.rg;$(HTR_DIR)/src/?.rg;$(HTR_DIR)/src/Mixtures/?.rg;$(HTR_DIR)/src/Utils/?.rg;$(HTR_DIR)/src/Poisson/?.rg
export INCLUDE_PATH := .;$(HTR_DIR)/src;$(HTR_DIR)/src/Mixtures;$(HTR_DIR)/src/Utils;$(HTR_DIR)/src/Poisson
REGENT := $(LEGION_DIR)/language/regent.py
REGENT_FLAGS += -fflow 0 -finner 1 -foffline 1
# Link flags
LINK_FLAGS += -L$(LEGION_DIR)/bindings/regent -lregent
LINK_FLAGS += -lm
ifdef CRAYPE_VERSION
LINK_FLAGS += -Bdynamic
LINK_FLAGS += $(CRAY_UGNI_POST_LINK_OPTS) -lugni
LINK_FLAGS += $(CRAY_UDREG_POST_LINK_OPTS) -ludreg
endif
######################################################
# If HDF5 is active
######################################################
ifeq ($(USE_HDF), 1)
ifdef HDF_ROOT
export INCLUDE_PATH := $(INCLUDE_PATH);$(HDF_ROOT)/include
export $(DYNLINK_PATH) := $($(DYNLINK_PATH)):$(HDF_ROOT)/lib
LINK_FLAGS += -L$(HDF_ROOT)/lib
endif
LINK_FLAGS += -l$(HDF_LIBNAME)
endif
######################################################
# If FFTW is active
######################################################
ifeq ($(USE_FFTW), 1)
ifdef FFTW_ROOT
export INCLUDE_PATH := $(INCLUDE_PATH);$(FFTW_ROOT)/include
export $(DYNLINK_PATH) := $($(DYNLINK_PATH)):$(FFTW_ROOT)/lib
C_FLAGS += -I$(FFTW_ROOT)/include
CXX_FLAGS += -I$(FFTW_ROOT)/include
NVCC_FLAGS += -I$(FFTW_ROOT)/include
LINK_FLAGS += -L$(FFTW_ROOT)/lib
endif
LINK_FLAGS += -l$(FFTW_LIBNAME)
ifeq ($(USE_CUDA), 1)
LINK_FLAGS += -L$(CUDA_HOME)/lib64/stubs -l$(CUFFT_LIBNAME)
endif
endif
######################################################
# If DEBUG mode is active
######################################################
ifeq ($(DEBUG), 1)
REGENT_OPTS += -g
REGENT_FLAGS += -fbounds-checks 1
C_FLAGS += -g -O0 -DLEGION_BOUNDS_CHECKS -DLEGION_PRIVILEGE_CHECKS
CXX_FLAGS += -g -O0 -DLEGION_BOUNDS_CHECKS -DLEGION_PRIVILEGE_CHECKS
NVCC_FLAGS += -g -O0 -DLEGION_BOUNDS_CHECKS -DLEGION_PRIVILEGE_CHECKS -G
LINK_FLAGS += -g
else
C_FLAGS += -O2
CXX_FLAGS += -O3
NVCC_FLAGS += -O3
endif
######################################################
# If DEBUG_OUTPUT mode is active
######################################################
ifneq ($(DEBUG_OUTPUT), 1)
C_FLAGS += -DCHECK_MIX
CXX_FLAGS += -DCHECK_MIX
NVCC_FLAGS += -DCHECK_MIX
endif
######################################################
# If OpenMP is active
######################################################
ifeq ($(USE_OPENMP), 1)
C_FLAGS += -fopenmp
CXX_FLAGS += -fopenmp
REGENT_FLAGS += -fopenmp 1
else
REGENT_FLAGS += -fopenmp 0
endif
######################################################
# If CUDA is active
######################################################
ifeq ($(USE_CUDA), 1)
NVCC ?= $(CUDA_HOME)/bin/nvcc
# Activate Regent's Cuda module only if we are not in debug mode
ifneq ($(DEBUG), 1)
REGENT_FLAGS += -fcuda 1
else
REGENT_FLAGS += -fcuda 0
endif
# Include thrust in C++
CXX_FLAGS += -I$(CUDA_HOME)/include
# Link libcudadevrt for separate compilation of CUDA files
LINK_FLAGS += -L$(CUDA_HOME)/lib64 -lcudadevrt
# CUDA arch variables
GPU_ARCH ?= auto
# translate legacy arch names into numbers
ifeq ($(strip $(GPU_ARCH)),fermi)
GPU_ARCH_N = 20
endif
ifeq ($(strip $(GPU_ARCH)),kepler)
GPU_ARCH_N = 30
endif
ifeq ($(strip $(GPU_ARCH)),k20)
GPU_ARCH_N = 35
endif
ifeq ($(strip $(GPU_ARCH)),k80)
GPU_ARCH_N = 37
endif
ifeq ($(strip $(GPU_ARCH)),maxwell)
GPU_ARCH_N = 52
endif
ifeq ($(strip $(GPU_ARCH)),pascal)
GPU_ARCH_N = 60
endif
ifeq ($(strip $(GPU_ARCH)),volta)
GPU_ARCH_N = 70
endif
ifeq ($(strip $(GPU_ARCH)),turing)
GPU_ARCH_N = 75
endif
ifeq ($(strip $(GPU_ARCH)),ampere)
GPU_ARCH_N = 80
endif
ifeq ($(strip $(GPU_ARCH)),auto)
# detect based on what nvcc supports
ALL_ARCHES = 20 30 32 35 37 50 52 53 60 61 62 70 72 75 80
GPU_ARCH_N = $(shell for X in $(ALL_ARCHES) ; do \
$(NVCC) -gencode arch=compute_$$X,code=sm_$$X -cuda -x c++ /dev/null -o /dev/null 2> /dev/null && echo $$X; \
done)
endif
# finally, convert space-or-comma separated list of architectures (e.g. 35,50)
# into nvcc -gencode arguments
COMMA=,
NVCC_FLAGS += $(foreach X,$(subst $(COMMA), ,$(GPU_ARCH_N)),-gencode arch=compute_$(X)$(COMMA)code=sm_$(X))
else
REGENT_FLAGS += -fcuda 0
endif
#######################################################
# Optional modules
#######################################################
ifeq ($(ELECTRIC_FIELD), 1)
C_FLAGS += -DELECTRIC_FIELD
CXX_FLAGS += -DELECTRIC_FIELD
NVCC_FLAGS += -DELECTRIC_FIELD
endif