-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
92 lines (72 loc) · 2.5 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
# Makefile
#
# Author: Niklas Eiling <[email protected]>
# SPDX-FileCopyrightText: 2023 Niklas Eiling <[email protected]>
# SPDX-License-Identifier: Apache-2.0
################################################################################
CC = gcc
LD = gcc
CFLAGS = -Wall -std=gnu99 -g -ggdb
BINARY = decompress
SAMPLES = samples-bin/matrixMul.compressed.fatbin \
samples-bin/matrixMul.uncompressed.fatbin \
samples-bin/nbody.uncompressed.fatbin \
samples-bin/nbody.compressed.fatbin
FILES := main.o fatbin-decompress.o utils.o
CUDA_PATH = /opt/cuda
NVCC = ${CUDA_PATH}/bin/nvcc
SMS = 75 60
CUDA_SAMPLES_RELEASE = 12.1
CUDA_SAMPLES_URL = https://github.com/NVIDIA/cuda-samples/archive/refs/tags/v${CUDA_SAMPLES_RELEASE}.tar.gz
.PHONY: all clean tests
all : $(BINARY)
%.o : %.c
$(CC) $(CFLAGS) -c -o $@ $<
$(BINARY) : $(FILES)
$(LD) $(LDFLAGS) -o $@ $^
tests: $(SAMPLES)
samples:
mkdir -p $@
wget ${CUDA_SAMPLES_URL} -O - | tar -xz --strip-components=1 -C $@
samples-bin:
mkdir -p $@
samples-bin/nbody.uncompressed.sample : samples samples-bin
make -C samples/Samples/5_Domain_Specific/nbody \
clean
make -C samples/Samples/5_Domain_Specific/nbody \
NVCCFLAGS="--no-compress -g -G" \
SMS="${SMS}" \
CPATH="samples/Common" \
CUDA_PATH=${CUDA_PATH}
cp samples/Samples/5_Domain_Specific/nbody/nbody $@
samples-bin/nbody.compressed.sample : samples samples-bin
make -C samples/Samples/5_Domain_Specific/nbody \
clean
make -C samples/Samples/5_Domain_Specific/nbody \
NVCCFLAGS="-Xfatbin --compress-all -g -G" \
SMS="${SMS}" \
CPATH="samples/Common" \
CUDA_PATH=${CUDA_PATH}
cp samples/Samples/5_Domain_Specific/nbody/nbody $@
samples-bin/matrixMul.compressed.sample : samples samples-bin
make -C samples/Samples/0_Introduction/matrixMul \
clean
make -C samples/Samples/0_Introduction/matrixMul \
NVCCFLAGS="-Xfatbin --compress-all" \
SMS="${SMS}" \
CPATH="samples/Common" \
CUDA_PATH=${CUDA_PATH}
cp samples/Samples/0_Introduction/matrixMul/matrixMul $@
samples-bin/matrixMul.uncompressed.sample : samples samples-bin
make -C samples/Samples/0_Introduction/matrixMul \
clean
make -C samples/Samples/0_Introduction/matrixMul \
NVCCFLAGS="--no-compress" \
SMS="${SMS}" \
CPATH="samples/Common" \
CUDA_PATH=${CUDA_PATH}
cp samples/Samples/0_Introduction/matrixMul/matrixMul $@
samples-bin/%.fatbin : samples-bin/%.sample
objcopy -O binary --only-section=.nv_fatbin $< $@
clean :
rm -f *.o *.d .depend *~ $(BINARY) matrixMul matrixMul.fatbin samples-bin/*