public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, AArch64 00/11] LSE atomics out-of-line
@ 2018-09-26  5:04 rth7680
  2018-09-26  5:04 ` [PATCH, AArch64 08/11] aarch64: Add out-of-line functions for LSE atomics rth7680
                   ` (13 more replies)
  0 siblings, 14 replies; 31+ messages in thread
From: rth7680 @ 2018-09-26  5:04 UTC (permalink / raw)
  To: gcc-patches; +Cc: ramana.radhakrishnan, agraf, matz, Richard Henderson

From: Richard Henderson <richard.henderson@linaro.org>

ARMv8.1 adds an (mandatory) Atomics extension, also known as the
Large System Extension.  Deploying this extension at the OS level
has proved challenging.

The following is the result of a conversation between myself,
Alex Graf of SuSE, and Ramana Radhakrishnan of ARM, at last week's
Linaro Connect in Vancouver.

The current state of the world is that one could distribute two
different copies of a given shared library and place the LSE-enabled
version in /lib64/atomics/ and it will be selected over the /lib64/
version by ld.so when HWCAP_ATOMICS is present.

Alex's main concern with this is that (1) he doesn't want to
distribute two copies of every library, or determine what a
resonable subset would be and (2) this solution does not work
for executables, e.g. mysql.

Ramana's main concern was to avoid the overhead of an indirect jump,
especially in how that would affect the (non-)branch-prediction of
the smallest implementations.

Therefore, I've created small out-of-line helpers that are directly
linked into every library or executable that requires them.  There
will be two direct branches, both of which will be well-predicted.

In the process, I discovered a number of places within the code
where the existing implementation could be improved.  In particular:

 - the LSE patterns didn't use predicates or constraints that
   match the actual instructions, requiring unnecessary splitting.

 - the non-LSE compare-and-swap can use an extending compare to
   avoid requiring the input to have been previously extended.

 - TImode compare-and-swap was missing entirely.  This brings
   aarch64 to parity with x86_64 wrt __sync_val_compare_and_swap.

There is a final patch that enables the new option by default.
I am not necessarily expecting this to be merged upstream, but
for the operating system to decide what the default should be.
It might be that this should be a configure option, so as to
make that OS choice easier, but I've just now thought of that.  ;-)

I'm going to have to rely on Alex and/or Ramana to perform
testing on a system that supports LSE.


r~


Richard Henderson (11):
  aarch64: Simplify LSE cas generation
  aarch64: Improve cas generation
  aarch64: Improve swp generation
  aarch64: Improve atomic-op lse generation
  aarch64: Emit LSE st<op> instructions
  Add visibility to libfunc constructors
  Link static libgcc after shared libgcc for -shared-libgcc
  aarch64: Add out-of-line functions for LSE atomics
  aarch64: Implement -matomic-ool
  aarch64: Implement TImode compare-and-swap
  Enable -matomic-ool by default

 gcc/config/aarch64/aarch64-protos.h           |  20 +-
 gcc/optabs-libfuncs.h                         |   2 +
 gcc/common/config/aarch64/aarch64-common.c    |   6 +-
 gcc/config/aarch64/aarch64.c                  | 480 ++++++--------
 gcc/gcc.c                                     |   9 +-
 gcc/optabs-libfuncs.c                         |  26 +-
 .../atomic-comp-swap-release-acquire.c        |   2 +-
 .../gcc.target/aarch64/atomic-inst-ldadd.c    |  18 +-
 .../gcc.target/aarch64/atomic-inst-ldlogic.c  |  54 +-
 .../gcc.target/aarch64/atomic-op-acq_rel.c    |   2 +-
 .../gcc.target/aarch64/atomic-op-acquire.c    |   2 +-
 .../gcc.target/aarch64/atomic-op-char.c       |   2 +-
 .../gcc.target/aarch64/atomic-op-consume.c    |   2 +-
 .../gcc.target/aarch64/atomic-op-imm.c        |   2 +-
 .../gcc.target/aarch64/atomic-op-int.c        |   2 +-
 .../gcc.target/aarch64/atomic-op-long.c       |   2 +-
 .../gcc.target/aarch64/atomic-op-relaxed.c    |   2 +-
 .../gcc.target/aarch64/atomic-op-release.c    |   2 +-
 .../gcc.target/aarch64/atomic-op-seq_cst.c    |   2 +-
 .../gcc.target/aarch64/atomic-op-short.c      |   2 +-
 .../aarch64/atomic_cmp_exchange_zero_reg_1.c  |   2 +-
 .../atomic_cmp_exchange_zero_strong_1.c       |   2 +-
 .../gcc.target/aarch64/sync-comp-swap.c       |   2 +-
 .../gcc.target/aarch64/sync-op-acquire.c      |   2 +-
 .../gcc.target/aarch64/sync-op-full.c         |   2 +-
 libgcc/config/aarch64/lse.c                   | 280 ++++++++
 gcc/config/aarch64/aarch64.opt                |   4 +
 gcc/config/aarch64/atomics.md                 | 608 ++++++++++--------
 gcc/config/aarch64/iterators.md               |   8 +-
 gcc/config/aarch64/predicates.md              |  12 +
 gcc/doc/invoke.texi                           |  14 +-
 libgcc/config.host                            |   4 +
 libgcc/config/aarch64/t-lse                   |  48 ++
 33 files changed, 1050 insertions(+), 577 deletions(-)
 create mode 100644 libgcc/config/aarch64/lse.c
 create mode 100644 libgcc/config/aarch64/t-lse

