Skip to content
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

Most AVX/AVX2 functions not exposed #16

Open
jackmott opened this issue Nov 12, 2019 · 8 comments
Open

Most AVX/AVX2 functions not exposed #16

jackmott opened this issue Nov 12, 2019 · 8 comments

Comments

@jackmott
Copy link

Is this because they make use of long double ?
What work needs to be done to get those added? Happy to help.

@gnzlbg
Copy link
Owner

gnzlbg commented Nov 13, 2019

Yes, but there is no way to use long double from Rust, so I don't see that anything can be done to expose these.

@gnzlbg
Copy link
Owner

gnzlbg commented Nov 13, 2019

cc @joshtriplett long double on FFI is another feature that the FFI WG should at some point tackle. It's impossible to call functions with long double because the "call ABI" of the type cannot be emulated.

@jackmott
Copy link
Author

Gothca, maybe I Will stroll over to the FFI WG and see if I can help there. In the mean time, I can use the sse4 functions twice, I suppose!

@gnzlbg
Copy link
Owner

gnzlbg commented Nov 13, 2019 via email

@greatest-ape
Copy link

greatest-ape commented Feb 23, 2020

Modifying sleef-sys slightly enables using, at the very least, this sleef avx function (coincidentally in a fork of @jackmott's crate). I don't know exactly how this relates the long double problem, but I thought I'd mention it anyway.

@greatest-ape
Copy link

I put it behind a feature flag here: greatest-ape@df02548

@greatest-ape
Copy link

@jackmott Only two functions actually take long double arguments: Sleef_sincospil_u05 and Sleef_sincospil_u35 (except for some in the DFT part of sleef which isn't currently compiled). I suspect the reason you're not seeing many AVX/AVX2 functions is that they are only compiled when avx is enabled as a target feature when compiling sleef-sys. #21 should fix this issue, if @gnzlbg is interested in merging it.

@greatest-ape
Copy link

I'm sorry about the multitude of comments, but for future reference/other readers, I suspect the ABI issue is discussed in:

Progress seems to have stalled on rust-lang/rust#59238, which would implement RFC2574.

In my understanding, my pull request #21 works at some platforms when used carefully, but soundness issues would occur when let's say a function taking a 256 bit wide vector is called on a CPU only supporting 128 bit wide vectors. A fix might be to somehow add

#[target_feature(enable = X)] in C FFI functions using SIMD types

(to quote the RFC) to all relevant functions in sleef-sys, e.g. X=avx for SIMD type __m256.

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

No branches or pull requests

3 participants