-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile.sycl
165 lines (132 loc) · 4.66 KB
/
Makefile.sycl
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
#******************************************************************************
#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 = icpx
GPU_CC = icpx
#######################################################
# 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 = -DLIBRETT_USES_SYCL
ifdef ENABLE_NVTOOLS
DEFS += -DENABLE_NVTOOLS
endif
ifdef NO_ALIGNED_ALLOC
DEFS += -DNO_ALIGNED_ALLOC
endif
OBJSLIB = build/librett.o build/plan.o build/kernel.o build/GpuModel.o build/GpuUtils.o build/Timer.o build/GpuModelKernel.o
OBJSTEST1 = build/example.o build/TensorTester.o build/GpuUtils.o build/Timer.o
OBJSTESTX = build/librett_test.o build/TensorTester.o build/GpuUtils.o build/Timer.o
OBJSBENCH = build/librett_bench.o build/TensorTester.o build/GpuUtils.o build/Timer.o build/GpuMemcpy.o
OBJS = $(OBJSLIB) $(OBJSTEST1) $(OBJSTESTX) $(OBJSBENCH)
GPUROOT = $(subst /bin/,,$(dir $(shell which $(GPU_CC))))
GPUROOT = $(GPU_PATH)
# JiT compilation
CFLAGS = -Isrc -std=c++17 $(DEFS) $(OPTLEV) -fPIC
LDFLAGS =
# AoT compilation
CFLAGS += -sycl-std=2020 -fsycl -fsycl-device-code-split=per_kernel -fsycl-unnamed-lambda -Wsycl-strict -fsycl-targets=spir64_gen
LDFLAGS += -Xsycl-target-backend "-device 12.60.7"
ifeq ($(CPU),x86_64)
CFLAGS += -march=native
endif
# Sub-group size (supported sizes are 16 and 32 only)
SIMD32 = -DLIBRETT_SUBGROUP_SIZE32 -fsycl-default-sub-group-size=32
SIMD16 = -DLIBRETT_SUBGROUP_SIZE16 -fsycl-default-sub-group-size=16
# make sycl groupsize=32
ifeq ($(groupsize),32)
# compile with the group size 32
CFLAGS += $(SIMD32)
else
# compile with the group size 16; default
CFLAGS += $(SIMD16)
endif
# make sycl tests=all
# compile all tests allowed by the hardware platform (sycl, hip, cuda)
# test 5 will fail with SIMD16
ifneq ($(tests),all)
# compile portable tests only; default
CFLAGS += -DPERFTEST
endif
ifeq ($(OS),osx)
GPU_LFLAGS = -L$(GPUROOT)/lib
else
GPU_LFLAGS = -L$(GPUROOT)/lib64
endif
GPU_LFLAGS += -fPIC
GPU_LFLAGS += -Llib -lrett
all: create_build lib/librett.a bin/example bin/librett_test bin/librett_bench
create_build:
mkdir -p build
lib/librett.a: $(OBJSLIB)
mkdir -p lib
rm -f lib/librett.a
ar -cvq lib/librett.a $(OBJSLIB)
mkdir -p include
cp -f src/librett.h include/librett.h
bin/example : lib/librett.a $(OBJSTEST1)
mkdir -p bin
$(HOST_CC) -o bin/example $(CFLAGS) $(LDFLAGS) $(OBJSTEST1) lib/librett.a
bin/librett_test : lib/librett.a $(OBJSTESTX)
mkdir -p bin
$(HOST_CC) -o bin/librett_test $(CFLAGS) $(LDFLAGS) $(OBJSTESTX) lib/librett.a
bin/librett_bench : lib/librett.a $(OBJSBENCH)
mkdir -p bin
$(HOST_CC) -o bin/librett_bench $(CFLAGS) $(LDFLAGS) $(OBJSBENCH) lib/librett.a
clean:
rm -f $(OBJS)
rm -f build/*.d
rm -f build/*.i
rm -f *~
rm -f lib/librett.a
rm -f bin/example
rm -f bin/librett_test
rm -f bin/librett_bench
build/%.o : src/%.cpp
$(HOST_CC) -c $(CFLAGS) -o build/$*.o $<
$(HOST_CC) -M $(CFLAGS) $< > build/$*.d
# $(HOST_CC) -E $(CFLAGS) $< > build/$*.i
build/%.o : tests/%.cpp
$(HOST_CC) -c $(CFLAGS) -o build/$*.o $<
$(HOST_CC) -M $(CFLAGS) $< >> build/$*.d