Skip to content
This repository was archived by the owner on Dec 17, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
42b41f4
WIP: Restructure libsparseir to move src/include/test to backend/cxx
shinaoka Oct 28, 2025
8827fe8
WIP: Move Fortran tests from backend/cxx/test/fortran to fortran/test
shinaoka Oct 28, 2025
11d30e7
WIP: Flatten backend/cxx/test/cpp to backend/cxx/test
shinaoka Oct 28, 2025
3f1f25b
WIP: Move cinterface_integration.cxx to backend/test and remove C++ A…
shinaoka Oct 28, 2025
10dcf02
Rename backend/test to backend/capi_test for C-API tests
shinaoka Oct 28, 2025
62ced59
refactor: modularize CMake structure with independent components
shinaoka Oct 28, 2025
150863d
ci: add simplified GitHub Actions workflow for C++ backend testing
shinaoka Oct 28, 2025
66448e8
fix: correct working-directory paths in GitHub Actions workflow
shinaoka Oct 28, 2025
29bd3f2
feat: add test scripts and workflows for Fortran bindings
shinaoka Oct 28, 2025
7bfac66
feat: add Python bindings test workflow
shinaoka Oct 28, 2025
9f64fa8
fix: disable fastmath for Intel Compiler to preserve xprec precision
shinaoka Oct 28, 2025
6f7696f
restore: workflows and update for restructured directory
shinaoka Oct 28, 2025
b84efa9
fix: macOS RPATH issues for Fortran tests
shinaoka Oct 28, 2025
15a3e65
fix: shell syntax error in test_with_cxx_backend.sh
shinaoka Oct 28, 2025
d009dbf
fix: remove develop branch from workflow triggers and revert meta.yam…
shinaoka Oct 28, 2025
30e7724
fix: remove unnecessary array copies and add proper error codes
shinaoka Oct 28, 2025
0d59329
fix: use correct comparison for IR coefficients
shinaoka Oct 28, 2025
9ed5905
fix: install Fortran library before running tests
shinaoka Oct 28, 2025
5749891
fix: install Fortran module files correctly
shinaoka Oct 28, 2025
b82c6b6
fix: add GNUInstallDirs for proper install paths
shinaoka Oct 28, 2025
0fc7708
fix: correct conda recipe paths - use ../../backend for proper relati…
shinaoka Oct 28, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/VersionConsistencyCheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ on:
pull_request:
branches: [main]
paths:
- 'include/sparseir/version.h'
- 'backend/cxx/include/sparseir/version.h'
- 'python/pyproject.toml'
- 'update_version.py'
push:
branches: [main]
paths:
- 'include/sparseir/version.h'
- 'backend/cxx/include/sparseir/version.h'
- 'python/pyproject.toml'
- 'update_version.py'

Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/test_cxx_backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Test C++ Backend

