-
Notifications
You must be signed in to change notification settings - Fork 68
Fixes for macOS portability #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes for macOS portability #51
Conversation
Thanks @joseeroman. Is this to fix an issue with the Accelerate framework? I.e., there is no issue if you use a reference BLAS implementation. ( just want to make I understand the issue this PR is fixing ) |
Yes, the issue appears only with Apple's BLAS and does not show up with reference BLAS. If I try calling this
it works as expected with reference BLAS but produces a segmentation fault with Apple's BLAS. The latter expects a subroutine call instead of a function call (to avoid returning a complex value on the stack), so the following works
I have not found any place where this is documented. Regarding the |
Isn't this just a Fortran compiler convention? The Intel ifort compiler does the same thing, return complex numbers as a hidden argument. Fine if (Sca)LAPACK is compiled with the same Fortran compiler as BLAS. The problem is the Fortran compiler on macOS (e.g., gfortran) doesn't match what Apple is assuming, which is the old f2c compiler/translator and CLAPACK conventions. |
With gfortran, see
I think it's fine to use updated ccdotc & zzdotc routines to work around these ABI issues. |
34a2a59
to
4144809
Compare
Hi @joseeroman. Would you be interested in contributing to the Continuous Integration on ScaLAPACK for the MacOS? I am proposing a simple version 0 on #56. Thanks! |
Any chance this gets approved/merged independently of the status of #56? There is an upcoming PETSc release by the end of this month, it would be nice if we could switch to this repository instead of our fork over at https://bitbucket.org/petsc/pkg-scalapack, but |
4144809
to
b3f4553
Compare
Rebased on top of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workaround looks good to me!
Just to have it written somewhere. After you PR:
- ScaLAPACK routines will use CCDOTC, ZZDOTC, CCDOTU, ZZDOTU. And CDOTC, ZDOTC, CDOTU, ZDOTU are deprecated (or at least should never be used inside the library).
- ScaLAPACK routines will use SLADIV and DLADIV. And CLADIV and ZLADIV are deprecated (or at least should never be used inside the library).
Please, correct me if I am wrong or if I missed something.
That's correct |
Hi @joseeroman. Could you please force an empty commit so that your changes are subjected to the new tests? Thanks! |
These BLAS functions return a complex number and this may produce ABI conflict if using a BLAS compiled with a Fortran compiler with different calling convention (e.g. macOS Accelerate framework). Use an equivalent subroutine instead.
These LAPACK functions return a complex number (as ZDOTC and friends) and hence do not work in MacOS, so it is better not to call them
b3f4553
to
a0f76fc
Compare
Wouldn't this introduce a performance regression for those relying on optimized blas libraries since optimized BLAS libraries will intrinsically do SIMD expansions in the While I totally understand the desire to ensure MacOS compatibility we also have to acknowledge the fact that this is based on LAPACK + BLAS and not on accelerate which does not obey the BLAS API. Whether or not the API is fixed I won't get into ;) Couldn't this be changed to a |
Could you show me a use case where BLAS-1 operations are the bottleneck compared to higher-level BLAS operations? |
For sure, they are not the bottleneck (perhaps just for very tiny matrices). But the point still stands. |
Which one? The one suggesting to add a new flag so that there will be possibly more code paths to follow/maintain for operations that are most often no-op? Yup, that point still stands. |
You may want to add these changes, intended to avoid issues in macOS due to special calling convention. We have had these changes in PETSc's
--download-scalapack
for two years now, but it is better if they can be added upstream.