This repository was archived by the owner on Dec 17, 2025. It is now read-only.
refactor: compile-time BLAS ILP64/LP64 selection and external pointer mode#469
Merged
refactor: compile-time BLAS ILP64/LP64 selection and external pointer mode#469
Conversation
Closed
- Make BLAS mandatory: Remove SPARSEIR_USE_BLAS option - Remove unused LAPACKE option: Remove SPARSEIR_USE_LAPACKE option - Implement dynamic Fortran BLAS symbol resolution at runtime - Add ILP64/LP64 support with automatic detection (prioritize ILP64) - Add combined registration functions: spir_register_dgemm_zgemm_lp64/ilp64 - Update Python bindings to use new combined registration - Remove unused FindLAPACKE.cmake and morse_LICENCE.txt - Add run_tests.sh script for automated Python testing
- Add test-cxx-backend-ilp64 job to test ILP64 BLAS interface - Install libopenblas64-0 and libopenblas64-dev on Ubuntu - Build with -DSPARSEIR_USE_BLAS_ILP64=ON flag - Update rollup job to include ILP64 test results
- Change BLAS linking back to PRIVATE (proper encapsulation) - Add LINKER:--no-as-needed flag to prevent linker from dropping BLAS dependency - This ensures BLAS symbols are available for dlopen/dlsym at runtime - Avoids unnecessary dependency propagation to consumers - Fixes "zgemm symbol not found" errors while maintaining clean design
…_PTR - Wrap spir_register_dgemm_zgemm_* declarations in sparseir.h with #ifdef - Add clarifying comments about no BLAS symbols in external mode - Ensures registration functions are only available when needed
- Fix duplicate #else/#endif blocks in gemm.hpp
- Wrap all integer type declarations with #ifdef SPARSEIR_USE_ILP64 blocks
- Move #include statements inside namespace sparseir {} in gemm.cpp
- Remove duplicate alpha/beta declaration lines
- Ensures my_dgemm/my_zgemm functions are properly defined in namespace
- Remove #ifdef SPARSEIR_USE_BLAS from gemm.cpp - BLAS support is mandatory, so no conditional compilation needed - Fixes undefined symbol errors for my_dgemm/my_zgemm
- Rename SPARSEIR_USE_ILP64 to SPARSEIR_USE_BLAS_ILP64 for clarity - Skip BLAS detection when SPARSEIR_USE_EXTERN_FBLAS_PTR is enabled - Update sparseir.h to conditionally declare registration functions - Remove obsolete SPARSEIR_USE_BLAS references from workflows and pyproject.toml - Remove --no-as-needed linker option (no longer needed) - Update README to reflect compile-time ILP64/LP64 selection
- Add BLA_SIZEOF_INTEGER setting in capi_test/CMakeLists.txt based on SPARSEIR_USE_BLAS_ILP64 env var - Update test_with_cxx_backend.sh and run_sample.sh to support ILP64 via environment variable - Set SPARSEIR_USE_BLAS_ILP64=1 in ILP64 test workflow steps - Add parallel execution (-j) and timeout for ILP64 tests - Remove macOS Accelerate framework linking from capi_test (no longer needed)
- Set default build type to Release in CMakeLists.txt if not specified - Remove obsolete SPARSEIR_USE_BLAS option from build_capi_with_tests.sh - This ensures Release mode is used by default instead of Debug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR refactors BLAS integration to use compile-time ILP64/LP64 selection and properly handle external function pointer mode.
Changes
SPARSEIR_USE_BLASoption)SPARSEIR_USE_LAPACKEoption as it was not being usedSPARSEIR_USE_ILP64toSPARSEIR_USE_BLAS_ILP64for clarity#ifdef SPARSEIR_USE_BLAS_ILP64for interface type selection (replacing dynamic symbol resolution)SPARSEIR_USE_EXTERN_FBLAS_PTRis enabled, skipsfind_package(BLAS)and BLAS linkingspir_register_dgemm_zgemm_lp64andspir_register_dgemm_zgemm_ilp64to register both dgemm and zgemm togethersparseir.hare conditionally declared based on build configurationcore.pyto use the new combined registration functionrun_tests.shscript inpython/directory for automated testing with cleanupSPARSEIR_USE_BLASreferences from GitHub workflows andpyproject.toml--no-as-neededlinker option (no longer needed with compile-time approach)Technical Details
Two BLAS modes:
#ifdefto select ILP64 (64-bit) or LP64 (32-bit) integer types based onSPARSEIR_USE_BLAS_ILP64.SPARSEIR_USE_EXTERN_FBLAS_PTR. No BLAS linking, function pointers registered at runtime via C-API.Implementation split:
gemm_link.impl: Direct BLAS linking implementationgemm_external.impl: External function pointer implementationSPARSEIR_USE_EXTERN_FBLAS_PTRCMake changes:
SPARSEIR_USE_EXTERN_FBLAS_PTR=ON: Skipsfind_package(BLAS)and BLAS linkingSPARSEIR_USE_BLAS_ILP64=ON: SetsBLA_SIZEOF_INTEGER=8and adds compile definition for ILP64 interfaceTesting
All existing tests pass with the new implementation.