Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,31 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
- Auto-fetched: libneo, fortplot (via FetchContent)
- Optional: OpenMP (enabled by default), GVEC (experimental, off by default), CGAL (off by default)

### OpenACC GPU Builds
SIMPLE supports GPU acceleration via OpenACC with two compiler options:

**GCC 16+ with nvptx offload** (experimental):
- Requires: GCC 16+ built with `--enable-offload-targets=nvptx-none`
- Location: `/temp/AG-plasma/opt/gcc16`
- Build: `make gcc-acc`
- Test: `make gcc-acc-test`
- Clean: `make gcc-acc-clean`
- Note: GPU offloading has known memory issues with GCC 16 nvptx. Use `ACC_DEVICE_TYPE=host` for host fallback.

**NVHPC/nvfortran**:
- Requires: NVIDIA HPC SDK (nvfortran)
- Build: `make nvfortran-acc`
- Test: `make nvfortran-acc-test`
- Clean: `make nvfortran-acc-clean`

**CMake options for OpenACC**:
```bash
cmake -S . -B build -GNinja \
-DSIMPLE_ENABLE_OPENACC=ON \
-DSIMPLE_OPENACC_OFFLOAD_TARGET=nvptx \
-DCMAKE_Fortran_COMPILER=/temp/AG-plasma/opt/gcc16/bin/gfortran
```

### GVEC Integration
- Minimal GVEC library automatically built from `thirdparty/gvec/`
- Provides B-spline and cubic spline functionality for magnetic field interpolation
Expand Down
32 changes: 26 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,27 @@ option(ENABLE_OPENMP "Enable OpenMP compiler flags." ON)
option(ENABLE_COVERAGE "Enable code coverage analysis (Debug/Profile builds only)" OFF)
option(SIMPLE_DETERMINISTIC_FP "Disable fast-math for reproducible floating-point" OFF)
option(SIMPLE_ENABLE_PYTHON_TOOLS "Enable Python helpers (tests/data generation)" ON)
option(SIMPLE_ENABLE_OPENACC "Enable OpenACC offload (NVHPC only)" OFF)
option(SIMPLE_ENABLE_OPENACC "Enable OpenACC offload (NVHPC or GCC with nvptx)" OFF)
set(SIMPLE_OPENACC_OFFLOAD_TARGET "none" CACHE STRING "OpenACC offload target for GCC (none|nvptx)")
set_property(CACHE SIMPLE_OPENACC_OFFLOAD_TARGET PROPERTY STRINGS none nvptx)

# GCC OpenACC support (must be before NVHPC block to set flags early)
if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND SIMPLE_ENABLE_OPENACC)
message(STATUS "OpenACC enabled for GCC compiler")
add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:-fopenacc>)
add_link_options(-fopenacc)
# Pass OpenACC settings to libneo (must be set before find_or_fetch)
set(ENABLE_OPENACC ON CACHE BOOL "Enable OpenACC in libneo" FORCE)
set(OPENACC_OFFLOAD_TARGET "${SIMPLE_OPENACC_OFFLOAD_TARGET}" CACHE STRING "OpenACC offload target for libneo" FORCE)
if(SIMPLE_OPENACC_OFFLOAD_TARGET STREQUAL "nvptx")
message(STATUS "OpenACC offload target: nvptx-none (GPU)")
add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:-foffload=nvptx-none>)
add_link_options(-foffload=nvptx-none)
else()
message(STATUS "OpenACC offload target: none (host fallback)")
endif()
endif()

option(SIMPLE_ENABLE_DEBUG_OUTPUT "Enable debug output in hot loops" OFF)

if(SIMPLE_ENABLE_DEBUG_OUTPUT)
Expand Down Expand Up @@ -270,21 +290,21 @@ endif()
if (ENABLE_COVERAGE)
if (CMAKE_BUILD_TYPE MATCHES "Debug|Profile")
message(STATUS "Coverage analysis enabled for ${CMAKE_BUILD_TYPE} build")

# Create interface library for coverage flags to scope them to specific targets
add_library(coverage_flags INTERFACE)
target_compile_options(coverage_flags INTERFACE --coverage -fprofile-arcs -ftest-coverage)
target_link_options(coverage_flags INTERFACE --coverage -lgcov)

# Add custom target for coverage data generation
find_program(LCOV_PATH lcov)
if(LCOV_PATH)
add_custom_target(coverage
COMMAND ${CMAKE_COMMAND} -E echo "Generating coverage data..."
COMMAND ${LCOV_PATH} --capture --directory ${CMAKE_BINARY_DIR} --output-file coverage.info
--rc branch_coverage=1
--ignore-errors inconsistent
--ignore-errors mismatch
--rc branch_coverage=1
--ignore-errors inconsistent
--ignore-errors mismatch
--ignore-errors unused
COMMAND ${LCOV_PATH} --remove coverage.info
"/home/ert/code/libneo/*"
Expand Down
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,30 @@ nvfortran-acc-test: nvfortran-acc

nvfortran-acc-clean:
rm -rf $(NVHPC_ACC_BUILD_DIR)

# GCC OpenACC build targets (requires GCC 16+ with nvptx offload support)
GCC16_ROOT := /temp/AG-plasma/opt/gcc16
GCC_ACC_BUILD_DIR := build_gcc_acc

.PHONY: gcc-acc gcc-acc-test gcc-acc-configure gcc-acc-clean

gcc-acc-configure:
cmake -S . -B$(GCC_ACC_BUILD_DIR) -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_Fortran_COMPILER=$(GCC16_ROOT)/bin/gfortran \
-DCMAKE_C_COMPILER=$(GCC16_ROOT)/bin/gcc \
-DSIMPLE_ENABLE_OPENACC=ON \
-DSIMPLE_OPENACC_OFFLOAD_TARGET=nvptx \
-DENABLE_PYTHON_INTERFACE=OFF \
-DCMAKE_COLOR_DIAGNOSTICS=ON \
$(FLAGS)

gcc-acc: gcc-acc-configure
LD_LIBRARY_PATH=$(GCC16_ROOT)/lib64:$$LD_LIBRARY_PATH cmake --build $(GCC_ACC_BUILD_DIR) --config $(CONFIG)

gcc-acc-test: gcc-acc
cd $(GCC_ACC_BUILD_DIR) && LD_LIBRARY_PATH=$(GCC16_ROOT)/lib64:$$LD_LIBRARY_PATH \
ctest --test-dir test --output-on-failure $(if $(filter 1,$(VERBOSE)),-V) $(if $(TEST),-R $(TEST)) -LE "python|regression"

gcc-acc-clean:
rm -rf $(GCC_ACC_BUILD_DIR)
Loading