-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
90 lines (72 loc) · 2.24 KB
/
Makefile
File metadata and controls
90 lines (72 loc) · 2.24 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
# Makefile for MPI-parallel smoke simulation
# Compiler and flags
CC = mpicc
CFLAGS = -Wall -O3 -std=c99
LDFLAGS = -lm
# Directories
SRC_DIR = src
BUILD_DIR = build
# Source files
SRCS = $(SRC_DIR)/main.c \
$(SRC_DIR)/grid.c \
$(SRC_DIR)/simulation.c \
$(SRC_DIR)/utils.c \
$(SRC_DIR)/visualization.c
# Object files (placed in build directory)
OBJS = $(SRCS:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.o)
# Target executable
TARGET = smoke_sim
# Default rule
all: $(BUILD_DIR) $(TARGET)
# Create build directory
$(BUILD_DIR):
@mkdir -p $(BUILD_DIR)
# Link step
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
# Compile step - object files go in build directory
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR)
$(CC) $(CFLAGS) -c $< -o $@
# Clean rule: removes object files, executable, vtk outputs, and data/*
clean:
@echo "Cleaning..."
-rm -f $(TARGET)
-rm -rf $(BUILD_DIR)
-rm -f out_r*_step*.vtk
-rm -rf data/*
# Clean everything including results
clean-all: clean
@echo "Cleaning all outputs..."
-rm -rf results/*.png results/*.dat
# Create necessary directories
setup:
@echo "Setting up project directories..."
@mkdir -p data results docs examples $(BUILD_DIR)
# Run performance analysis
analyze:
@echo "Running performance analysis..."
cd scripts && python3 speedup_plot.py
# Quick test with single process
test:
@echo "Running single-process test..."
mpirun -n 1 ./$(TARGET)
# Example multi-process runs
run-4:
@echo "Running with 4 processes..."
mpirun -n 4 ./$(TARGET)
run-8:
@echo "Running with 8 processes..."
mpirun -n 8 ./$(TARGET)
# Help target
help:
@echo "Available targets:"
@echo " all - Build the simulation (default)"
@echo " clean - Remove build files and data"
@echo " clean-all - Remove all build files and results"
@echo " setup - Create necessary directories"
@echo " test - Run single-process test"
@echo " run-4 - Run with 4 processes"
@echo " run-8 - Run with 8 processes"
@echo " analyze - Generate performance plots"
@echo " help - Show this help message"
.PHONY: all clean clean-all setup analyze test run-4 run-8 help