-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
94 lines (75 loc) · 2.5 KB
/
Makefile
File metadata and controls
94 lines (75 loc) · 2.5 KB
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
# =======================
# Project-wide Makefile
# =======================
# ---- C config ----
CC := mpicc
CFLAGS := -O3 -std=c11 -Wall -Wextra
C_SRC := c/src/sim.c
C_BIN := c/sim
# ---- Python config ----
PY_VENV := python/.venv
PY := $(PY_VENV)/bin/python
PIP := $(PY_VENV)/bin/pip
PY_MAIN := python/sim.py
# ---- MPI + demo args ----
MPIRUN := mpirun
NP := 4
RUN_ARGS_C := --steps 20000 --print-every 200 --seed-mode local --periodic --viz-every 50 --viz-gif --viz-outdir c/frames
RUN_ARGS_PY := --steps 20000 --print-every 200 --seed-mode local --periodic --viz-every 50 --viz-gif --viz-outdir python/frames
# ---- Tools ----
MAGICK := magick
# ---- Phony targets ----
.PHONY: help all \
c-build c-run c-gif c-clean \
py-venv py-install py-run py-gif py-clean \
demo clean
help:
@echo "Targets:"
@echo " c-build - build C MPI sim"
@echo " c-run - run C sim with preset args"
@echo " c-gif - GIF from c/frames/*.pgm"
@echo " c-clean - remove C binary and c/frames"
@echo " py-install - uv sync --directory python (uses pyproject.tml)"
@echo " py-run - run Python sim with preset args (no activation needed)"
@echo " py-gif - GIF from python/frames/*.png"
@echo " demo - run both C and Python demos"
@echo " clean - clean both C and Python outputs"
all: c-build
# ===== C targets =====
c-build: $(C_BIN)
$(C_BIN): $(C_SRC)
$(CC) $(CFLAGS) -o $(C_BIN) $(C_SRC)
c-run: c-build
$(MPIRUN) -n $(NP) ./$(C_BIN) $(RUN_ARGS_C)
$(MAGICK) c/frames/step_*.pgm c/frames/out.gif
c-clean:
rm -f $(C_BIN)
rm -rf c/frames
# ===== Python targets =====
# create and install venv using uv
py-install:
@mkdir -p python/.logs
@if [ -f python/pyproject.toml ]; then \
uv sync --directory python >> python/.logs/uv-install.log 2>&1; \
else \
echo "No python/pyproject.toml found; skipping installs."; \
fi
# python version already creates the GIF if --viz-gif is given
py-run-sim: py-install
$(MPIRUN) -n $(NP) $(PY) $(PY_MAIN) $(RUN_ARGS_PY)
py-run-insitu: py-install
@if [ -z "$$VIRTUAL_ENV" ]; then \
echo "ERROR: No Python virtual environment is active."; \
echo ""; \
echo "Activate it first:"; \
echo " source python/.env/bin/activate"; \
exit 1; \
fi
bash ./launch-scripts/launch-insitu-python-local.sh
py-run-insitu-nix:
bash ./launch-scripts/launch-insitu-python-local.sh
py-clean:
rm -rf python/frames
# ===== Convenience =====
demo: c-run py-run
clean: c-clean py-clean