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

[FINUFFT] Microarchitecture expansion #4249

Merged
merged 4 commits into from
Jan 14, 2022

Conversation

ludvigak
Copy link
Contributor

The FINUFFT library doesn't have CPU instruction set dispatch, but benefits a lot from optimization with SIMD instructions, so compiling it for different microarchitectures seems like a good idea.

@@ -36,4 +43,4 @@ dependencies = [
]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; preferred_gcc_version = v"8")
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; preferred_gcc_version = v"8", julia_compat=julia_compat)
Copy link
Member

Choose a reason for hiding this comment

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

Note that if you change julia_compat you also must change the version of the package itself, unfortunately the registry won't like having different compatibility bounds when we only change the build number

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, but that version is supposed to match the version of the binary library. Or do you suggest that the version of finufft_jll diverge from the version of libfinufft?

Copy link
Member

Choose a reason for hiding this comment

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

I know, but some times we do have to diverge, unfortunately. Or maybe you can try to nicely ping developers to tag a new release, there have been some changes since last release already 🙂

Choose a reason for hiding this comment

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

I have just pushed 2.0.4. Do I need to tag a release? I'm waiting on fixing a python wheels CI failure that shouldn't affect anything you're doing.

Copy link
Member

Choose a reason for hiding this comment

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

Lovely, thanks a lot! 😃


platforms = vcat(platforms_x86_64, platforms_other)
Copy link
Member

Choose a reason for hiding this comment

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

We should probably add a way to automatically expand microarchitectures only for specified architectures, it isn't uncommon that the libraries do this kind of optimisation only for x86_64.

If you were worried about the failures on aarch64, those are bugs that we have to fix anyway (I already have some fixes locally but have to test something else)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well yes, I was trying to circumvent the failures :)

But in any case, the goal of the microarchitecture expansion is to get binaries with AVX support, so limiting it to x86_64 makes a lot of sense in any case.

Copy link
Member

Choose a reason for hiding this comment

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

For the record, I'm slowly making some progress towards #4252. JuliaPackaging/BinaryBuilderBase.jl#205 fixed the aarch64 flags (not relevant here, but important before moving microarchitectures forward) and with JuliaPackaging/BinaryBuilderBase.jl#232 it is now possible to restrict the expansion with an additional argument:

julia> platforms_x86_64 = filter(p -> p.tags["arch"]=="x86_64", supported_platforms());
       platforms_other  = filter(p -> p.tags["arch"]!="x86_64", supported_platforms());
       platforms_x86_64 = expand_microarchitectures(platforms_x86_64);
       platforms_x86_64 = filter(p -> p.tags["march"] != "avx512", platforms_x86_64);
       platforms = vcat(platforms_x86_64, platforms_other)

26-element Vector{Platform}:
 Linux x86_64 {libc=glibc, march=x86_64}
 Linux x86_64 {libc=glibc, march=avx}
 Linux x86_64 {libc=glibc, march=avx2}
 Linux x86_64 {libc=musl, march=x86_64}
 Linux x86_64 {libc=musl, march=avx}
 Linux x86_64 {libc=musl, march=avx2}
 macOS x86_64 {march=x86_64}
 macOS x86_64 {march=avx}
 macOS x86_64 {march=avx2}
 FreeBSD x86_64 {march=x86_64}
 FreeBSD x86_64 {march=avx}
 FreeBSD x86_64 {march=avx2}
 Windows x86_64 {march=x86_64}
 Windows x86_64 {march=avx}
 Windows x86_64 {march=avx2}
 Linux i686 {libc=glibc}
 Linux aarch64 {libc=glibc}
 Linux armv6l {call_abi=eabihf, libc=glibc}
 Linux armv7l {call_abi=eabihf, libc=glibc}
 Linux powerpc64le {libc=glibc}
 Linux i686 {libc=musl}
 Linux aarch64 {libc=musl}
 Linux armv6l {call_abi=eabihf, libc=musl}
 Linux armv7l {call_abi=eabihf, libc=musl}
 macOS aarch64
 Windows i686

julia> expand_microarchitectures(supported_platforms(), ["x86_64", "avx", "avx2"])
26-element Vector{Platform}:
 Linux i686 {libc=glibc}
 Linux x86_64 {libc=glibc, march=x86_64}
 Linux x86_64 {libc=glibc, march=avx}
 Linux x86_64 {libc=glibc, march=avx2}
 Linux aarch64 {libc=glibc}
 Linux armv6l {call_abi=eabihf, libc=glibc}
 Linux armv7l {call_abi=eabihf, libc=glibc}
 Linux powerpc64le {libc=glibc}
 Linux i686 {libc=musl}
 Linux x86_64 {libc=musl, march=x86_64}
 Linux x86_64 {libc=musl, march=avx}
 Linux x86_64 {libc=musl, march=avx2}
 Linux aarch64 {libc=musl}
 Linux armv6l {call_abi=eabihf, libc=musl}
 Linux armv7l {call_abi=eabihf, libc=musl}
 macOS x86_64 {march=x86_64}
 macOS x86_64 {march=avx}
 macOS x86_64 {march=avx2}
 macOS aarch64
 FreeBSD x86_64 {march=x86_64}
 FreeBSD x86_64 {march=avx}
 FreeBSD x86_64 {march=avx2}
 Windows i686
 Windows x86_64 {march=x86_64}
 Windows x86_64 {march=avx}
 Windows x86_64 {march=avx2}

julia> all(in(platforms), expand_microarchitectures(supported_platforms(), ["x86_64", "avx", "avx2"]))
true

@ludvigak ludvigak marked this pull request as ready for review January 14, 2022 07:47
@ludvigak
Copy link
Contributor Author

There, I think we are good to go!

@giordano
Copy link
Member

Awesome! While we have had for a while this infrastructure to target different microarchitectures, we haven't used it yet into the wild, as you could guess from the aarch64 bugs. This is the first package that is going to actually use it. Should you have any problems, please do let us know!

@giordano giordano merged commit 6d296a1 into JuliaPackaging:master Jan 14, 2022
simeonschaub pushed a commit to simeonschaub/Yggdrasil that referenced this pull request Feb 23, 2022
* Add microarchitecture expansion

* Set  julia_compat=1.6

* Only expand for microarchitectures on x86_64

* Update to Finufft v2.0.4
@ludvigak ludvigak deleted the ludvigak-finufft-march branch September 10, 2024 09:06
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.

3 participants