Makefile 3.89 KB
Newer Older
Ethan Coon's avatar
Ethan Coon committed
1
2
3
4
5
ELM_BASE = ../../src
KERNEL_FOLDER = cc
ELM_ROOT = $(ELM_BASE)/$(KERNEL_FOLDER)


6
KOKKOS_PATH = ${HOME}/Downloads/kokkos
Ethan Coon's avatar
Ethan Coon committed
7
8
9
#KOKKOS_PATH = /Users/uec/codes/ats/amanzi-tpls/build-dev-tpetra/trilinos/trilinos-12-14-1_master-source/packages/kokkos


10
KOKKOS_DEBUG = "yes"
Pillai, Himanshu's avatar
Pillai, Himanshu committed
11
12
13
EXE_NAME1 = "test_CanopyHydrology_kern1_single"
EXE_NAME2 = "test_CanopyHydrology_kern1_multiple"
EXE_NAME3 = "test_CanopyHydrology_module"
Pillai, Himanshu's avatar
Pillai, Himanshu committed
14
KOKKOS_DEVICES = ${myDEVICE}
Pillai, Himanshu's avatar
Pillai, Himanshu committed
15
16


Ethan Coon's avatar
Ethan Coon committed
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Get the Kokkos Device
ifneq (,$(findstring Cuda,$(KOKKOS_DEVICES)))

CXX = ${KOKKOS_PATH}/bin/nvcc_wrapper
EXE1 = ${EXE_NAME1}.cuda
EXE2 = ${EXE_NAME2}.cuda
EXE3 = ${EXE_NAME3}.cuda
KOKKOS_ARCH = "BSW,Pascal60"
KOKKOS_CUDA_OPTIONS = "force_uvm,enable_lambda"

else

EXE1 = ${EXE_NAME1}.host
EXE2 = ${EXE_NAME2}.host
EXE3 = ${EXE_NAME3}.host
KOKKOS_ARCH = "BSW"

endif

# Set the Kernel programming model
Pillai, Himanshu's avatar
Pillai, Himanshu committed
37
CXXFLAGS += -DNATURE=KOKKOS_INLINE_FUNCTION 
Pillai, Himanshu's avatar
Pillai, Himanshu committed
38

Ethan Coon's avatar
Ethan Coon committed
39
default: Serial
Pillai, Himanshu's avatar
Pillai, Himanshu committed
40

Ethan Coon's avatar
Ethan Coon committed
41
42
# include Kokkos
include $(KOKKOS_PATH)/Makefile.kokkos
Pillai, Himanshu's avatar
Pillai, Himanshu committed
43
# CXXFLAGS += $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS)
44

Ethan Coon's avatar
Ethan Coon committed
45
46
#include ELM
include $(ELM_BASE)/config/Makefile.config
47

Ethan Coon's avatar
Ethan Coon committed
48
# build the tess
Pillai, Himanshu's avatar
Pillai, Himanshu committed
49
50
TESTS = test_CanopyHydrology_kern1_single \
        test_CanopyHydrology_kern1_multiple \
51
        test_CanopyHydrology_module
52

Pillai, Himanshu's avatar
Pillai, Himanshu committed
53
54
55
TESTS1 = test_CanopyHydrology_kern1_multiple \
         test_CanopyHydrology_module

Pillai, Himanshu's avatar
Pillai, Himanshu committed
56
57
58
59
SRC1 = CanopyHydrology_kern1_single.cpp        
SRC2 = CanopyHydrology_kern1_multiple.cpp
SRC3 = CanopyHydrology_module.cpp      

Ethan Coon's avatar
Ethan Coon committed
60
61
62
63
64
65
66
67
LINK = ${CXX}

OBJ1 =  $(SRC1:.cpp=.cpp.o)
OBJ2 =  $(SRC2:.cpp=.cpp.o)
OBJ3 =  $(SRC3:.cpp=.cpp.o)	

.PHONY: links Serial OpenMP Cuda

Pillai, Himanshu's avatar
Pillai, Himanshu committed
68
69
Serial: build1 build2 build3 test
	echo "Serial"
Pillai, Himanshu's avatar
Pillai, Himanshu committed
70
	echo "Start Build"
Pillai, Himanshu's avatar
Pillai, Himanshu committed
71
72
OpenMP: build1 build2 build3 test
	echo "OpenMP"
Pillai, Himanshu's avatar
Pillai, Himanshu committed
73
	echo "Start Build"
Pillai, Himanshu's avatar
Pillai, Himanshu committed
74
75
Cuda: build2 build3 test1
	echo "Cuda"
76
	echo "Start Build"
77

Pillai, Himanshu's avatar
Pillai, Himanshu committed
78
79
80
81
82
83
84
85
86
87
88
89
90
Report: 
	@echo "LINKING"
	@echo "----------------"
	@echo "LINK = $(LINK)"
	@echo "KOKKOS_LDFLAGS = $(KOKKOS_LDFLAGS)"
	@echo "OBJ1 = $(OBJ1)"
	@echo "NETCDF_FLAGS = $(NETCDF_FLAGS)"
	@echo "KOKKOS_LIBS = $(KOKKOS_LIBS)"
	@echo "EXE = $(EXE1)"
	@echo "CXXFLAGS = $(CXXFLAGS)"
	@echo "KOKKOS_CXXFLAGS = $(KOKKOS_CXXFLAGS)"
	@echo "KOKKOS_CPPFLAGS = $(KOKKOS_CPPFLAGS)"

