[all-commits] [llvm/llvm-project] 83c1d0: [SPIR-V] Overhaul module analysis to improve trans...

Vyacheslav Levytskyy via All-commits all-commits at lists.llvm.org
Tue Jan 7 01:42:44 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 83c1d003118a2cb8136fe49e2ec43958c93d9d6b
      https://github.com/llvm/llvm-project/commit/83c1d003118a2cb8136fe49e2ec43958c93d9d6b
  Author: Vyacheslav Levytskyy <vyacheslav.levytskyy at intel.com>
  Date:   2025-01-07 (Tue, 07 Jan 2025)

  Changed paths:
    M llvm/lib/Target/SPIRV/CMakeLists.txt
    M llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp
    M llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
    R llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.cpp
    M llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h
    M llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
    M llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.h
    M llvm/lib/Target/SPIRV/SPIRVInstrInfo.cpp
    M llvm/lib/Target/SPIRV/SPIRVInstrInfo.h
    M llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
    M llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
    M llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h
    M llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp
    M llvm/test/CodeGen/SPIRV/AtomicCompareExchange.ll
    M llvm/test/CodeGen/SPIRV/event-zero-const.ll
    M llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_function_pointers/fp-simple-hierarchy.ll
    M llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_function_pointers/fp_const.ll
    M llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_function_pointers/fun-ptr-addrcast.ll
    M llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_inline_assembly/inline_asm.ll
    M llvm/test/CodeGen/SPIRV/extensions/SPV_KHR_shader_clock/shader_clock.ll
    M llvm/test/CodeGen/SPIRV/iaddcarry-builtin.ll
    M llvm/test/CodeGen/SPIRV/image-unoptimized.ll
    M llvm/test/CodeGen/SPIRV/isubborrow-builtin.ll
    M llvm/test/CodeGen/SPIRV/keep-tracked-const.ll
    M llvm/test/CodeGen/SPIRV/llvm-intrinsics/fshl.ll
    M llvm/test/CodeGen/SPIRV/llvm-intrinsics/fshr.ll
    M llvm/test/CodeGen/SPIRV/llvm-intrinsics/memset.ll
    M llvm/test/CodeGen/SPIRV/logical-access-chain.ll
    M llvm/test/CodeGen/SPIRV/pointers/PtrCast-null-in-OpSpecConstantOp.ll
    M llvm/test/CodeGen/SPIRV/pointers/struct-opaque-pointers.ll
    M llvm/test/CodeGen/SPIRV/transcoding/SampledImage.ll
    M llvm/test/CodeGen/SPIRV/transcoding/cl-types.ll
    M llvm/test/CodeGen/SPIRV/transcoding/spirv-private-array-initialization.ll
    M llvm/test/CodeGen/SPIRV/transcoding/sub_group_non_uniform_arithmetic.ll
    M llvm/test/CodeGen/SPIRV/unnamed-global.ll

  Log Message:
  -----------
  [SPIR-V] Overhaul module analysis to improve translation speed and simplify the underlying logics (#120415)

This PR is to address legacy issues with module analysis that currently
uses a complicated and not so efficient approach to trace dependencies
between SPIR-V id's via a duplicate tracker data structures and an
explicitly built dependency graph. Even a quick performance check
without any specialized benchmarks points to this part of the
implementation as a biggest bottleneck.

This PR specifically:
* eliminates a need to build a dependency graph as a data structure,
* updates the test suite (mainly, by fixing incorrect CHECK's referring
to a hardcoded order of definitions, contradicting the spec requirement
to allow certain definitions to go "in any order", see
https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_logical_layout_of_a_module),
* improves function pointers implementation so that it now passes
EXPENSIVE_CHECKS (thus removing 3 XFAIL's in the test suite).

As a quick sanity check of whether goals of the PR are achieved, we can
measure time of translation for any big LLVM IR. While testing the PR in
the local development environment, improvements of the x5 order have
been observed.

For example, the SYCL test case "group barrier" that is a ~1Mb binary IR
input shows the following values of the naive performance metric that we
can nevertheless apply here to roughly estimate effects of the PR.

before the PR:
```
$ time llc -O0 -mtriple=spirv64v1.6-unknown-unknown _group_barrier_phi.bc -o 1 --filetype=obj

real    3m33.241s
user    3m14.688s
sys     0m18.530s
```

after the PR

```
$ time llc -O0 -mtriple=spirv64v1.6-unknown-unknown _group_barrier_phi.bc -o 1 --filetype=obj

real    0m42.031s
user    0m38.834s
sys     0m3.193s
```

Next work should probably address Duplicate Tracker further, as it needs
analysis now from the perspective of what parts of it are not necessary
now, after changing the approach to implementation of the module
analysis step.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list