diff options
| author | 2026-11-10 08:29:58 +0000 | |
|---|---|---|
| committer | 2026-11-10 08:33:56 +0000 | |
| commit | 776276d5c7e67356a880f3e31076d32cdc1c1882 (patch) | |
| tree | cbde131f3d46338adee9c67ac0f988295736bdd4 /makefile | |
| download | coursework-master.tar.gz | |
Diffstat (limited to 'makefile')
| -rw-r--r-- | makefile | 105 |
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 @@ | |||
| 1 | CC := gcc | ||
| 2 | MPICC := mpicc | ||
| 3 | NVCC := /usr/local/cuda-12.6/bin/nvcc | ||
| 4 | # NVCC := nvcc | ||
| 5 | |||
| 6 | CFLAGS += -I./src | ||
| 7 | CFLAGS += -std=gnu99 | ||
| 8 | CFLAGS += -Wall -Wextra -Wno-comment -Wno-unused-function | ||
| 9 | CFLAGS += -O3 -march=native -flto -fno-semantic-interposition -fstrict-aliasing | ||
| 10 | # CFLAGS += -O0 | ||
| 11 | CFLAGS += -ggdb3 | ||
| 12 | # CFLAGS += -DNDEBUG | ||
| 13 | |||
| 14 | # LDFLAGS += -Wl,-rpath,$(HOME)/.guix-profile/lib/ | ||
| 15 | LDFLAGS += -flto -fno-semantic-interposition | ||
| 16 | |||
| 17 | TARGETS := single-threaded multi-threaded super-computer cuda.so | ||
| 18 | SOURCES += ./src/single-threaded.c | ||
| 19 | SOURCES += ./src/multi-threaded.c | ||
| 20 | SOURCES += ./src/super-computer.c | ||
| 21 | SOURCES += ./src/utils.c | ||
| 22 | SOURCES += ./src/scanner.c | ||
| 23 | SOURCES += ./src/transaction-heap.c | ||
| 24 | SOURCES += ./src/stb_ds.c | ||
| 25 | SOURCES += ./src/cities.c | ||
| 26 | OBJECTS := $(SOURCES:.c=.o) | ||
| 27 | DEPENDENCIES := $(OBJECTS:.o=.d) | ||
| 28 | |||
| 29 | PERF_EVENTS += -e cpu-cycles | ||
| 30 | PERF_EVENTS += -e branch-misses | ||
| 31 | PERF_EVENTS += -e cache-misses | ||
| 32 | PERF_EVENTS += -e stalled-cycles-frontend | ||
| 33 | |||
| 34 | .PHONE: all | ||
| 35 | all: $(TARGETS) | ||
| 36 | |||
| 37 | single-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 | |||
| 46 | multi-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 | |||
| 55 | super-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 | |||
| 65 | sandbox: \ | ||
| 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 | |||
| 88 | tmp/cities.txt: res/transactions_data.csv | ./tmp/ | ||
| 89 | cat $< | tail -n +2 | cut -d, -f8 | sort -u > $@ | ||
| 90 | |||
| 91 | tmp/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 | ||
| 104 | clean: | ||
| 105 | rm -fr tmp/ $(TARGETS) $(OBJECTS) $(DEPENDENCIES) perf.data perf.data.old | ||
