-
Notifications
You must be signed in to change notification settings - Fork 10
Correct double
return type for SDOT and Co with Apple Accelerate
#65
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
Comments
First, I would say blame Apple for not following the rules or even using f2c (which introduced this issue) . For example for
and you need
Did I get this right? Since this is an ABI change, the only way I could think of (by now), is to provide a separate flexiblas library and try to add some detection mechanism, when loading the backend, if the single precision routines do the right job. Can you check if this is the complete list of functions:
Are single precision complex function affected as well? |
Thank you for considering this. I agree that this mess is Apple's fault. Ideally, FlexiBLAS would expose function prototypes that confirm to the reference implementation even if the underlying implementation has this defect. I.e., FlexiBLAS would continue to expose the function with
even if the underlying (defective) implementation uses the following (non-conformant) prototype:
But it would use a small shim function that casts the wrong return type ( So, if I understood you correctly, that would be the other way round from what you suggested. I don't have physical access to a macOS system. But I could ask on the Octave forum thread if someone could run some tests. If I understand the situation correctly, all functions (not subroutines) that return float are affected. From what I can tell, complex real is not affected. But I will try to have that confirmed. Grepping for
I wouldn't be surprised if they (the Apples devs) did the same mistake in their implementations of LAPACK functions. If that is true (I'll try to have that confirmed), that would also affect the following LAPACK functions in Apple Accelerate:
|
Thinking about it, there is probably no reason for excluding the |
As a first though, I do not have a proper idea to implement a shim layer, which does its select on the return type, without recompiling the application. If you have any idea let me know. The scabs1 function should be neglected, it is only for internal BLAS usage and, for example, not exposed by ATLAS or very old Accelerate frameworks(to my knowledge). |
I don't know how exactly FlexiBLAS forwards to the actual implementation of a function. But I'd imagine that it would grab a pointer to the function somehow.
|
I suspect they are still using |
This is a very crude attempt to check whether BLAS functions that should return single-precision floating point values actually do that. Some implementations (like Apple Accelerate) don't do that. See mpimd-csc#65. This is mainly meant for early feedback.
This is a very crude attempt to check whether BLAS functions that should return single-precision floating point values actually do that. Some implementations (like Apple Accelerate) don't do that. See mpimd-csc#65. This is mainly meant for early feedback.
I've opened #68 for a potential implementation idea. Would something like that work? |
This is a very crude attempt to check whether BLAS functions that should return single-precision floating point values actually do that. Some implementations (like Apple Accelerate) don't do that. See mpimd-csc#65. This is mainly meant for early feedback.
Does |
That test was with |
(OT: Regarding the reference to |
@dasergatskov tested using CDOTU with Apple Accelerate with an example written in C++: The return value is indeed of type |
I am on the way building this into a new code gen, did any body test, if the LAPACK routines returning |
Thanks for looking into this. If I recall correctly, we didn't check that yet. If you have access to a macOS device with Apple Accelerate, you might be able to test that with the example programs from that thread. |
In the LAPACKE sources, there is a hint that is true for LAPACK as well.. . See |
Anything else would have been surprising. But one never knows... @dasergatskov also confirmed that So, the test agrees with that comment in the LAPACKE header. (But I wouldn't be so general as to blame |
Some BLAS functions have the wrong return type in their implementation in Apple Accelerate. E.g.,
SDOT
should return a single-precision floating point value but it returns a double-precision floating point value.Essentially, all functions that are returning a single-precision floating point value in their standard implementation are affected.
Other implementations of BLAS (e.g., OpenBLAS) follow the standard implementation also on macOS. That makes it difficult to use FlexiBLAS to switch, e.g., between OpenBLAS and Apple Accelerate on macOS.
Would it be possible that FlexiBLAS added some shims that convert the return type for the affected functions from (non-standard)
double
tofloat
?See also the discussion here:
https://octave.discourse.group/t/macos-accelerate-framework-single-precision-issue/6140
Or:
https://fortran-lang.discourse.group/t/how-many-blas-libraries-have-this-error/4454
The text was updated successfully, but these errors were encountered: