interpolation1d

done single-threded 1d interpolations; linear, rational, cubic spline, polynomial and barycentric. Still not done test functions yet. Still missing multi-core options.
This commit is contained in:
2025-09-18 20:18:27 +02:00
parent 92437e5ef1
commit 3a53b6ebf7
29 changed files with 982 additions and 15 deletions
+34 -10
View File
@@ -3,6 +3,11 @@
CC := g++
CXXFLAGS := -std=c++14 -Wall -Iinclude -O3 -march=native -fopenmp
LDFLAGS := -fopenmp
# Compiles .h files when there's been a change
DEPFLAGS := -MMD -MP
CXX ?= g++
# Directories
@@ -12,7 +17,6 @@ OBJ_DIR := obj
BIN_DIR := bin
TEST_BIN := $(BIN_DIR)/tests
# All test sources
@@ -31,6 +35,11 @@ OBJS := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRCS))
# === Test sources ===
TEST_SRCS := $(shell find test -name 'test_*.cpp')
TEST_OBJS := $(patsubst test/%.cpp, $(OBJ_DIR)/test/%.o, $(TEST_SRCS))
# Compiles .h files when there's been a change
DEPS := $(OBJS:.o=.d) $(TEST_OBJS:.o=.d) $(TEST_MAIN:.o=.d)
-include $(DEPS)
# The single file that defines TEST_MAIN / main()
TEST_MAIN := $(OBJ_DIR)/test/test_all.o
@@ -53,6 +62,12 @@ export OMP_DYNAMIC
export OMP_SCHEDULE
export OMP_DISPLAY_ENV
# What belongs to "run" vs "test"
RUN_DEPS := $(OBJS:.o=.d)
TEST_DEPS := $(TEST_OBJS:.o=.d) $(TEST_MAIN:.o=.d)
RUN_ARTIFACTS := $(TARGET) $(OBJS) $(RUN_DEPS)
TEST_ARTIFACTS := $(TEST_BIN) $(TEST_OBJS) $(TEST_MAIN) $(TEST_DEPS)
# === Default Target ===
@@ -66,11 +81,11 @@ $(TARGET): $(OBJS)
# === Compiling source files to object files ===
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) -c $< -o $@
$(CXX) $(CXXFLAGS) $(DEPFLAGS) -c $< -o $@
# === Run with OpenMP env set only for the run ===
.PHONY: run
run: $(TARGET)
run: clean-test $(TARGET)
@echo ">>> OMP_PROC_BIND=$(OMP_PROC_BIND)"
@echo ">>> OMP_PLACES=$(OMP_PLACES)"
@echo ">>> OMP_MAX_ACTIVE_LEVELS=$(OMP_MAX_LEVELS)"
@@ -96,11 +111,6 @@ run-single: ## Single-level parallel (good default)
run-nested: ## Two-level nested (outer,inner), adjust to your cores
$(MAKE) run OMP_MAX_LEVELS=2 OMP_THREADS="4,8" OMP_PROC_BIND=close OMP_PLACES=cores
# Clean up
.PHONY: clean
clean:
rm -rf $(OBJ_DIR) $(BIN_DIR)
# Optional: print debug info
.PHONY: info
info:
@@ -111,7 +121,7 @@ info:
.PHONY: test
test: $(TEST_BIN)
test: clean-run $(TEST_BIN)
@echo ">>> OMP_PROC_BIND=$(OMP_PROC_BIND)"
@echo ">>> OMP_PLACES=$(OMP_PLACES)"
@echo ">>> OMP_MAX_ACTIVE_LEVELS=$(OMP_MAX_LEVELS)"
@@ -134,4 +144,18 @@ $(TEST_BIN): $(TEST_OBJS) $(TEST_MAIN)
$(OBJ_DIR)/test/%.o: test/%.cpp
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) -c $< -o $@
$(CXX) $(CXXFLAGS) $(DEPFLAGS) -c $< -o $@
# Clean up
.PHONY: clean
clean:
rm -rf $(OBJ_DIR) $(BIN_DIR)
.PHONY: clean-run clean-test
clean-run:
@echo "Cleaning run artifacts..."
@rm -f $(RUN_ARTIFACTS)
clean-test:
@echo "Cleaning test artifacts..."
@rm -f $(TEST_ARTIFACTS)