-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
executable file
·181 lines (142 loc) · 5.54 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
#******************************************************************************
#MIT License
#
#Copyright (c) 2016 Antti-Pekka Hynninen
#Copyright (c) 2016 Oak Ridge National Laboratory (UT-Batelle)
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all
#copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.
#*******************************************************************************
#################### User Settings ####################
# C++ compiler
HOST_CC = hipcc
GPU_CC = hipcc
# CUDA compiler
CUDAC = hipcc
# Enable nvvp profiling of CPU code by using "make ENABLE_NVTOOLS=1"
# If aligned_alloc() is not available, use "make NO_ALIGNED_ALLOC=1"
# SM versions for which code is generated must be sm_30 and above
GENCODE_SM35 := -gencode arch=compute_35,code=sm_35
GENCODE_SM50 := -gencode arch=compute_50,code=sm_50
GENCODE_SM52 := -gencode arch=compute_52,code=sm_52
GENCODE_SM61 := -gencode arch=compute_61,code=sm_61
GENCODE_SM70 := -gencode arch=compute_70,code=sm_70
GENCODE_FLAGS := $(GENCODE_SM50) $(GENCODE_SM52) $(GENCODE_SM61) $(GENCODE_SM70)
#######################################################
# Detect OS
ifeq ($(shell uname -a|grep Linux|wc -l|tr -d ' '), 1)
OS = linux
endif
ifeq ($(shell uname -a|grep titan|wc -l|tr -d ' '), 1)
OS = linux
endif
ifeq ($(shell uname -a|grep Darwin|wc -l|tr -d ' '), 1)
OS = osx
endif
# Detect x86_64 vs. Power
CPU = unknown
ifeq ($(shell uname -a|grep x86_64|wc -l|tr -d ' '), 1)
CPU = x86_64
endif
ifeq ($(shell uname -a|grep ppc64|wc -l|tr -d ' '), 1)
CPU = ppc64
endif
# Set optimization level
OPTLEV = -O3
# Defines
DEFS =
ifdef ENABLE_NVTOOLS
DEFS += -DENABLE_NVTOOLS
endif
ifdef NO_ALIGNED_ALLOC
DEFS += -DNO_ALIGNED_ALLOC
endif
OBJSLIB = build/cutt.o build/cuttplan.o build/cuttkernel.o build/cuttGpuModel.o build/CudaMem.o build/CudaUtils.o build/cuttTimer.o build/cuttGpuModelKernel.o
OBJSTEST = build/cutt_test.o build/TensorTester.o build/CudaMem.o build/CudaUtils.o build/cuttTimer.o
OBJSBENCH = build/cutt_bench.o build/TensorTester.o build/CudaMem.o build/CudaUtils.o build/cuttTimer.o build/CudaMemcpy.o
OBJS = $(OBJSLIB) $(OBJSTEST) $(OBJSBENCH)
CUDAROOT = $(subst /bin/,,$(dir $(shell which $(CUDAC))))
#CFLAGS = -I${CUDAROOT}/include -std=c++11 $(DEFS) $(OPTLEV) -fPIC -D__HIP_PLATFORM_NVCC__
CFLAGS = -I${CUDAROOT}/include -std=c++11 $(DEFS) $(OPTLEV) -fPIC -D__HIP_PLATFORM_HCC__ -D__HIP_ROCclr__
ifeq ($(CPU),x86_64)
CFLAGS += -march=native
endif
#CUDA_CFLAGS = -ccbin $(GPU_CC) -I${CUDAROOT}/include -std=c++11 $(OPTLEV) -Xptxas -dlcm=ca -lineinfo $(GENCODE_FLAGS) --resource-usage -Xcompiler -fPIC -D_FORCE_INLINES -x cu -Wno-deprecated-declarations
CUDA_CFLAGS = --amdgpu-target=gfx906,gfx908 -std=c++11 $(OPTLEV) -D_FORCE_INLINES
ifeq ($(OS),osx)
CUDA_LFLAGS = -L$(CUDAROOT)/lib
else
#CUDA_LFLAGS = -L$(CUDAROOT)/lib64
endif
CUDA_LFLAGS += -fPIC
#CUDA_LFLAGS += -Llib -lcudart -lcutt
ifdef ENABLE_NVTOOLS
CUDA_LFLAGS += -lnvToolsExt
endif
all: create_build lib/libcutt.a bin/cutt_test bin/cutt_bench
create_build:
mkdir -p build
lib/libcutt.a: $(OBJSLIB)
mkdir -p lib
rm -f lib/libcutt.a
ar -cvq lib/libcutt.a $(OBJSLIB)
mkdir -p include
cp -f src/cutt.h include/cutt.h
bin/cutt_test : lib/libcutt.a $(OBJSTEST)
mkdir -p bin
$(HOST_CC) -o bin/cutt_test -L/opt/rocm-3.9.0/lib/ -lamdhip64 $(OBJSTEST) -Llib -lcutt $(CUDA_LFLAGS)
bin/cutt_bench : lib/libcutt.a $(OBJSBENCH)
mkdir -p bin
$(HOST_CC) -o bin/cutt_bench -L/opt/rocm-3.9.0/lib/ -lamdhip64 $(OBJSBENCH) -Llib -lcutt $(CUDA_LFLAGS)
clean:
rm -f $(OBJS)
rm -f build/*.d
rm -f *~
rm -f lib/libcutt.a
rm -f bin/cutt_test
rm -f bin/cutt_bench
# Pull in dependencies that already exist
-include $(OBJS:.o=.d)
# build/%.o : src/%.cu
# $(CUDAC) -c $(CUDA_CFLAGS) -o build/$*.o $<
# echo -e 'build/\c' > build/$*.d
# $(CUDAC) -M $(CUDA_CFLAGS) $< >> build/$*.d
build/CudaMemcpy.o : src/CudaMemcpy.cpp
$(CUDAC) -c $(CUDA_CFLAGS) -o $*.o $<
echo -e 'build/\c' > $*.d
$(CUDAC) -M $(CUDA_CFLAGS) $< >> $*.d
build/CudaUtils.o : src/CudaUtils.cpp
$(CUDAC) -c $(CUDA_CFLAGS) -o $*.o $<
echo -e 'build/\c' > $*.d
$(CUDAC) -M $(CUDA_CFLAGS) $< >> $*.d
build/TensorTester.o : src/TensorTester.cpp
$(CUDAC) -c $(CUDA_CFLAGS) -o $*.o $<
echo -e 'build/\c' > $*.d
$(CUDAC) -M $(CUDA_CFLAGS) $< >> $*.d
build/cuttGpuModelKernel.o : src/cuttGpuModelKernel.cpp
$(CUDAC) -c $(CUDA_CFLAGS) -o $*.o $<
echo -e 'build/\c' > $*.d
$(CUDAC) -M $(CUDA_CFLAGS) $< >> $*.d
build/cuttkernel.o : src/cuttkernel.cpp
$(CUDAC) -c $(CUDA_CFLAGS) -o $*.o $<
echo -e 'build/\c' > $*.d
$(CUDAC) -M $(CUDA_CFLAGS) $< >> $*.d
build/%.o : src/%.cpp
$(HOST_CC) -c $(CFLAGS) -o build/$*.o $<
echo -e 'build/\c' > build/$*.d
$(HOST_CC) -M $(CFLAGS) $< >> build/$*.d