-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
445 lines (377 loc) · 23.2 KB
/
Copy pathMakefile
File metadata and controls
445 lines (377 loc) · 23.2 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# =============================================================================
# apple-bottom Makefile
# =============================================================================
#
# Usage:
# make Build library and examples
# make test Run correctness tests
# make bench Run performance benchmarks
# make clean Clean build artifacts
#
# =============================================================================
CC = clang
OBJC = clang
CFLAGS = -Wall -Wextra -O3 -std=c11 -DACCELERATE_NEW_LAPACK
OBJCFLAGS = -std=c++11 -Wall -Wextra -O3 -fobjc-arc -DACCELERATE_NEW_LAPACK
LDFLAGS = -lc++ -framework Metal -framework Foundation -framework Accelerate
# DD multiplication algorithm selector (v1.3 A/C investigation).
# Default: DWTimesDW2 (JMP 2017 Alg 11, MR 2022 Thm 2.7, error bound < 5u²).
# Opt-in : DWTimesDW3 (JMP 2017 Alg 12, MR 2022 Thm 2.8, error bound < 4u²).
# Invoke with `make clean && make lib DWTIMESDW3=1`. The flag is also propagated
# into the MSL compile step via MTLCompileOptions.preprocessorMacros.
ifdef DWTIMESDW3
OBJCFLAGS += -DAPPLEBOTTOM_USE_DWTIMESDW3
endif
# Dylib link flags: re-export Accelerate so host binaries linking only
# -lapplebottom still get the full 150+ BLAS/LAPACK symbols we don't
# shadow ourselves. Our own dgemm_/zgemm_ win at link time via two-level
# namespace ordering (libapplebottom appears before Accelerate).
DYLIB_LDFLAGS = -lc++ -framework Metal -framework Foundation \
-Wl,-reexport_framework,Accelerate
# Executables link against build/libapplebottom.dylib (install_name @rpath/…).
# Adding @loader_path so in-tree binaries (build/test_*, build/examples/*, build/bench_*)
# resolve the dylib sitting right next to them.
EXE_RPATH = -Wl,-rpath,@loader_path -Wl,-rpath,@loader_path/..
BUILD = build
SRC = src
INCLUDE = include
EXAMPLES = examples
.PHONY: all lib test bench bench-report bench-rect clean examples install uninstall
# =============================================================================
# Main targets
# =============================================================================
all: lib examples
@echo ""
@echo "✓ Build complete!"
@echo ""
@echo " Library: $(BUILD)/libapplebottom.a"
@echo " Examples: $(BUILD)/examples/"
@echo ""
@echo "Quick start:"
@echo " ./$(BUILD)/examples/basic_dgemm"
@echo ""
$(BUILD):
mkdir -p $(BUILD)
mkdir -p $(BUILD)/examples
# =============================================================================
# Library
# =============================================================================
$(BUILD)/apple_bottom.o: $(SRC)/apple_bottom.m $(INCLUDE)/apple_bottom.h | $(BUILD)
$(OBJC) $(OBJCFLAGS) -I$(INCLUDE) -xobjective-c++ -c $(SRC)/apple_bottom.m -o $@
$(BUILD)/blas_wrapper.o: $(SRC)/blas_wrapper.c $(INCLUDE)/apple_bottom.h | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) -c $(SRC)/blas_wrapper.c -o $@
$(BUILD)/fortran_bridge.o: $(SRC)/fortran_bridge.c $(INCLUDE)/apple_bottom.h $(SRC)/profiling/blas_profiler.h | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) -I$(SRC) -c $(SRC)/fortran_bridge.c -o $@
$(BUILD)/blas_profiler.o: $(SRC)/profiling/blas_profiler.c $(SRC)/profiling/blas_profiler.h | $(BUILD)
$(CC) $(CFLAGS) -I$(SRC) -c $(SRC)/profiling/blas_profiler.c -o $@
$(BUILD)/device_api.o: $(SRC)/device_api.m $(INCLUDE)/apple_bottom.h $(INCLUDE)/apple_bottom_device.h | $(BUILD)
$(OBJC) $(OBJCFLAGS) -I$(INCLUDE) -xobjective-c++ -c $(SRC)/device_api.m -o $@
LIB_OBJS = $(BUILD)/apple_bottom.o $(BUILD)/blas_wrapper.o \
$(BUILD)/fortran_bridge.o $(BUILD)/blas_profiler.o \
$(BUILD)/device_api.o
$(BUILD)/libapplebottom.a: $(LIB_OBJS)
ar rcs $@ $^
@echo "Built: $@"
# Shared library for Fortran linkage (QE, Yambo, …).
# install_name is set to @rpath so host binaries can locate us via -rpath at link time.
# Accelerate is re-exported so -lapplebottom alone provides full BLAS/LAPACK.
$(BUILD)/libapplebottom.dylib: $(LIB_OBJS)
$(CC) -dynamiclib -install_name @rpath/libapplebottom.dylib \
-current_version 1.3.1 -compatibility_version 1.0.0 \
$^ -o $@ $(DYLIB_LDFLAGS)
@echo "Built: $@"
dylib: $(BUILD)/libapplebottom.dylib
lib: $(BUILD)/libapplebottom.a $(BUILD)/libapplebottom.dylib
# =============================================================================
# Examples
# =============================================================================
$(BUILD)/examples/basic_dgemm: $(EXAMPLES)/01_basic_dgemm/main.c lib | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Built: $@"
examples: $(BUILD)/examples/basic_dgemm
# =============================================================================
# Benchmarks
# =============================================================================
$(BUILD)/bench_dgemm: benchmarks/bench_dgemm.c lib | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Built: $@"
$(BUILD)/bench_zgemm: benchmarks/bench_zgemm.c lib | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Built: $@"
$(BUILD)/bench_sgemm: benchmarks/bench_sgemm.c | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ $(LDFLAGS)
@echo "Built: $@"
bench: $(BUILD)/bench_dgemm $(BUILD)/bench_sgemm $(BUILD)/bench_pool $(BUILD)/bench_zgemm $(BUILD)/bench_dsyrk $(BUILD)/bench_zherk $(BUILD)/bench_async
@echo ""
@echo "═══════════════════════════════════════════════════════════════════"
@echo "DGEMM Benchmark"
@echo "═══════════════════════════════════════════════════════════════════"
./$(BUILD)/bench_dgemm
@echo ""
@echo "═══════════════════════════════════════════════════════════════════"
@echo "ZGEMM Benchmark"
@echo "═══════════════════════════════════════════════════════════════════"
./$(BUILD)/bench_zgemm
@echo ""
@echo "═══════════════════════════════════════════════════════════════════"
@echo "SGEMM Reference (AMX FP32)"
@echo "═══════════════════════════════════════════════════════════════════"
./$(BUILD)/bench_sgemm
bench-report: bench
@echo ""
@echo "═══════════════════════════════════════════════════════════════════"
@echo "Generating Benchmark Report"
@echo "═══════════════════════════════════════════════════════════════════"
@bash scripts/bench_report.sh
# =============================================================================
# Tests
# =============================================================================
$(BUILD)/test_precision: tests/test_precision.c lib | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Built: $@"
$(BUILD)/test_correctness: tests/test_correctness.c lib | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Built: $@"
$(BUILD)/test_device_api: tests/test_device_api.c lib | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Built: $@"
$(BUILD)/test_convergence: tests/verification/test_convergence.c lib | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Built: $@"
test: $(BUILD)/test_precision $(BUILD)/test_correctness $(BUILD)/test_device_api
@echo ""
@echo "═══════════════════════════════════════════════════════════════════"
@echo "Running Tests"
@echo "═══════════════════════════════════════════════════════════════════"
./$(BUILD)/test_precision
./$(BUILD)/test_correctness
./$(BUILD)/test_device_api
@echo ""
@echo "✓ All tests passed!"
test-verification: $(BUILD)/test_convergence
@echo ""
@echo "═══════════════════════════════════════════════════════════════════"
@echo "Running Verification Tests (V&V)"
@echo "═══════════════════════════════════════════════════════════════════"
./$(BUILD)/test_convergence
@echo ""
# Adversarial & system-level test suite
$(BUILD)/test_chaos: tests/test_chaos.c lib | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH) -lpthread
@echo "Built: $@"
test-chaos: $(BUILD)/test_chaos
@echo ""
@echo "═══════════════════════════════════════════════════════════════════"
@echo "Running Adversarial & System-Level Tests"
@echo "═══════════════════════════════════════════════════════════════════"
./$(BUILD)/test_chaos
# Rectangular matrix diagnostic test
$(BUILD)/test_rectangular_diag: tests/test_rectangular_diag.c lib | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Built: $@"
test-rectangular-diag: $(BUILD)/test_rectangular_diag
@echo ""
@echo "═══════════════════════════════════════════════════════════════════"
@echo "Running Rectangular Matrix Diagnostic Test"
@echo "═══════════════════════════════════════════════════════════════════"
./$(BUILD)/test_rectangular_diag
# Performance regression: save baseline or compare
bench-baseline: lib
@echo "Saving performance baseline..."
./scripts/perf_regression.sh --save
bench-regression: lib
@echo "Running performance regression check..."
./scripts/perf_regression.sh --ci
# =============================================================================
# Clean
# =============================================================================
clean:
rm -rf $(BUILD)
@echo "Cleaned build directory"
# =============================================================================
# Install (optional)
# =============================================================================
PREFIX ?= /usr/local
install: lib
install -d $(PREFIX)/lib
install -d $(PREFIX)/include
install -d $(PREFIX)/lib/pkgconfig
install -m 644 $(BUILD)/libapplebottom.a $(PREFIX)/lib/
install -m 755 $(BUILD)/libapplebottom.dylib $(PREFIX)/lib/
install -m 644 $(INCLUDE)/apple_bottom.h $(PREFIX)/include/
install -m 644 $(INCLUDE)/apple_bottom_device.h $(PREFIX)/include/
@sed -e 's|@PREFIX@|$(PREFIX)|g' \
-e 's|@VERSION@|1.3.1|g' \
applebottom.pc.in > $(PREFIX)/lib/pkgconfig/applebottom.pc
@echo "Installed to $(PREFIX)"
uninstall:
rm -f $(PREFIX)/lib/libapplebottom.a
rm -f $(PREFIX)/lib/libapplebottom.dylib
rm -f $(PREFIX)/include/apple_bottom.h
rm -f $(PREFIX)/include/apple_bottom_device.h
rm -f $(PREFIX)/lib/pkgconfig/applebottom.pc
@echo "Uninstalled from $(PREFIX)"
# =============================================================================
# Add these targets to the end of your Makefile
# =============================================================================
# Sanitizer builds (for local debugging)
.PHONY: test-asan test-ubsan
test-asan: clean
@echo "Building with AddressSanitizer..."
$(OBJC) $(OBJCFLAGS) -fsanitize=address -g -I$(INCLUDE) -xobjective-c++ -c $(SRC)/apple_bottom.m -o $(BUILD)/apple_bottom.o
$(CC) $(CFLAGS) -fsanitize=address -g -I$(INCLUDE) -c $(SRC)/blas_wrapper.c -o $(BUILD)/blas_wrapper.o
$(CC) $(CFLAGS) -fsanitize=address -g -I$(INCLUDE) -c $(SRC)/fortran_bridge.c -o $(BUILD)/fortran_bridge.o
ar rcs $(BUILD)/libapplebottom.a $(BUILD)/apple_bottom.o $(BUILD)/blas_wrapper.o $(BUILD)/fortran_bridge.o
$(CC) $(CFLAGS) -fsanitize=address -g -I$(INCLUDE) tests/test_correctness.c -o $(BUILD)/test_correctness -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Running tests with ASan..."
ASAN_OPTIONS=detect_leaks=1 ./$(BUILD)/test_correctness
test-ubsan: clean
@echo "Building with UndefinedBehaviorSanitizer..."
$(OBJC) $(OBJCFLAGS) -fsanitize=undefined -g -I$(INCLUDE) -xobjective-c++ -c $(SRC)/apple_bottom.m -o $(BUILD)/apple_bottom.o
$(CC) $(CFLAGS) -fsanitize=undefined -g -I$(INCLUDE) -c $(SRC)/blas_wrapper.c -o $(BUILD)/blas_wrapper.o
$(CC) $(CFLAGS) -fsanitize=undefined -g -I$(INCLUDE) -c $(SRC)/fortran_bridge.c -o $(BUILD)/fortran_bridge.o
ar rcs $(BUILD)/libapplebottom.a $(BUILD)/apple_bottom.o $(BUILD)/blas_wrapper.o $(BUILD)/fortran_bridge.o
$(CC) $(CFLAGS) -fsanitize=undefined -g -I$(INCLUDE) tests/test_correctness.c -o $(BUILD)/test_correctness -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Running tests with UBSan..."
./$(BUILD)/test_correctness
$(BUILD)/bench_dsyrk: benchmarks/bench_dsyrk.c lib | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Built: $@"
$(BUILD)/bench_zherk: benchmarks/bench_zherk.c lib | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Built: $@"
$(BUILD)/bench_pool: benchmarks/bench_pool.c lib | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Built: $@"
$(BUILD)/bench_async: benchmarks/bench_async.c lib | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Built: $@"
$(BUILD)/bench_dtrsm: benchmarks/bench_dtrsm.c lib | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Built: $@"
$(BUILD)/bench_paper: benchmarks/bench_paper.c lib | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Built: $@"
$(BUILD)/bench_device_residency: benchmarks/bench_device_residency.c lib | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Built: $@"
$(BUILD)/bench_rect_dgemm: benchmarks/bench_rect_dgemm.c lib | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Built: $@"
$(BUILD)/bench_rect_zgemm: benchmarks/bench_rect_zgemm.c lib | $(BUILD)
$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@ -L$(BUILD) -lapplebottom $(LDFLAGS) $(EXE_RPATH)
@echo "Built: $@"
bench-rect: $(BUILD)/bench_rect_dgemm $(BUILD)/bench_rect_zgemm
@echo ""
@echo "Built bench_rect_{dgemm,zgemm}. Run via benchmarks/scripts/run_rect_sweep.sh"
bench-paper: $(BUILD)/bench_paper
@echo ""
@echo "═══════════════════════════════════════════════════════════════════"
@echo "HPEC 2026 Paper Benchmark Suite"
@echo "═══════════════════════════════════════════════════════════════════"
./$(BUILD)/bench_paper
bench-paper-csv: $(BUILD)/bench_paper
./$(BUILD)/bench_paper --csv
# =============================================================================
# CI Targets
# =============================================================================
.PHONY: build-check ci-local verify-symbols
# Verify the dylib exports standard Fortran BLAS names (dgemm_, zgemm_)
# and that Accelerate is properly re-exported. This confirms the dylib
# is a true drop-in for Fortran host codes (QE, Yambo, …).
verify-symbols: $(BUILD)/libapplebottom.dylib
@echo ""
@echo "═══════════════════════════════════════════════════════════════════"
@echo "Verifying libapplebottom.dylib symbol exports"
@echo "═══════════════════════════════════════════════════════════════════"
@echo ""
@echo "Shadowed Fortran BLAS symbols (should be defined in our dylib):"
@nm -gU $(BUILD)/libapplebottom.dylib 2>/dev/null | grep -E " _(dgemm_|zgemm_|ab_dgemm_|ab_zgemm_)$$" \
|| (echo " ✗ MISSING standard BLAS exports" && exit 1)
@echo ""
@echo "Accelerate re-export (LC_REEXPORT_DYLIB entries):"
@otool -l $(BUILD)/libapplebottom.dylib | grep -A 2 LC_REEXPORT_DYLIB \
|| (echo " ✗ Accelerate NOT re-exported" && exit 1)
@echo ""
@echo "✓ Symbols look correct — this is a drop-in BLAS dylib"
@echo ""
# Build check: compile all source files to .o without linking
# Used by GitHub Actions to verify syntax and compilation (fast check)
build-check: | $(BUILD)
@echo ""
@echo "═══════════════════════════════════════════════════════════════════"
@echo "Build Check (compile only, no linking)"
@echo "═══════════════════════════════════════════════════════════════════"
@echo "Compiling apple_bottom.m..."
@$(OBJC) $(OBJCFLAGS) -I$(INCLUDE) -xobjective-c++ -c $(SRC)/apple_bottom.m -o $(BUILD)/apple_bottom.o
@echo "Compiling blas_wrapper.c..."
@$(CC) $(CFLAGS) -I$(INCLUDE) -c $(SRC)/blas_wrapper.c -o $(BUILD)/blas_wrapper.o
@echo "Compiling fortran_bridge.c..."
@$(CC) $(CFLAGS) -I$(INCLUDE) -I$(SRC) -c $(SRC)/fortran_bridge.c -o $(BUILD)/fortran_bridge.o
@echo "Compiling blas_profiler.c..."
@$(CC) $(CFLAGS) -I$(SRC) -c $(SRC)/profiling/blas_profiler.c -o $(BUILD)/blas_profiler.o
@echo "Compiling test_correctness.c..."
@$(CC) $(CFLAGS) -I$(INCLUDE) -c tests/test_correctness.c -o $(BUILD)/test_correctness.o
@echo "Compiling test_precision.c..."
@$(CC) $(CFLAGS) -I$(INCLUDE) -c tests/test_precision.c -o $(BUILD)/test_precision.o
@echo "Compiling test_chaos.c..."
@$(CC) $(CFLAGS) -I$(INCLUDE) -c tests/test_chaos.c -o $(BUILD)/test_chaos.o
@echo "Compiling test_convergence.c..."
@$(CC) $(CFLAGS) -I$(INCLUDE) -c tests/verification/test_convergence.c -o $(BUILD)/test_convergence.o
@echo ""
@echo "✓ All source files compile successfully"
@echo ""
# Local CI: run full test suite + convergence study, generate CI report
# Only writes CI_REPORT.txt if all tests pass (exits on first failure)
ci-local: $(BUILD)/test_precision $(BUILD)/test_correctness $(BUILD)/test_chaos $(BUILD)/test_convergence
@echo ""
@echo "═══════════════════════════════════════════════════════════════════"
@echo "CI Local Validation"
@echo "═══════════════════════════════════════════════════════════════════"
@echo ""
@echo "Running test suite..."
@./$(BUILD)/test_precision > $(BUILD)/test_precision.log 2>&1 && echo "✓ test_precision: PASS" || (echo "✗ test_precision: FAIL" && cat $(BUILD)/test_precision.log && exit 1)
@./$(BUILD)/test_correctness > $(BUILD)/test_correctness.log 2>&1 && echo "✓ test_correctness: PASS" || (echo "✗ test_correctness: FAIL" && cat $(BUILD)/test_correctness.log && exit 1)
@./$(BUILD)/test_chaos > $(BUILD)/test_chaos.log 2>&1 && echo "✓ test_chaos: PASS" || (echo "✗ test_chaos: FAIL" && cat $(BUILD)/test_chaos.log && exit 1)
@echo ""
@echo "Running convergence study (V-2)..."
@./$(BUILD)/test_convergence > $(BUILD)/test_convergence.log 2>&1 && echo "✓ test_convergence: PASS" || (echo "✗ test_convergence: FAIL" && cat $(BUILD)/test_convergence.log && exit 1)
@echo ""
@echo "Generating CI report..."
@bash -c ' \
PRECISION_PASS=$$(grep -c "✓ PASS" $(BUILD)/test_precision.log || echo 0); \
CORRECTNESS_LINE=$$(grep "Results:" $(BUILD)/test_correctness.log); \
CORRECTNESS_PASS=$$(echo "$$CORRECTNESS_LINE" | sed -E "s/.*Results: ([0-9]+) passed.*/\1/"); \
CORRECTNESS_FAIL=$$(echo "$$CORRECTNESS_LINE" | sed -E "s/.*Results: [0-9]+ passed, ([0-9]+) failed.*/\1/"); \
TOTAL=$$((PRECISION_PASS + CORRECTNESS_PASS)); \
FAILED=$$CORRECTNESS_FAIL; \
echo "GIT_SHA: $$(git rev-parse HEAD)" > $(BUILD)/CI_REPORT.txt; \
echo "GIT_BRANCH: $$(git rev-parse --abbrev-ref HEAD)" >> $(BUILD)/CI_REPORT.txt; \
echo "TIMESTAMP: $$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $(BUILD)/CI_REPORT.txt; \
echo "HOSTNAME: $$(hostname)" >> $(BUILD)/CI_REPORT.txt; \
echo "TEST_PRECISION: PASS ($$PRECISION_PASS tests)" >> $(BUILD)/CI_REPORT.txt; \
echo "TEST_CORRECTNESS: PASS ($$CORRECTNESS_PASS tests)" >> $(BUILD)/CI_REPORT.txt; \
echo "TEST_CONVERGENCE: PASS" >> $(BUILD)/CI_REPORT.txt; \
echo "TEST_TOTAL: $$TOTAL" >> $(BUILD)/CI_REPORT.txt; \
echo "TEST_PASSED: $$TOTAL" >> $(BUILD)/CI_REPORT.txt; \
echo "TEST_FAILED: $$FAILED" >> $(BUILD)/CI_REPORT.txt; \
if [ -f $(BUILD)/convergence_data.csv ]; then \
POINTS=$$(tail -n +2 $(BUILD)/convergence_data.csv | wc -l | tr -d " "); \
SHA=$$(shasum -a 256 $(BUILD)/convergence_data.csv | cut -d" " -f1); \
echo "CONVERGENCE_POINTS: $$POINTS" >> $(BUILD)/CI_REPORT.txt; \
echo "CONVERGENCE_DATA_SHA256: $$SHA" >> $(BUILD)/CI_REPORT.txt; \
else \
echo "CONVERGENCE_POINTS: 0" >> $(BUILD)/CI_REPORT.txt; \
echo "CONVERGENCE_DATA_SHA256: missing" >> $(BUILD)/CI_REPORT.txt; \
fi; \
echo "STATUS: PASS" >> $(BUILD)/CI_REPORT.txt \
'
@echo ""
@echo "═══════════════════════════════════════════════════════════════════"
@echo "✓ CI Validation Complete"
@echo "═══════════════════════════════════════════════════════════════════"
@echo ""
@cat $(BUILD)/CI_REPORT.txt
@echo ""
@echo "Report saved to: $(BUILD)/CI_REPORT.txt"
@echo ""