-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile-exp1
More file actions
93 lines (75 loc) · 2.54 KB
/
Makefile-exp1
File metadata and controls
93 lines (75 loc) · 2.54 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
mkfile_dir := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
include $(mkfile_dir)../../Makefile.defs
MP4BUILD = 1
#host_debug_flag = -g
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
ifeq ($(VERBOSE),1)
$(info Compilation and linking VERBOSE Mode ON)
VERBOSE = -v
endif
ifeq ($(TEMPS),1)
$(info Compilation and linking save-temp Mode ON)
VERBOSE += -save-temps
endif
ifdef MP4BUILD
CLANG=$(AOMP)/bin/clang++
CXXFLAGS = $(host_debug_flag) -O3 -I${OMPIDIR}/include -target $(AOMP_CPUTARGET) -fopenmp -fopenmp-targets=$(AOMP_GPUTARGET) -Xopenmp-target=$(AOMP_GPUTARGET) -march=$(AOMP_GPU) $(VERBOSE) $(CDEFS)
CXX = $(AOMP)/bin/clang++
LFLAGS = -fopenmp -fopenmp-targets=$(AOMP_GPUTARGET) -target $(AOMP_CPUTARGET)
ifeq (nvptx,$(findstring nvptx,$(AOMP_GPUTARGET)))
CUDA ?= /usr/local/cuda
LFLAGS += -L$(CUDA)/lib64 -lcuda -lcudart -lelf -lffi
endif
CXXLNKFLAGS = $(host_debug_flag)
else
CXXFLAGS = $(host_debug_flag) -O3 -I${OMPIDIR/include
CXXLNKFLAGS = $(host_debug_flag)
LFLAGS =
LIBS = -lm
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
SRCS = MI-Teams-exp1.cpp
OBJS = $(SRCS:%.cc=objs/%.o)
all: objs MI-Teams-exp1
objs:
mkdir objs
MI-Teams-exp1: objs $(OBJS)
@echo
@echo linking MI-Teams-exp1
@echo
$(SETDEBUGLIB) $(CLANG) $(CXXFLAGS) $(OBJS) $(CXXLNKFLAGS) -o $@ $(LIBS) $(LFLAGS)
run: MI-Teams-exp1
$(SETDEBUGRUNENV) ./MI-Teams-exp1
objs/MI-Teams-exp1.o: MI-Teams-exp1.cpp
$(CLANG) $(CXXFLAGS) -c MI-Teams-exp1.cpp -o $@
objs/%.o: %.c
$(CLANG) $(CXXFLAGS) -c $< -o $@
.PHONY: clean
clean:
rm -f MI-Teams-exp1 objs/*.o