Skip to content

Add support of framework Accelerate for MacOS#1371

Open
foxtran wants to merge 6 commits intogrimme-lab:mainfrom
foxtran:fix/Accelerate
Open

Add support of framework Accelerate for MacOS#1371
foxtran wants to merge 6 commits intogrimme-lab:mainfrom
foxtran:fix/Accelerate

Conversation

@foxtran
Copy link
Copy Markdown
Contributor

@foxtran foxtran commented Dec 14, 2025

This patch masks old buggy implementation of BLAS/LAPACK from Apple Accelerate with fixed version via aliasing. New implementation is available since MacOS 13.3, and has suffix $NEWLAPACK for LP64 mode, ILP64 mode has syffix $NEWLAPACK$ILP64. However, new implementation still has incompatible interface for cdotc, cdotu, zdotc, zdotu. Fortunately, xtb does not use them.

I've masked all used BLAS/LAPACK routines which are used at the current moment. Better solution is to provide explicit interfaces/masking to BLAS/LAPACK in source code.

Closes #1319

@toxtran toxtran mentioned this pull request Dec 15, 2025
2 tasks
@foxtran foxtran force-pushed the fix/Accelerate branch 2 times, most recently from 6484775 to 88a1d62 Compare December 15, 2025 09:52
Comment thread meson_options.txt Outdated
Copy link
Copy Markdown
Member

@awvwgk awvwgk left a comment

Choose a reason for hiding this comment

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

I am not too happy with this change because it adds a long list of flags globally. Would it be possible to implement this on the source level by overriding the BLAS / LAPACK interfaces with an extra bind(c, name="_dxyz$NEWLAPACK")?

@foxtran
Copy link
Copy Markdown
Contributor Author

foxtran commented Dec 15, 2025

Would it be possible to implement this on the source level by overriding the BLAS / LAPACK interfaces with an extra bind(c, name="_dxyz$NEWLAPACK")?

Actually, I have a library for doing this... However, it requires to update all deps of xtb and this is really painful.

@foxtran
Copy link
Copy Markdown
Contributor Author

foxtran commented Dec 15, 2025

And one has to instrument whole xtb source code with these interfaces. For example, here:

real(wp) :: ddot, thrs, scal, damp, dampO,dampD,thr

and here:

xtb/src/bfgs.f90

Lines 144 to 147 in 6d44803

dds = ddot(nat3,dx,1,dx,1)
if(dds > thrs) then
ddtd = ddot(nat3,tvec,1,dx,1)/dds

ddot is used without mctc interface. So, it is a big work.

For MRCC, I solved this problem mainly with patched old compiler, but it can not understand xtb source code, unfortunately.

@philipturner
Copy link
Copy Markdown

While trying to inject a custom DSYEVD or SSYEVD kernel, it was troublesome to tabulate all possible linear algebra functions used in xTB, and then create a wrapper library that calls standard BLAS for every call except xSYEVD. If we did have a clear way to selectively migrate specific BLAS functions to custom libraries, that would help a little bit with future performance improvements.

https://github.com/philipturner/nanotech-code-archive/blob/main/swift-xtb/Experiments/PerformancePrediction/Trampoline.swift

However, at some point, for example to switch between FP64 and FP32 based on convergence criteria, the client would have to recompile xTB from source. This is just food for thought.

foxtran added 6 commits April 8, 2026 14:21
Signed-off-by: Igor S. Gerasimov <foxtranigor@gmail.com>
Signed-off-by: Igor S. Gerasimov <foxtranigor@gmail.com>
Signed-off-by: Igor S. Gerasimov <foxtranigor@gmail.com>
Signed-off-by: Igor S. Gerasimov <foxtranigor@gmail.com>
Signed-off-by: Igor S. Gerasimov <foxtranigor@gmail.com>
Signed-off-by: Igor S. Gerasimov <foxtranigor@gmail.com>
@foxtran
Copy link
Copy Markdown
Contributor Author

foxtran commented Apr 8, 2026

Hmm.. Something is broken...

@foxtran
Copy link
Copy Markdown
Contributor Author

foxtran commented Apr 8, 2026

@thfroitzheim, ping me next time when you want to update code. Something goes wrong.

@thfroitzheim
Copy link
Copy Markdown
Member

We wanted to check if your addition of accelarate would fix the current problem on macos in #1396. But it doesn't seem to be the case. Everything else still seems to work here.

@foxtran
Copy link
Copy Markdown
Contributor Author

foxtran commented Apr 8, 2026

Oh.. I see.. Can fix it at evening.

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.

Use Accelerate as default backend on Apple silicon

4 participants