Ethan Coon's avatar
Ethan Coon committed
91
build1: links $(EXE1)
92

Ethan Coon's avatar
Ethan Coon committed
93
94
95
96
97
98
99
100
101
$(EXE1): $(KOKKOS_CPP_DEPENDS) $(OBJ1) $(KOKKOS_LINK_DEPENDS)
	# @echo "LINKING"
	# @echo "----------------"
	# @echo "LINK = $(LINK)"
	# @echo "KOKKOS_LDFLAGS = $(KOKKOS_LDFLAGS)"
	# @echo "OBJ1 = $(OBJ1)"
	# @echo "NETCDF_FLAGS = $(NETCDF_FLAGS)"
	# @echo "KOKKOS_LIBS = $(KOKKOS_LIBS)"
	# @echo "EXE = $(EXE1)"
102
103
104
	# @echo "CXXFLAGS = $(CXXFLAGS)"
	# @echo "KOKKOS_CXXFLAGS = $(KOKKOS_CXXFLAGS)"
	# @echo "KOKKOS_CPPFLAGS = $(KOKKOS_CPPFLAGS)"
Ethan Coon's avatar
Ethan Coon committed
105
	$(LINK) $(OBJ1) $(NETCDF_FLAGS) $(KOKKOS_LDFLAGS) $(KOKKOS_LIBS) $(CXX_LD_FLAGS) -o $(EXE1)
106

Pillai, Himanshu's avatar
Pillai, Himanshu committed
107
build2: links Report $(EXE2)
108

109
$(EXE2): $(OBJ2) $(KOKKOS_LINK_DEPENDS)
Pillai, Himanshu's avatar
Pillai, Himanshu committed
110
111
112
113
114
115
116
117
118
119
120
	@echo "LINKING"
	@echo "----------------"
	@echo "LINK = $(LINK)"
	@echo "KOKKOS_LDFLAGS = $(KOKKOS_LDFLAGS)"
	@echo "OBJ1 = $(OBJ1)"
	@echo "NETCDF_FLAGS = $(NETCDF_FLAGS)"
	@echo "KOKKOS_LIBS = $(KOKKOS_LIBS)"
	@echo "EXE = $(EXE1)"
	@echo "CXXFLAGS = $(CXXFLAGS)"
	@echo "KOKKOS_CXXFLAGS = $(KOKKOS_CXXFLAGS)"
	@echo "KOKKOS_CPPFLAGS = $(KOKKOS_CPPFLAGS)"
Ethan Coon's avatar
Ethan Coon committed
121
	$(LINK) $(OBJ2) $(NETCDF_FLAGS) $(KOKKOS_LDFLAGS) $(KOKKOS_LIBS) $(CXX_LD_FLAGS) -o $(EXE2)
Pillai, Himanshu's avatar
Pillai, Himanshu committed
122

Ethan Coon's avatar
Ethan Coon committed
123
build3: links $(EXE3)
Pillai, Himanshu's avatar
Pillai, Himanshu committed
124
125

$(EXE3): $(OBJ3) $(KOKKOS_LINK_DEPENDS)
Ethan Coon's avatar
Ethan Coon committed
126
	$(LINK) $(OBJ3) $(NETCDF_FLAGS) $(KOKKOS_LDFLAGS) $(KOKKOS_LIBS) $(CXX_LD_FLAGS) -o $(EXE3)
Pillai, Himanshu's avatar
Pillai, Himanshu committed
127

128
129
130
clean:
	@$(ELM_CLEAN)
	rm -f test_* *.o *.cuda *.host
131

Pillai, Himanshu's avatar
Pillai, Himanshu committed
132
test : $(SRC1) $(SRC2) $(SRC3)
Pillai, Himanshu's avatar
Pillai, Himanshu committed
133
134
135
	./$(EXE_NAME1).host > test_CanopyHydrology_kern1_single.stdout
	./$(EXE_NAME2).host > test_CanopyHydrology_kern1_multiple.stdout
	./$(EXE_NAME3).host > test_CanopyHydrology_module.stdout
136
	python ../compare_to_gold.py $(TESTS)
137

Pillai, Himanshu's avatar
Pillai, Himanshu committed
138
test1 : $(SRC2) $(SRC3)
Pillai, Himanshu's avatar
Pillai, Himanshu committed
139
140
	./${EXE_NAME2}.cuda > test_CanopyHydrology_kern1_multiple.stdout
	./${EXE_NAME3}.cuda > test_CanopyHydrology_module.stdout
Pillai, Himanshu's avatar
Pillai, Himanshu committed
141
142
	python ../compare_to_gold.py $(TESTS1)

143
144
links:
	@echo "making in links"
Pillai, Himanshu's avatar
Pillai, Himanshu committed
145
146
	$(MAKE) -C ../links links

Pillai, Himanshu's avatar
Pillai, Himanshu committed
147
148

allclean: clean
Ethan Coon's avatar
Ethan Coon committed
149
	$(MAKE) -C $(SRCDIR) clean