on:
push:
branches: [ "main", "459-restructure-directories" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

jobs:
test-cxx-backend:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v5

- name: Install dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y cmake libopenblas-dev libeigen3-dev

- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install cmake eigen openblas

- name: Build and test C++ backend
working-directory: backend/cxx
run: ./build_capi_with_tests.sh

- name: Build and test capi_test against backend
working-directory: capi_test
run: ./test_with_cxx_backend.sh

58 changes: 58 additions & 0 deletions .github/workflows/test_fortran.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Test Fortran Bindings

on:
push:
branches: [ "main", "459-restructure-directories" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

jobs:
test-fortran-gcc:
runs-on: ubuntu-latest
name: Fortran with GCC/gfortran

steps:
- uses: actions/checkout@v5

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake gfortran libopenblas-dev libeigen3-dev

- name: Build and test Fortran bindings with GCC
working-directory: fortran
run: ./test_with_cxx_backend.sh

test-fortran-intel:
runs-on: ubuntu-latest
name: Fortran with Intel compilers

steps:
- uses: actions/checkout@v5

- name: Install Intel oneAPI
run: |
# Download Intel oneAPI GPG public key
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null

# Add Intel oneAPI repository
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list

# Update and install Intel oneAPI compilers and MKL
sudo apt-get update
sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp intel-oneapi-compiler-fortran intel-oneapi-mkl-devel

- name: Install dependencies
run: |
sudo apt-get install -y cmake libeigen3-dev

- name: Build and test Fortran bindings with Intel
working-directory: fortran
run: |
source /opt/intel/oneapi/setvars.sh
export CC=icx
export CXX=icpx
export FC=ifx
./test_with_cxx_backend.sh

68 changes: 68 additions & 0 deletions .github/workflows/test_python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Test Python Bindings

on:
push:
branches:
- main
- 459-restructure-directories
pull_request:
branches:
- main
workflow_dispatch:

jobs:
test-python:
name: Test Python on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['3.10', '3.11', '3.12']

steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Install system dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
libeigen3-dev \
libopenblas-dev \
libblas-dev \
liblapack-dev

- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install eigen openblas

- name: Install uv and set the python version
uses: astral-sh/setup-uv@v7
with:
version: "0.8.15"
python-version: ${{ matrix.python-version }}

- name: Enable caching
uses: astral-sh/setup-uv@v7
with:
enable-cache: true

- name: Setup build environment
working-directory: python
run: python3 setup_build.py

- name: Run uv sync
working-directory: python
run: uv sync
env:
SPARSEIR_USE_BLAS: 1

- name: Run tests
working-directory: python
run: uv run pytest tests/ -v
env:
SPARSEIR_USE_BLAS: 1

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

# CMake
build
work_cxx

.DS_Store
.vscode/settings.json
Expand Down
40 changes: 23 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include(GNUInstallDirs)
if (NOT SPARSEIR_VERSION)
include("VersionFromHeader")
version_from_header(SPARSEIR_VERSION
HEADER "include/sparseir/version.h"
HEADER "backend/cxx/include/sparseir/version.h"
MACROS SPARSEIR_VERSION_MAJOR SPARSEIR_VERSION_MINOR SPARSEIR_VERSION_PATCH
)
message(STATUS "Extracted package version: ${SPARSEIR_VERSION}")
Expand Down Expand Up @@ -156,24 +156,24 @@ endif()
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME sparseir)

add_library(sparseir SHARED
src/utils.cpp
src/linalg.cpp
src/root.cpp
src/specfuncs.cpp
src/svd.cpp
src/sve.cpp
src/poly.cpp
src/kernel.cpp
src/gemm.cpp
src/cinterface.cpp
backend/cxx/src/utils.cpp
backend/cxx/src/linalg.cpp
backend/cxx/src/root.cpp
backend/cxx/src/specfuncs.cpp
backend/cxx/src/svd.cpp
backend/cxx/src/sve.cpp
backend/cxx/src/poly.cpp
backend/cxx/src/kernel.cpp
backend/cxx/src/gemm.cpp
backend/cxx/src/cinterface.cpp
)
if(NOT MSVC)
target_compile_options(sparseir PRIVATE -Wall -Wextra -pedantic)
endif()

target_include_directories(sparseir
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/backend/cxx/include>
$<INSTALL_INTERFACE:include>
PRIVATE
$<BUILD_INTERFACE:${xprec_SOURCE_DIR}/include>
Expand Down Expand Up @@ -235,8 +235,14 @@ if (SPARSEIR_BUILD_TESTING)
)
FetchContent_MakeAvailable(Catch2)

# Add test directory
add_subdirectory("test")
# Add test directories
add_subdirectory("backend/cxx/test")
add_subdirectory("backend/capi_test")

# Add Fortran test directory if Fortran is enabled
if(SPARSEIR_BUILD_FORTRAN)
add_subdirectory("fortran/test")
endif()
endif()

# -------------------------------------
Expand All @@ -253,9 +259,9 @@ install(TARGETS sparseir

# Install only necessary header files (C API)
install(FILES
include/sparseir/sparseir.h
include/sparseir/version.h
include/sparseir/spir_status.h
backend/cxx/include/sparseir/sparseir.h
backend/cxx/include/sparseir/version.h
backend/cxx/include/sparseir/spir_status.h
DESTINATION "${SPARSEIR_INSTALL_INCLUDEDIR}/sparseir"
COMPONENT sparseir
)
Expand Down
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions back/build_capi_with_asan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
set -e

# Get script directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"

# Create build directory
mkdir -p build
cd build

# Configure with tests enabled
cmake .. \
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX:-$HOME/opt/libsparseir} \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_FLAGS="-w -fsanitize=address -static-libasan" \
-DCMAKE_CXX_FLAGS="-w -fsanitize=address -static-libasan" \
-DCMAKE_EXE_LINKER_FLAGS="-static-libasan" \
-DSPARSEIR_BUILD_FORTRAN=OFF \
-DSPARSEIR_BUILD_TESTING=OFF \
-DSPARSEIR_USE_BLAS=ON

# Build (including tests)
cmake --build . --config Release -j 4

# Run tests
ctest --output-on-failure

echo "SparseIR was built with tests successfully."
echo "You can install it using: cd build && cmake --install ."
32 changes: 32 additions & 0 deletions back/build_optimized.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -e

# Get script directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"

# Clean build directory to ensure clean state
rm -rf build
mkdir -p build
cd build

# Configure with maximum optimization for benchmarking
cmake .. \
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX:-$HOME/opt/libsparseir} \
-DSPARSEIR_BUILD_FORTRAN=ON \
-DSPARSEIR_BUILD_TESTING=OFF \
-DSPARSEIR_USE_BLAS=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS="-O3 -DNDEBUG -g0 -march=native" \
-DCMAKE_EXE_LINKER_FLAGS="-flto" \
-DCMAKE_VERBOSE_MAKEFILE=ON

# Build with maximum parallelization
cmake --build . --config Release -- -j $(nproc)

# Install
cmake --install .

echo "Optimized SparseIR library has been built and installed successfully."
echo "Debug symbols removed, maximum optimization enabled."
File renamed without changes.
Loading
Loading