aboutsummaryrefslogtreecommitdiff
path: root/makefile
diff options
context:
space:
mode:
Diffstat (limited to 'makefile')
-rw-r--r--makefile105
1 files changed, 105 insertions, 0 deletions
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..8f5f619
--- /dev/null
+++ b/makefile
@@ -0,0 +1,105 @@
1CC := gcc
2MPICC := mpicc
3NVCC := /usr/local/cuda-12.6/bin/nvcc
4# NVCC := nvcc
5
6CFLAGS += -I./src
7CFLAGS += -std=gnu99
8CFLAGS += -Wall -Wextra -Wno-comment -Wno-unused-function
9CFLAGS += -O3 -march=native -flto -fno-semantic-interposition -fstrict-aliasing
10# CFLAGS += -O0
11CFLAGS += -ggdb3
12# CFLAGS += -DNDEBUG
13
14# LDFLAGS += -Wl,-rpath,$(HOME)/.guix-profile/lib/
15LDFLAGS += -flto -fno-semantic-interposition
16
17TARGETS := single-threaded multi-threaded super-computer cuda.so
18SOURCES += ./src/single-threaded.c
19SOURCES += ./src/multi-threaded.c
20SOURCES += ./src/super-computer.c
21SOURCES += ./src/utils.c
22SOURCES += ./src/scanner.c
23SOURCES += ./src/transaction-heap.c
24SOURCES += ./src/stb_ds.c
25SOURCES += ./src/cities.c
26OBJECTS := $(SOURCES:.c=.o)
27DEPENDENCIES := $(OBJECTS:.o=.d)
28
29PERF_EVENTS += -e cpu-cycles
30PERF_EVENTS += -e branch-misses
31PERF_EVENTS += -e cache-misses
32PERF_EVENTS += -e stalled-cycles-frontend
33
34.PHONE: all
35all: $(TARGETS)
36
37single-threaded: \
38 ./src/single-threaded.o \
39 ./src/utils.o \
40 ./src/scanner.o \
41 ./src/transaction-heap.o \
42 ./src/stb_ds.o \
43 ./src/cities.o
44 $(CC) $(LDFLAGS) $^ -o $@
45
46multi-threaded: \
47 ./src/multi-threaded.o \
48 ./src/utils.o \
49 ./src/scanner.o \
50 ./src/transaction-heap.o \
51 ./src/stb_ds.o \
52 ./src/cities.o
53 $(CC) $(LDFLAGS) -fopenmp $^ -o $@
54
55super-computer: \
56 ./src/super-computer.o \
57 ./src/utils.o \
58 ./src/scanner.o \
59 ./src/transaction-heap.o \
60 ./src/stb_ds.o \
61 ./src/cities.o \
62 ./cuda.so
63 $(MPICC) $(LDFLAGS) -fopenmp $^ -o $@
64
65sandbox: \
66 ./src/sandbox.o \
67 ./src/utils.o \
68 ./src/scanner.o \
69 ./src/file-scanner.o
70 $(CC) $(LDFLAGS) $^ -o $@
71
72./src/multi-threaded.o: ./src/multi-threaded.c makefile
73 $(CC) $(CFLAGS) -fopenmp -MMD -MP -c $< -o $@
74
75./src/super-computer.o: ./src/super-computer.c makefile
76 $(MPICC) $(CFLAGS) -fopenmp -MMD -MP -c $< -o $@
77
78./cuda.so: ./src/cuda.cu makefile
79 $(NVCC) -O3 -arch=sm_86 --cudart=static -lcuda -MMD -MP -shared -Xcompiler '-fPIC' $< -o $@
80
81
82%.o: %.c makefile
83 $(CC) $(CFLAGS) -MMD -MP -c $< -o $@
84
85./%/:
86 mkdir -p $@
87
88tmp/cities.txt: res/transactions_data.csv | ./tmp/
89 cat $< | tail -n +2 | cut -d, -f8 | sort -u > $@
90
91tmp/cities.c: tmp/cities.txt
92 gperf --output-file=$@ $<
93
94-include $(DEPENDENCIES)
95
96# tmp/perf.data: $(TARGET) | ./tmp
97# perf record --call-graph dwarf $(PERF_EVENTS) --output=$@ ./$<
98
99# .PHONY: perf
100# perf: tmp/perf.data
101# perf report -i $<
102
103.PHONE: clean
104clean:
105 rm -fr tmp/ $(TARGETS) $(OBJECTS) $(DEPENDENCIES) perf.data perf.data.old