Skip to content

Conversation

ChrisRackauckas-Claude
Copy link
Contributor

Summary

  • Added runtime availability checks for MKL and OpenBLAS libraries
  • Implemented the same pattern as AppleAccelerateLU for consistent error handling
  • Ensures proper compilation when binaries are missing

Changes

This PR adds availability checks for MKL and OpenBLAS extensions following the same pattern used in AppleAccelerateLU:

  1. Added availability check functions:

    • __mkl_isavailable() - Checks if MKL library is available and has required symbols
    • __openblas_isavailable() - Checks if OpenBLAS library is available and has required symbols
  2. Added runtime checks in all solver functions:

    • All getrf! functions now check library availability before calling
    • All getrs! functions now check library availability before calling
    • Both solve! functions check availability at the start
  3. Used Libdl for dynamic library checking:

    • Attempts to load the library and verify required symbols exist
    • Returns false if library cannot be loaded or symbols are missing
    • Provides clear error messages when libraries are not available

Motivation

As mentioned in the request, this ensures that MKL and OpenBLAS calls properly compile out when the binaries are not available, similar to how AppleAccelerateLU already works. This prevents runtime errors and provides better error messages to users.

Test Plan

  • Tested locally with OpenBLAS available - solver works correctly
  • Tested locally with MKL available - solver works correctly
  • Verified error messages are shown when availability check returns false
  • CI tests should pass

🤖 Generated with Claude Code

claude added 3 commits August 20, 2025 18:10
This commit adds runtime availability checks for MKL and OpenBLAS libraries
to ensure proper error handling when the libraries are not available. The
implementation follows the same pattern as AppleAccelerateLU:

- Added __mkl_isavailable() function to check MKL library availability
- Added __openblas_isavailable() function to check OpenBLAS library availability
- Added error checks in all getrf!, getrs!, and solve! functions
- Uses Libdl to check for library symbols at runtime

This ensures that calls properly compile out when the binaries are missing
and provides clear error messages when the libraries are not available.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Per review feedback, simplified the availability checks:
- Removed try/catch blocks as they're unnecessary
- Removed Libdl symbol checking - if the binary exists via is_available(), it's fine
- Just check if the JLL module is defined and is_available() returns true

This makes the code cleaner and follows the principle that if the binary
exists, we can trust it has the required symbols.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Changed the availability check functions to use @static if for compile-time
determination, matching the pattern used in AppleAccelerate:
- Uses @static if to check @isdefined at compile time
- Returns is_available() result statically when JLL is defined
- Returns false statically when JLL is not defined

This makes the checks more efficient as they're resolved at compile time
rather than runtime.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@ChrisRackauckas ChrisRackauckas merged commit a6edf87 into SciML:main Aug 20, 2025
131 of 136 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants