csci5451/assignments/01/Makefile
2023-10-09 04:30:22 -05:00

67 lines
2.2 KiB
Makefile

.PHONY: all handin watch-openmp watch-report rust clean
CFLAGS := -std=c11 -fopenmp \
-I/opt/homebrew/opt/libomp/include \
-I/usr/lib/gcc/aarch64-linux-gnu/11/include \
-O3 -g
LDFLAGS := -std=c11 -fopenmp -L/opt/homebrew/opt/libomp/lib -O3
RUST_SOURCES := $(shell find . -name "*.rs")
all: lc_openmp lc_pthreads
handin: zhan4854.tar.gz
clean:
rm -rf \
lc_openmp lc_pthreads \
zhan4854 zhan4854.tar.gz \
dataset/small \
*.o
zhan4854.tar.gz: common.c common.h lc_openmp.c lc_pthreads.c Makefile ASSIGNMENT.md report.pdf run_benchmark.sh
mkdir -p zhan4854
cp $^ zhan4854
tar -czvf $@ zhan4854
rm -r zhan4854
report.pdf: report.md
pandoc -o $@ $^
lc_openmp: lc_openmp.o common.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lm
lc_pthreads: lc_pthreads.o common.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lm
%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $<
## Dumb debug stuff, please ignore:
dataset/small/%.txt: generate_test_data.py
python generate_test_data.py dataset/small_data.csv dataset/small_label.csv dataset/small
dataset/mnist/%.txt: generate_test_data.py
python generate_test_data.py dataset/MNIST_data.csv dataset/MNIST_label.csv dataset/mnist
watch-report:
watchexec -c clear -e md 'make report.pdf'
watch-openmp:
watchexec -c clear -e Makefile,c,h 'make lc_openmp && ./lc_openmp ./dataset/small_data.csv ./dataset/small_label.csv 10 2'
run-pthreads-small: lc_pthreads dataset/small/train_data.txt
./lc_pthreads dataset/small/train_data.txt dataset/small/train_label.txt 10 2 dataset/small/test_data.txt dataset/small/test_label.txt
run-pthreads-mnist: lc_pthreads dataset/mnist/train_data.txt
./lc_pthreads dataset/mnist/train_data.txt dataset/mnist/train_label.txt 10 8 dataset/mnist/test_data.txt dataset/mnist/test_label.txt
run-openmp-small: lc_openmp dataset/small/train_data.txt
./lc_openmp dataset/small/train_data.txt dataset/small/train_label.txt 10 2 dataset/small/test_data.txt dataset/small/test_label.txt
run-openmp-mnist: lc_openmp dataset/mnist/train_data.txt
./lc_openmp dataset/mnist/train_data.txt dataset/mnist/train_label.txt 10 8 dataset/mnist/test_data.txt dataset/mnist/test_label.txt
rust: $(RUST_SOURCES)
cargo run -- ${BASE_PATH}/dataset/{small_data.csv,small_label.csv} 10 2