This is an archive of the discontinued LLVM Phabricator instance.

[libc] Simplifies multi implementations and benchmarks
ClosedPublic

Authored by gchatelet on May 11 2021, 5:22 AM.

Details

Summary

This is a roll forward of D101895 with two additional fixes:

Original Patch description:

This is a follow up on D101524 which:

  • simplifies cpu features detection and usage,
  • flattens target dependent optimizations so it's obvious which implementations are generated,
  • provides an implementation targeting the host (march/mtune=native) for the mem* functions,
  • makes sure all implementations are unittested (provided the host can run them).

Additional fixes:

  • Fix uninitialized ALL_CPU_FEATURES
  • Use non pseudo microarch as it is only supported from Clang 12 on

Diff Detail

Event Timeline

gchatelet created this revision.May 11 2021, 5:22 AM
gchatelet requested review of this revision.May 11 2021, 5:22 AM
sivachandra accepted this revision.May 11 2021, 10:17 AM

Does this need clang-11?

This revision is now accepted and ready to land.May 11 2021, 10:17 AM

Does this need clang-11?

Nope it should compile from clang 3.9 on.

This revision was automatically updated to reflect the committed changes.

Using clang-13, that has this changeset I encounter: clang-13: error: the clang compiler does not support '-march=native'.

Using clang-13, that has this changeset I encounter: clang-13: error: the clang compiler does not support '-march=native'.

Thx for reporting @Abpostelnicu . Which CPU are you compiling for?

Abpostelnicu added a comment.EditedOct 7 2021, 7:26 AM

Using clang-13, that has this changeset I encounter: clang-13: error: the clang compiler does not support '-march=native'.

Thx for reporting @Abpostelnicu . Which CPU are you compiling for?

thanks for the reply, aarch64. You can see the build.

Using clang-13, that has this changeset I encounter: clang-13: error: the clang compiler does not support '-march=native'.

Thx for reporting @Abpostelnicu . Which CPU are you compiling for?

thanks for the reply, aarch64. You can see the build.

I see thx.
The issue comes from the cross compilation.
We should disable host optimized targets when cross compiling as it pulls in invalid compilation flags.
I'll prepare a patch.

Using clang-13, that has this changeset I encounter: clang-13: error: the clang compiler does not support '-march=native'.

Thx for reporting @Abpostelnicu . Which CPU are you compiling for?

thanks for the reply, aarch64. You can see the build.

I see thx.
The issue comes from the cross compilation.
We should disable host optimized targets when cross compiling as it pulls in invalid compilation flags.
I'll prepare a patch.

Actually, AFAIU it's an issue with the toolchain configuration.
CMake specifies: When cross-compiling, a CMAKE_TOOLCHAIN_FILE should set the CMAKE_SYSTEM_PROCESSOR variable to match target architecture that it specifies (via CMAKE_<LANG>_COMPILER and perhaps CMAKE_<LANG>_COMPILER_TARGET).
When I look at the CMake cmd line I don't see a -DCMAKE_SYSTEM_PROCESSOR=aarch64-linux-android.
Can you have a look?

Let's try to diagnose the issue out of this thread, I'll start a private conversation.

libc/src/string/CMakeLists.txt