Skip to content

Link to OpenBLAS on Linux#806

Merged
yungyuc merged 1 commit into
solvcon:masterfrom
yungyuc:feat/openblas
May 23, 2026
Merged

Link to OpenBLAS on Linux#806
yungyuc merged 1 commit into
solvcon:masterfrom
yungyuc:feat/openblas

Conversation

@yungyuc
Copy link
Copy Markdown
Member

@yungyuc yungyuc commented May 23, 2026

Link EigenSystem against OpenBLAS on Linux to mirror the Accelerate/vecLib backend on Apple (PR #768). Changes include:

  • CMake: optional find_library(openblas) defines MM_HAS_VENDOR_LAPACK; the APPLE branch defines the same.
  • Add a new file cpp/modmesh/linalg/lapack_compat.hpp to abstract the compatibility layer for BLAS/LAPACK.
  • Source and binding guards switch from __APPLE__ to MM_HAS_VENDOR_LAPACK.
  • Unit-testing skips on mm.EigenSystem is None instead of sys.platform != "darwin".
  • CI: add libopenblas-dev to the Linux apt-get list.

For issue #804.

Link `EigenSystem` against OpenBLAS on Linux to mirror the Accelerate/vecLib
backend on Apple (PR solvcon#768).  Changes include:

- CMake: optional `find_library(openblas)` defines `MM_HAS_VENDOR_LAPACK`; the
  `APPLE` branch defines the same.
- Add a new file `cpp/modmesh/linalg/lapack_compat.hpp` to abstract the
  compatibility layer for BLAS/LAPACK.
- Source and binding guards switch from `__APPLE__` to `MM_HAS_VENDOR_LAPACK`.
- Unit-testing skips on `mm.EigenSystem is None` instead of `sys.platform !=
  "darwin"`.
- CI: add `libopenblas-dev` to the Linux apt-get list.

For issue solvcon#804.
sudo apt-get -qy install kitware-archive-keyring
sudo apt-get -qy install \
sudo curl git build-essential make cmake libc6-dev gcc g++ \
libopenblas-dev \
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use OpenBLAS on Linux for now.

{

#ifdef __APPLE__
#ifdef MM_HAS_VENDOR_LAPACK
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a clearer fencing. Move platform abstration in the macro.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet.

#ifdef __APPLE__
using lapack_int_t = __LAPACK_int;
#else
using lapack_int_t = int;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross-platform type.

// NOLINTNEXTLINE(misc-header-include-cycle)
#include <Accelerate/Accelerate.h>
#else // __APPLE__
extern "C" void dgeev_(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For non-Apple platform, use the distinct declaration for now. It should be enhanced to use upstream header in the future, when we use more LAPACK subroutines in the future (e.g., for issue #790).

Comment thread tests/test_linalg.py

@unittest.skipUnless(sys.platform == "darwin",
"mm.EigenSystem requires Apple vecLib")
@unittest.skipIf(mm.EigenSystem is None,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the existence of EigenSystem to detect instead of platform.

@yungyuc yungyuc self-assigned this May 23, 2026
@yungyuc yungyuc added performance Profiling, runtime, and memory consumption array Multi-dimensional array implementation labels May 23, 2026
@yungyuc yungyuc moved this from Todo to In Progress in tensor operations May 23, 2026
@yungyuc yungyuc marked this pull request as ready for review May 23, 2026 08:28
@yungyuc
Copy link
Copy Markdown
Member Author

yungyuc commented May 23, 2026

@ThreeMonth03 @KHLee529 @tigercosmos @chestercheng please help take a look.

@yungyuc yungyuc merged commit 2cbc729 into solvcon:master May 23, 2026
14 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in tensor operations May 23, 2026
@yungyuc yungyuc deleted the feat/openblas branch May 23, 2026 08:30
@yungyuc yungyuc linked an issue May 23, 2026 that may be closed by this pull request
@tigercosmos
Copy link
Copy Markdown
Collaborator

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

array Multi-dimensional array implementation performance Profiling, runtime, and memory consumption

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add OpenBLAS-backed EigenSystem build on Ubuntu 24.04 Linux

2 participants