Skip to content

[FR] Enable LLVM Polly #1096

Closed
Closed

Description

@a1batross

In our app, we don't write vectorized code by hand, instead we're relying on compiler autovectorization. In legacy NDK we used GCC's Graphite and now when we switched to latest NDK r20, I've noticed that Polly, LLVM's alternative to GCC Graphite, isn't enabled in NDK toolchains.

Simple way to check if it's enabled:

$ ./aarch64-linux-android21-clang -mllvm -polly -xc -c - -o test.o < /dev/null
clang (LLVM option parsing): Unknown command line argument '-polly'.  Try: 'clang (LLVM option parsing) -help'
clang (LLVM option parsing): Did you mean '-color'?
$ echo $?
1

When on Clang 8 from LLVM's APT repository it doesn't show an error:

$ clang-8 -target aarch64-linux-android21 -mllvm -polly -xc -c - -o test.o < /dev/null
$ echo $?
0

Our app is crossplatform, so testing Polly on Linux ARM machine is resulted performance boost around 10%. Is there any bugs on Android so it's not available?

Activity

  1. self-assigned this
    on Oct 11, 2019
  2. stephenhines commented on Oct 11, 2019

    @stephenhines

    This is just something that we have not had time to evaluate or test in the context of Android. It is something we can look into for future releases, but I can't commit to a specific release yet.

  3. a1batross commented on Oct 11, 2019

    @a1batross
    Author

    @stephenhines thanks for answer!

    Actually, I have my own research with Polly on Android as part of study of how I can use thirdparty Android NDK compiler, for example, Clang/LLVM from Ubuntu repositories, apt.llvm.org or self-built, but that set up to use NDK's sysroots.
    Also, being a fan of hardfloat ABI, I also set compiler to use sysroot from older NDK with uncut hardfloat ABI support. This doesn't apply to the topic, but still was a nice try.

    I did ran tests and benchmarks to ensure that this way of hack didn't generated worse code than NDK's toolchain.

    So, here is results:

    Toolchain Avg FPS
    NDK Clang ARMv7 77 FPS
    Host Clang softfp 77 FPS
    Host Clang hardfp 75.8 FPS
    Host Clang softfp Polly 85 FPS
    Host Clang hardfp Polly 89 FPS
    NDK Clang AArch64 100 FPS
    Host Clang AArch64 Polly 102 FPS

    We just ended up with renderer performance on AArch64, but for ARMv7 devices that half of our audience still uses it's given a nice performance boost.

  4. stephenhines commented on Mar 19, 2020

    @stephenhines

    https://android-review.googlesource.com/c/toolchain/llvm_android/+/1261718 enables this for our toolchain. We'll be marking Polly support as experimental in an upcoming release of the NDK.

  5. added this to the milestone on Mar 19, 2020
  6. DanAlbert commented on Mar 19, 2020

    @DanAlbert
    Contributor

    I think that change missed the train for the r22 compiler, so triaging to r23. @stephenhines please correct me/move it if that's wrong.

  7. modified the milestones: , r22 on Apr 14, 2020
  8. stephenhines commented on Apr 14, 2020

    @stephenhines

    This actually will make it for R22, since we need to take Yabin's update as well.

  9. DanAlbert commented on Jun 25, 2020

    @DanAlbert
    Contributor

    @stephenhines

    $ prebuilts/clang/host/linux-x86/clang-r383902c/bin/clang++ -mllvm -polly foo.cpp -c
    clang (LLVM option parsing): Unknown command line argument '-polly'.  Try: 'clang (LLVM option parsing) --help'
    clang (LLVM option parsing): Did you mean '--color'?
    

    Seems this wasn't actually enabled? @nickdesaulniers as well because he was interested in using this.

  10. stephenhines commented on Jun 25, 2020

    @stephenhines

    Yeah, I missed that the build configuration wasn't actually picked up. We need to explicitly build polly (actually "Polly") and then bundle the necessary libraries to make this work. Let's move this to r23 instead.

  11. modified the milestones: r22, on Jun 25, 2020
  12. DanAlbert commented on Jun 25, 2020

    @DanAlbert
    Contributor

    Bummer. https://android-review.googlesource.com/c/platform/ndk/+/1350665 fixes the changelog.

    https://android-review.googlesource.com/c/platform/ndk/+/1350664 adds a test that we should submit when this gets added.

  13. 11 remaining items

  14. added a commit that references this issue on Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions