-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
108 lines (86 loc) · 2.84 KB
/
Makefile
File metadata and controls
108 lines (86 loc) · 2.84 KB
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
# Default build suggestion of MPI + OPENMP with Clang on IBM (Power 8) + NVIDIA GPU machines.
# You might have to change the compiler name and flags.
mkfile_dir := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
include $(mkfile_dir)../Makefile.defs
SHELL = /bin/sh
.SUFFIXES: .cc .o
host_debug_flag ?=
AOMP_GPU ?= $(INSTALLED_GPU)
AOMP_GPUTARGET = amdgcn-amd-amdhsa
# Default is Radeon vega/gfx900, for nvidia "export AOMP_GPU=sm_35"
ifeq (sm_,$(findstring sm_,$(AOMP_GPU)))
AOMP_GPUTARGET = nvptx64-nvidia-cuda
endif
AOMP_CPUTARGET ?= x86_64-pc-linux-gnu
DEBUG_LEVEL ?= 0
LULESH_EXEC = lulesh2.0
MPI_INC = /opt/local/include/openmpi
MPI_LIB = /opt/local/lib
# Point your mpicc to Clang
CXX = $(CLANG)
SOURCES2.0 = \
lulesh.cc \
lulesh-comm.cc \
lulesh-viz.cc \
lulesh-util.cc \
lulesh-init.cc
OBJECTS2.0 = $(SOURCES2.0:.cc=.o)
teams =
ifdef TEAMS
teams = -DTEAMS=$(TEAMS)
endif
threads =
ifdef THREADS
threads = -DTHREADS=$(THREADS)
endif
gpu =
ifdef USE_GPU
gpu = -DUSE_GPU=$(USE_GPU)
endif
mpi = -DUSE_MPI=0
ifdef USE_MPI
mpi = -DUSE_MPI=$(USE_MPI)
endif
# Tuning flags for Power 8
CXXFLAGS = -O3 $(shared) $(mpi) $(teams) $(threads) $(gpu) -lm -Wno-unused-command-line-argument $(host_debug_flag)
CXXFLAGS += -target $(AOMP_CPUTARGET) -fopenmp -fopenmp-targets=$(AOMP_GPUTARGET) -Xopenmp-target=$(AOMP_GPUTARGET) -march=$(AOMP_GPU)
CXX = $(AOMP)/bin/clang++
LDFLAGS = -fopenmp -fopenmp-targets=$(AOMP_GPUTARGET) -target $(AOMP_CPUTARGET) -lm
ifeq (nvptx,$(findstring nvptx,$(AOMP_GPUTARGET)))
CUDA ?= /usr/local/cuda
LDFLAGS += -L$(CUDA)/lib64 -lcuda -lcudart -lelf -lffi
endif
ifeq ($(DEBUG_LEVEL),0)
SETDEBUGLIB =
SETDEBUGRUNENV =
else
# if DEBUG_LEVEL != 0, build with the debug libraries which are slow.
SETDEBUGLIB = LIBRARY_PATH=$(AOMP)/lib-debug
# Once you build with debug libs, you have different levels of debug
# by setting these environment variables.
# LIBOMPTARGET_DEBUG: Host device runtime debug messages
SETDEBUGRUNENV = LIBOMPTARGET_DEBUG=1
# LIBOMPTARGET_DEVICE_RTL_DEBUG: Device runtime debug messages.
#SETDEBUGRUNENV = LIBOMPTARGET_DEVICE_RTL_DEBUG=-1
# ATMI_DEBUG: Print ATMI debug messages
#SETDEBUGRUNENV = ATMI_DEBUG=1
endif
# NOTE: You do NOT need debug libs to turn kernel tracing on.
# Set LIBOMPTARGET_KERNEL_TRACE anytime to get kernel launch trace.
# Uncomment next line to activate kernel launch trace in this makefile.
#SETDEBUGRUNENV += LIBOMPTARGET_KERNEL_TRACE=1
.cc.o: lulesh.h
@echo "Building $<"
$(CXX) -c $(CXXFLAGS) -o $@ $<
all: $(LULESH_EXEC)
lulesh2.0: $(OBJECTS2.0)
@echo "Linking"
$(SETDEBUGLIB) $(CXX) $(CXXFLAGS) $(OBJECTS2.0) -o $@ $(LDFLAGS)
run: lulesh2.0
@echo "Running lulesh2.0"
OMP_NUM_THREADS=16 $(SETDEBUGRUNENV) ./lulesh2.0
clean:
/bin/rm -f *.o *~ *.tgt* $(OBJECTS) $(LULESH_EXEC)
/bin/rm -rf *.dSYM
tar: clean
cd .. ; tar cvf lulesh-2.0.tar LULESH-2.0 ; mv lulesh-2.0.tar LULESH-2.0