[PATCH] D51969: [AMDGPU] Add an AMDGPU specific atomic optimizer.

Neil Henning via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 12 02:37:32 PDT 2018


sheredom created this revision.
sheredom added reviewers: nhaehnle, arsenm.
sheredom added a project: AMDGPU.
Herald added subscribers: llvm-commits, jfb, t-tye, tpr, dstuttard, yaxunl, mgorny, wdng, jvesely, kzhuravl.

This commit adds a new IR level pass to the AMDGPU backend to perform atomic optimizations. It works by:

- Running through a function and finding atomicrmw add/sub or uses of the atomic buffer intrinsics for add/sub.
- If all arguments except the value to be added/subtracted are uniform, record the value to be optimized.
- Run through the atomic operations we can optimize and, depending on whether the value is uniform/divergent use wavefront wide operations (DPP in the divergent case) to calculate the total amount to be atomically added/subtracted.
- Then let only a single lane of each wavefront perform the atomic operation, reducing the total number of atomic operations in flight.
- Lastly we recombine the result from the single lane to each lane of the wavefront, and calculate our individual lanes offset into the final result.


Repository:
  rL LLVM

https://reviews.llvm.org/D51969

Files:
  lib/Target/AMDGPU/AMDGPU.h
  lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp
  lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  lib/Target/AMDGPU/CMakeLists.txt
  test/CodeGen/AMDGPU/atomic_load_add.ll
  test/CodeGen/AMDGPU/atomic_load_sub.ll
  test/CodeGen/AMDGPU/atomic_optimizations_buffer.ll
  test/CodeGen/AMDGPU/atomic_optimizations_global_pointer.ll
  test/CodeGen/AMDGPU/atomic_optimizations_local_pointer.ll
  test/CodeGen/AMDGPU/atomic_optimizations_raw_buffer.ll
  test/CodeGen/AMDGPU/atomic_optimizations_struct_buffer.ll
  test/CodeGen/AMDGPU/global_atomics.ll
  test/CodeGen/AMDGPU/global_atomics_i64.ll
  test/CodeGen/AMDGPU/llvm.amdgcn.buffer.atomic.ll
  test/CodeGen/AMDGPU/llvm.amdgcn.raw.buffer.atomic.ll
  test/CodeGen/AMDGPU/llvm.amdgcn.struct.buffer.atomic.ll
  test/CodeGen/AMDGPU/local-atomics.ll
  test/CodeGen/AMDGPU/local-atomics64.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51969.165040.patch
Type: text/x-patch
Size: 70032 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180912/07f41a0c/attachment-0001.bin>


More information about the llvm-commits mailing list