From 776276d5c7e67356a880f3e31076d32cdc1c1882 Mon Sep 17 00:00:00 2001 From: Martin Michalec Date: Tue, 10 Nov 2026 11:29:58 +0300 Subject: publish --- makefile | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 makefile (limited to 'makefile') diff --git a/makefile b/makefile new file mode 100644 index 0000000..8f5f619 --- /dev/null +++ b/makefile @@ -0,0 +1,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 -- cgit v1.3.1