-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
169 lines (138 loc) · 7.44 KB
/
Makefile
File metadata and controls
169 lines (138 loc) · 7.44 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
CONFIG ?= Release
FLAGS ?=
BUILD_DIR := build
BUILD_NINJA := $(BUILD_DIR)/build.ninja
# Common ctest command with optional verbose and test name filtering
CTEST_CMD = cd $(BUILD_DIR) && ctest --test-dir test --output-on-failure $(if $(filter 1,$(VERBOSE)),-V) $(if $(TEST),-R "$(TEST)")
CTEST_CMD_NOPY = cd $(BUILD_DIR) && SIMPLE_ENABLE_PYTHON_TOOLS=0 ctest --test-dir test --output-on-failure $(if $(filter 1,$(VERBOSE)),-V) $(if $(TEST),-R "$(TEST)")
NVHPC_CTEST_CMD = cd $(NVHPC_BUILD_DIR) && ACC_DEVICE_TYPE=HOST ACC_DEVICE_NUM=0 SIMPLE_ENABLE_PYTHON_TOOLS=0 ctest --test-dir test --output-on-failure $(if $(filter 1,$(VERBOSE)),-V) $(if $(TEST),-R "$(TEST)")
# NVIDIA HPC SDK paths for nvfortran builds
NVHPC_ROOT := /opt/nvidia/hpc_sdk/Linux_x86_64/25.11
NVHPC_HPCX := $(NVHPC_ROOT)/comm_libs/13.0/hpcx/hpcx-2.25.1/ompi
NVHPC_BUILD_DIR := build_nvfortran
NVHPC_ACC_BUILD_DIR := build_nvfortran_acc
.PHONY: all configure reconfigure build build-deterministic build-deterministic-nopy test test-nopy test-fast test-slow test-regression test-all test-golden-main test-golden-tag test-golden install clean nvfortran nvfortran-test nvfortran-test-nopy nvfortran-configure nvfortran-clean
.PHONY: nvfortran-acc nvfortran-acc-test nvfortran-acc-test-nopy nvfortran-acc-configure nvfortran-acc-clean
all: build
$(BUILD_NINJA):
cmake -S . -B$(BUILD_DIR) -GNinja -DCMAKE_BUILD_TYPE=$(CONFIG) -DCMAKE_COLOR_DIAGNOSTICS=ON $(FLAGS)
configure: $(BUILD_NINJA)
reconfigure:
cmake -S . -B$(BUILD_DIR) -GNinja -DCMAKE_BUILD_TYPE=$(CONFIG) -DCMAKE_COLOR_DIAGNOSTICS=ON
build: configure
cmake --build $(BUILD_DIR) --config $(CONFIG)
# Test targets
# Usage: make [test-target] [TEST=test_name] [VERBOSE=1]
# Example: make test TEST=test_gvec VERBOSE=1
# Example: make test-golden-main TEST=classifier VERBOSE=1
# Run all tests except regression tests (default)
test: build-deterministic
$(CTEST_CMD) -LE "regression"
# Run all non-Python tests (exclude python + regression)
test-nopy: build-deterministic
$(CTEST_CMD_NOPY) -LE "python|regression"
# Run only fast tests (exclude slow and regression tests)
test-fast: build-deterministic
$(CTEST_CMD) -LE "slow|regression|performance|scalability"
# Run only slow tests
test-slow: build-deterministic
$(CTEST_CMD) -L "slow" -LE "regression|performance|scalability"
# Run only regression tests (requires deterministic FP build without Python interface)
test-regression: build-deterministic-nopy
$(CTEST_CMD) -L "regression"
# Build with deterministic floating-point for regression tests
# Keeps CODE intact so local dependency paths are respected
# Patches libneo to also use deterministic FP (no -ffast-math)
build-deterministic:
@echo "Building with deterministic FP..."
cmake -S . -B$(BUILD_DIR) -GNinja -DCMAKE_BUILD_TYPE=$(CONFIG) -DSIMPLE_DETERMINISTIC_FP=ON -DCMAKE_COLOR_DIAGNOSTICS=ON $(FLAGS)
@LIBNEO_CMAKE="$(BUILD_DIR)/_deps/libneo-src/CMakeLists.txt"; \
if [ -f "$$LIBNEO_CMAKE" ] && grep -q "\-ffast-math" "$$LIBNEO_CMAKE" 2>/dev/null; then \
echo "Patching libneo for deterministic FP..."; \
sed 's/-ffast-math[[:space:]]*-ffp-contract=fast/-ffp-contract=off/g' "$$LIBNEO_CMAKE" > "$$LIBNEO_CMAKE.tmp" && mv "$$LIBNEO_CMAKE.tmp" "$$LIBNEO_CMAKE"; \
sed 's/-ffast-math/-ffp-contract=off/g' "$$LIBNEO_CMAKE" > "$$LIBNEO_CMAKE.tmp" && mv "$$LIBNEO_CMAKE.tmp" "$$LIBNEO_CMAKE"; \
echo "Reconfiguring after libneo patch..."; \
cmake -S . -B$(BUILD_DIR) -GNinja -DCMAKE_BUILD_TYPE=$(CONFIG) -DSIMPLE_DETERMINISTIC_FP=ON -DCMAKE_COLOR_DIAGNOSTICS=ON $(FLAGS); \
fi
cmake --build $(BUILD_DIR) --config $(CONFIG)
# Deterministic build matching golden record reference configuration (Python OFF)
build-deterministic-nopy:
@echo "Building with deterministic FP and Python interface OFF (golden record reference)..."
cmake -S . -B$(BUILD_DIR) -GNinja -DCMAKE_BUILD_TYPE=$(CONFIG) -DSIMPLE_DETERMINISTIC_FP=ON -DENABLE_PYTHON_INTERFACE=OFF -DCMAKE_COLOR_DIAGNOSTICS=ON $(FLAGS)
@LIBNEO_CMAKE="$(BUILD_DIR)/_deps/libneo-src/CMakeLists.txt"; \
if [ -f "$$LIBNEO_CMAKE" ] && grep -q "\-ffast-math" "$$LIBNEO_CMAKE" 2>/dev/null; then \
echo "Patching libneo for deterministic FP..."; \
sed 's/-ffast-math[[:space:]]*-ffp-contract=fast/-ffp-contract=off/g' "$$LIBNEO_CMAKE" > "$$LIBNEO_CMAKE.tmp" && mv "$$LIBNEO_CMAKE.tmp" "$$LIBNEO_CMAKE"; \
sed 's/-ffast-math/-ffp-contract=off/g' "$$LIBNEO_CMAKE" > "$$LIBNEO_CMAKE.tmp" && mv "$$LIBNEO_CMAKE.tmp" "$$LIBNEO_CMAKE"; \
echo "Reconfiguring after libneo patch..."; \
cmake -S . -B$(BUILD_DIR) -GNinja -DCMAKE_BUILD_TYPE=$(CONFIG) -DSIMPLE_DETERMINISTIC_FP=ON -DENABLE_PYTHON_INTERFACE=OFF -DCMAKE_COLOR_DIAGNOSTICS=ON $(FLAGS); \
fi
cmake --build $(BUILD_DIR) --config $(CONFIG)
# Run all tests including regression tests
test-all: build
$(CTEST_CMD)
# Golden record test target
# Compares current branch against main to enforce strict numerical reproducibility
# Any differences must be manually reviewed before merging
test-golden: build-deterministic-nopy
cd $(BUILD_DIR) && ctest --output-on-failure $(if $(filter 1,$(VERBOSE)),-V) -L "golden_record" $(if $(TEST),-R "$(TEST)")
# Golden record tests without deterministic FP (faster, for local iteration only)
test-golden-fast: build
cd $(BUILD_DIR) && ctest --output-on-failure $(if $(filter 1,$(VERBOSE)),-V) -L "golden_record" $(if $(TEST),-R "$(TEST)")
doc: configure
cmake --build --preset default --target doc
fpm:
fpm build
clean:
rm -rf $(BUILD_DIR)
# NVIDIA nvfortran build targets
# Uses NVIDIA HPC SDK with HPC-X MPI and proper CUDA setup
nvfortran-configure:
NVHPC_CUDA_HOME=/opt/cuda \
cmake -S . -B$(NVHPC_BUILD_DIR) -GNinja \
-DCMAKE_BUILD_TYPE=$(CONFIG) \
-DCMAKE_Fortran_COMPILER=nvfortran \
-DCMAKE_C_COMPILER=nvc \
-DMPI_HOME=$(NVHPC_HPCX) \
-DMPI_C_COMPILER=$(NVHPC_HPCX)/bin/mpicc \
-DMPI_Fortran_COMPILER=$(NVHPC_HPCX)/bin/mpifort \
-DSIMPLE_DETERMINISTIC_FP=ON \
-DENABLE_PYTHON_INTERFACE=OFF \
-DSIMPLE_ENABLE_PYTHON_TOOLS=OFF \
-DCMAKE_COLOR_DIAGNOSTICS=ON \
$(FLAGS)
nvfortran: nvfortran-configure
NVHPC_CUDA_HOME=/opt/cuda cmake --build $(NVHPC_BUILD_DIR) --config $(CONFIG)
nvfortran-test-nopy: nvfortran
$(NVHPC_CTEST_CMD) -LE "python|regression"
# NVHPC test target with optional filtering.
# Usage: make nvfortran-test [TEST=test_name] [VERBOSE=1]
nvfortran-test: nvfortran
$(NVHPC_CTEST_CMD) -LE "regression"
nvfortran-clean:
rm -rf $(NVHPC_BUILD_DIR)
nvfortran-acc-configure:
NVHPC_CUDA_HOME=/opt/cuda \
cmake -S . -B$(NVHPC_ACC_BUILD_DIR) -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_Fortran_COMPILER=nvfortran \
-DCMAKE_C_COMPILER=nvc \
-DMPI_HOME=$(NVHPC_HPCX) \
-DMPI_C_COMPILER=$(NVHPC_HPCX)/bin/mpicc \
-DMPI_Fortran_COMPILER=$(NVHPC_HPCX)/bin/mpifort \
-DSIMPLE_DETERMINISTIC_FP=ON \
-DSIMPLE_ENABLE_OPENACC=ON \
-DENABLE_PYTHON_INTERFACE=OFF \
-DSIMPLE_ENABLE_PYTHON_TOOLS=OFF \
-DCMAKE_COLOR_DIAGNOSTICS=ON \
$(FLAGS)
nvfortran-acc: nvfortran-acc-configure
NVHPC_CUDA_HOME=/opt/cuda cmake --build $(NVHPC_ACC_BUILD_DIR) --config $(CONFIG)
nvfortran-acc-test-nopy: nvfortran-acc
cd $(NVHPC_ACC_BUILD_DIR) && ACC_DEVICE_TYPE=NVIDIA ACC_DEVICE_NUM=0 SIMPLE_ENABLE_PYTHON_TOOLS=0 \
ctest --test-dir test --output-on-failure $(if $(filter 1,$(VERBOSE)),-V) $(if $(TEST),-R $(TEST)) -LE "python|regression"
nvfortran-acc-test: nvfortran-acc
cd $(NVHPC_ACC_BUILD_DIR) && ACC_DEVICE_TYPE=NVIDIA ACC_DEVICE_NUM=0 SIMPLE_ENABLE_PYTHON_TOOLS=0 \
ctest --test-dir test --output-on-failure $(if $(filter 1,$(VERBOSE)),-V) $(if $(TEST),-R $(TEST)) -LE "regression"
nvfortran-acc-clean:
rm -rf $(NVHPC_ACC_BUILD_DIR)