-- 
2.17.1

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2019-02-04 12:15 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-26  5:04 [PATCH, AArch64 00/11] LSE atomics out-of-line rth7680
2018-09-26  5:04 ` [PATCH, AArch64 08/11] aarch64: Add out-of-line functions for LSE atomics rth7680
2018-09-26  9:01   ` Florian Weimer
2018-09-26 14:33     ` Richard Henderson
2018-09-26 14:36       ` Florian Weimer
2018-09-26 14:37         ` Richard Henderson
2018-09-28 16:29   ` Ramana Radhakrishnan
2018-09-26  5:04 ` [PATCH, AArch64 05/11] aarch64: Emit LSE st<op> instructions rth7680
2018-09-26  5:04 ` [PATCH, AArch64 07/11] Link static libgcc after shared libgcc for -shared-libgcc rth7680
2018-09-26 16:55   ` Joseph Myers
2018-09-26 16:57     ` Richard Henderson
2018-09-26  5:04 ` [PATCH, AArch64 10/11] aarch64: Implement TImode compare-and-swap rth7680
2018-09-27 13:08   ` Matthew Malcomson
     [not found]   ` <3460dd10-4d9a-1def-3f9b-5f7a1afe5906@arm.com>
2018-09-27 16:39     ` Richard Henderson
2018-09-27 17:07       ` Matthew Malcomson
2018-10-01 13:51   ` Matthew Malcomson
2018-09-26  5:04 ` [PATCH, AArch64 01/11] aarch64: Simplify LSE cas generation rth7680
2018-09-26  5:04 ` [PATCH, AArch64 03/11] aarch64: Improve swp generation rth7680
2018-09-26  5:04 ` [PATCH, AArch64 11/11] Enable -matomic-ool by default rth7680
2018-09-26  5:04 ` [PATCH, AArch64 06/11] Add visibility to libfunc constructors rth7680
2018-09-26  5:04 ` [PATCH, AArch64 09/11] aarch64: Implement -matomic-ool rth7680
2018-09-26  5:04 ` [PATCH, AArch64 04/11] aarch64: Improve atomic-op lse generation rth7680
2018-09-26  7:40 ` [PATCH, AArch64 02/11] aarch64: Improve cas generation rth7680
2018-09-26  9:22 ` [PATCH, AArch64 00/11] LSE atomics out-of-line Florian Weimer
2018-09-26 13:05   ` Michael Matz
2018-09-27 13:08 ` Ramana Radhakrishnan
2018-09-27 15:19   ` Alexander Graf
2018-09-27 16:51   ` Richard Henderson
2018-09-28  8:48     ` Ramana Radhakrishnan
2019-02-04 11:14 ` __libc_single_threaded variable for optimizing std::shared_ptr (was: [PATCH, AArch64 00/11] LSE atomics out-of-line) Florian Weimer
2019-02-04 12:15   ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).