forked from camierjs/nabla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
204 lines (184 loc) · 6.13 KB
/
makefile
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
#travis:;which cmake
###############################
# MacOS||Linux switch||CentOS #
# gcc -dM -E -x c++ /dev/null #
###############################
ifeq ($(shell uname),Darwin)
CMAKE_ROOT_PATH=/usr/local/bin
COMPILER_ROOT_PATH=/usr/local/bin
COMPILER_POSTFIX= -8
# MPI_ROOT_PATH=/usr/local
endif
ifeq ($(shell uname),Linux)
CMAKE_ROOT_PATH = /usr/bin
COMPILER_ROOT_PATH = /usr/bin
# MPI_ROOT_PATH=/usr/local
# COMPILER_ROOT_PATH = /usr/local/gcc/4.9.3/bin
# COMPILER_ROOT_PATH = /usr/local/gcc/5.3.0/bin: undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
endif
ifeq ($(shell [ -f /etc/redhat-release ] && cat /etc/redhat-release|cut -b 1-6),CentOS)
CMAKE_ROOT_PATH = /usr/bin
COMPILER_ROOT_PATH = /usr/local/gcc/bin
endif
####################
# COMPILER OPTIONS #
# gcc -dM -E - < /dev/null
####################
C_FLAGS = -std=c99
MAKEFLAGS = --no-print-directory
#export CC = $(COMPILER_ROOT_PATH)/gcc$(COMPILER_POSTFIX)
#export CXX = $(COMPILER_ROOT_PATH)/g++$(COMPILER_POSTFIX)
#export CC = $(COMPILER_ROOT_PATH)/mpicc
#export CXX = $(COMPILER_ROOT_PATH)/mpicxx
#################
# CMAKE OPTIONS #
#################
#CMAKE = $(CMAKE_ROOT_PATH)/cmake
#CTEST = $(CMAKE_ROOT_PATH)/ctest
CMAKE = cmake
CTEST = ctest
HYODA = /usr/local/arcane/testing/bin/hyoda
#########
# PATHS #
#########
NABLA_PATH = $(shell pwd)
BUILD_PATH = build
#BUILD_PATH = /tmp/nabla
############
# COMMANDS #
############
BUILD_MKDIR = mkdir -p $(BUILD_PATH) && sync && sync
CMAKE_FLAGS = --warn-uninitialized
BUILD_CMAKE = cd $(BUILD_PATH) && $(CMAKE) $(CMAKE_FLAGS) $(NABLA_PATH)
NUMBR_PROCS = $(shell getconf _NPROCESSORS_ONLN)
##################
# BUILD Commands #
##################
all:
@[ ! -d $(BUILD_PATH) ] && ($(BUILD_MKDIR) && $(BUILD_CMAKE)) || exit 0
@[ ! -f $(BUILD_PATH)/Makefile ] && ($(BUILD_MKDIR) && $(BUILD_CMAKE)) || exit 0
# @echo PWD=`pwd` # PWD=/home/travis/build/camierjs/nabla
@cd $(BUILD_PATH) && make -j $(NUMBR_PROCS)
##################
# CONFIG Command #
##################
cfg:
$(BUILD_CMAKE)
config:cfg
bin:
@cd $(BUILD_PATH) && make install
install:bin
##################
# TESTs Commands #
##################
tst:test
test:
(cd $(BUILD_PATH)/tests && $(CTEST) --schedule-random -j $(NUMBR_PROCS))
####################
# BACKEND TEMPLATE #
####################
backends = arcane cuda kokkos lambda okina raja legion
define BACKEND_template =
$(1):
(cd $(BUILD_PATH)/tests && $(CTEST) --schedule-random -j $(NUMBR_PROCS) -R $(1))
endef
$(foreach backend,$(backends),$(eval $(call BACKEND_template,$(backend))))
###################
# CTESTS TEMPLATE #
###################
types = gen run
backends = lambda okina #cuda kokkos arcane raja legion
tests = nesw glcNxt sethi calypso llshrc pnnnt pennant ndspmhd comd pDDFV schrodinger glace aecjs nvknl darcy amber heat p1apwb1D_version_2 p12d p12D upwind p1apwb1D_implicite propagateur drc mhydro ddfv xgnplt pdfLgvn fmly deflex hlt aleph1D aleph2D glc glace2D xst upwindAP lulesh llsh gram
#$(shell cd tests && find . -maxdepth 1 -type d -name \
[^.]*[^\\\(mesh\\\)]*[^\\\(gloci\\\)]*|\
sed -e "s/\\.\\// /g"|tr "\\n" " ")
procs = 1 2 4
simds = std sse avx avx2 #avx512 mic warp
parallels = seq omp #smp mpi family cilk
define CTEST_template =
nabla_$(1)_$(2)_$(3)_$(4)_$(5)_$(6):
(tput reset && cd $(BUILD_PATH)/tests && \
$(CTEST) -V -R nabla_$(1)_$(2)_$(3)_$(4)_$(5)_$(6))
endef
$(foreach type,$(types),\
$(foreach backend,$(backends),\
$(foreach test,$(tests),\
$(foreach cpu,$(procs),\
$(foreach simd,$(simds),\
$(foreach parallel,$(parallels),\
$(eval $(call CTEST_template,$(type),$(backend),$(test),$(cpu),$(simd),$(parallel)))))))))
############
# CLEANING #
############
cln clean:
@[ ! -f $(BUILD_PATH)/Makefile ] && rm -rf $(BUILD_PATH) || exit 0
@[ -d $(BUILD_PATH) ] && (cd $(BUILD_PATH) && make clean) || exit 0
#############
# 2014~20XY #
#############
grep2016:
@grep -r 2014~2017 *
sed2016:
@find . -type f -exec grep -l 2014~2017 {} \; |xargs sed -i 's/2014\~2016/2014\~2017/g'
###########
# PHONIES #
###########
.PHONY: all cfg config bin tst cln clean
#########################
# PERF TESTS GEN/GO/GET #
#########################
PERF_PATH=/tmp/lulesh
MAKEFILE_DUMP=TGT=lulesh\\nMESH ?= $$msh\\nSIMD ?= $$vec\\nPARALLEL ?= omp\\nLOG= \\\# -t \\\#-v $(TGT).log\\nADDITIONAL_NABLA_FILES=luleshGeom.n\\ninclude /tmp/nabla/tests/Makefile.nabla.okina
SIMDs = std sse avx avx2
MESHs = 16 24 32 40 48 56 64 72 80 88 96
THREADs = 1 2 4 8 16 20 24 32 48 64
ECHO=/bin/echo
gen:
mkdir -v -p $(PERF_PATH)
@tput reset
@echo Now launching generation
@for vec in $(SIMDs);do\
for msh in $(MESHs);do\
$(ECHO) -e \\t$$vec\\t$$msh;\
mkdir -v -p $(PERF_PATH)/$$vec/$$msh;\
ln -fs $(shell pwd)/tests/lulesh/*.n $(PERF_PATH)/$$vec/$$msh;\
$(ECHO) -e $(MAKEFILE_DUMP) > $(PERF_PATH)/$$vec/$$msh/Makefile;\
(cd $(PERF_PATH)/$$vec/$$msh && make);\
done;\
done;\
done
go:
@tput reset
@echo Now launching tests
@for vec in $(SIMDs);do\
for msh in $(MESHs);do\
for thr in $(THREADs);do\
$(ECHO) -e \\t$$vec\\t$$msh\\t$$thr;\
KMP_AFFINITY=scatter,granularity=fine OMP_NUM_THREADS=$$thr LC_NUMERIC=en_US.UTF8 perf stat -r 4 -e instructions,cycles,task-clock,cpu-clock \
-o $(PERF_PATH)/$$vec/$$msh/lulesh"_"$$msh"_"omp"_"$$vec"_"$$thr.perf \
$(PERF_PATH)/$$vec/$$msh/lulesh"_"$$msh"_"omp"_"$$vec \> /dev/null;\
done;\
done;\
done
get:
@tput reset
@echo Now collecting results
@for vec in $(SIMDs);do\
OUTPUT_FILE=/tmp/nablaLulesh"_"$$vec"."org;\
$(ECHO) -e \\tGenerating: $$OUTPUT_FILE;\
$(ECHO) -n > $$OUTPUT_FILE;\
for msh in $(MESHs);do\
$(ECHO) -e \\t\\tMESH=$$msh;\
VAL_ONE=`cat /tmp/lulesh/$$vec/$$msh/lulesh_$$msh"_"omp"_"$$vec"_"1.perf|grep elapsed|cut -d's' -f1|tr -d [:blank:]`;\
$(ECHO) $$VAL_ONE;\
$(ECHO) \* lulesh_$$msh"_"omp"_"$$vec >> $$OUTPUT_FILE &&\
for thr in $(THREADs);do\
$(ECHO) -e \\t\\t\\tTHREAD=$$thr;\
(sync && sync &&\
$(ECHO) -n \|$$vec\|$$thr\|$$msh\|$$VAL_ONE\| >> $$OUTPUT_FILE &&\
cat /tmp/lulesh/$$vec/$$msh/lulesh_$$msh"_"omp"_"$$vec"_"$$thr.perf|grep elapsed|cut -d's' -f1|tr -d [:blank:]|tr -d \\n >> $$OUTPUT_FILE &&\
$(ECHO) \| >> $$OUTPUT_FILE);\
done;\
$(ECHO) >> $$OUTPUT_FILE;\
done;\
done