Page MenuHomePhabricator

[libcxx] implement <experimental/simd> concat() and split()
Needs ReviewPublic

Authored by timshen on Dec 19 2017, 1:21 PM.

Details

Summary

This patch implements the extended version (see P0820) of P0214
concat() and split().

If compiled with Clang, sometimes they are implemented in terms of
__builtin_shufflevector to avoid relying on auto-vectorization.

Event Timeline

timshen created this revision.Dec 19 2017, 1:21 PM
timshen updated this revision to Diff 129009.Jan 8 2018, 4:58 PM

Rebased.

timshen edited the summary of this revision. (Show Details)Apr 5 2018, 11:45 AM
mclow.lists added inline comments.Jul 17 2018, 9:25 AM
libcxx/include/experimental/simd
1055

P0820 has been adopted, no need for this comment any more.

1547

I see no change here other than fixing a typo - correct?

1686

In general, we try to keep all the compiler-specific bits in <__config>. They tend to grow/mutate over time, and so it's nice to have them all in one place.

Better to define something like _LIBCPP_HAS_BUILTIN_SHUFFLEVECTOR and use that; then if GCC gets religion and adds it, you will only have to update a single place. Also, it makes the reading easier - no more looking at this and wondering "Why are you requiring clang here?"

Is this the only place you plan on using __simd_shuffle? If so, why not a member function.

timshen updated this revision to Diff 158092.Jul 30 2018, 2:58 PM
timshen marked 2 inline comments as done.
timshen edited the summary of this revision. (Show Details)

Update based on comments.

A note on test cases: I only used simds ints to test split() and concat(), as both functions don't specialize on the element type, unlike the constructors.

libcxx/include/experimental/simd
1547

That is correct.

1686

GCC already got religion and had it, but in a radically different interface. There is little chance that they will merge the interface in the future.

The GCC one is called __builtin_shuffle (https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html). I haven't added it only because I don't care about the performance on GCC.

It's rather non-trivial to eliminate the difference between them, certainly more than a macro like _LIBCPP_HAS_BUILTIN_SHUFFLEVECTOR.

Do you have any other way to improve the readability?