blob: 8f5f6194d87b9606304d3f9e12e5481588cf388a (
plain)
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
|
CC := gcc
MPICC := mpicc
NVCC := /usr/local/cuda-12.6/bin/nvcc
# NVCC := nvcc
CFLAGS += -I./src
CFLAGS += -std=gnu99
CFLAGS += -Wall -Wextra -Wno-comment -Wno-unused-function
CFLAGS += -O3 -march=native -flto -fno-semantic-interposition -fstrict-aliasing
# CFLAGS += -O0
CFLAGS += -ggdb3
# CFLAGS += -DNDEBUG
# LDFLAGS += -Wl,-rpath,$(HOME)/.guix-profile/lib/
LDFLAGS += -flto -fno-semantic-interposition
TARGETS := single-threaded multi-threaded super-computer cuda.so
SOURCES += ./src/single-threaded.c
SOURCES += ./src/multi-threaded.c
SOURCES += ./src/super-computer.c
SOURCES += ./src/utils.c
SOURCES += ./src/scanner.c
SOURCES += ./src/transaction-heap.c
SOURCES += ./src/stb_ds.c
SOURCES += ./src/cities.c
OBJECTS := $(SOURCES:.c=.o)
DEPENDENCIES := $(OBJECTS:.o=.d)
PERF_EVENTS += -e cpu-cycles
PERF_EVENTS += -e branch-misses
PERF_EVENTS += -e cache-misses
PERF_EVENTS += -e stalled-cycles-frontend
.PHONE: all
all: $(TARGETS)
single-threaded: \
./src/single-threaded.o \
./src/utils.o \
./src/scanner.o \
./src/transaction-heap.o \
./src/stb_ds.o \
./src/cities.o
$(CC) $(LDFLAGS) $^ -o $@
multi-threaded: \
./src/multi-threaded.o \
./src/utils.o \
./src/scanner.o \
./src/transaction-heap.o \
./src/stb_ds.o \
./src/cities.o
$(CC) $(LDFLAGS) -fopenmp $^ -o $@
super-computer: \
./src/super-computer.o \
./src/utils.o \
./src/scanner.o \
./src/transaction-heap.o \
./src/stb_ds.o \
./src/cities.o \
./cuda.so
$(MPICC) $(LDFLAGS) -fopenmp $^ -o $@
sandbox: \
./src/sandbox.o \
./src/utils.o \
./src/scanner.o \
./src/file-scanner.o
$(CC) $(LDFLAGS) $^ -o $@
./src/multi-threaded.o: ./src/multi-threaded.c makefile
$(CC) $(CFLAGS) -fopenmp -MMD -MP -c $< -o $@
./src/super-computer.o: ./src/super-computer.c makefile
$(MPICC) $(CFLAGS) -fopenmp -MMD -MP -c $< -o $@
./cuda.so: ./src/cuda.cu makefile
$(NVCC) -O3 -arch=sm_86 --cudart=static -lcuda -MMD -MP -shared -Xcompiler '-fPIC' $< -o $@
%.o: %.c makefile
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
./%/:
mkdir -p $@
tmp/cities.txt: res/transactions_data.csv | ./tmp/
cat $< | tail -n +2 | cut -d, -f8 | sort -u > $@
tmp/cities.c: tmp/cities.txt
gperf --output-file=$@ $<
-include $(DEPENDENCIES)
# tmp/perf.data: $(TARGET) | ./tmp
# perf record --call-graph dwarf $(PERF_EVENTS) --output=$@ ./$<
# .PHONY: perf
# perf: tmp/perf.data
# perf report -i $<
.PHONE: clean
clean:
rm -fr tmp/ $(TARGETS) $(OBJECTS) $(DEPENDENCIES) perf.data perf.data.old
|