[PATCH] D63459: Loop Cache Analysis

Ettore Tiotto via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 17 14:41:16 PDT 2019


etiotto created this revision.
etiotto added reviewers: hfinkel, Meinersbur, jdoerfert, kbarton, bmahjour, anemet.
Herald added subscribers: llvm-commits, jsji, mgrang, hiraditya, mgorny.
Herald added a project: LLVM.

Implement a new analysis to estimate the number of cache lines required by a loop nest. 
The analysis is largely based on the following paper:

  Compiler Optimizations for Improving Data Locality
  By: Steve Carr, Katherine S. McKinley, Chau-Wen Tseng
  http://www.cs.utexas.edu/users/mckinley/papers/asplos-1994.pdf

The analysis considers temporal reuse (accesses to the same memory location) and spatial reuse (accesses to memory locations within a cache line). For simplicity the analysis considers memory accesses in the innermost loop in a loop nest, and thus determines the number of cache lines used when the loop L in loop nest LN is placed in the innermost position.

The result of the analysis can be used to driver several transformations. As an example loop interchange could use it determine which loops in a perfect loop nest should be interchanged to maximize cache reuse. Similarly loop distribution could be enhanced to take into consideration cache reuse between arrays when distributing a loop to eliminate vectorization inhibiting dependencies.

The general approach taken to estimate the number of cache lines used by the memory references in the inner loop of a loop nest is:

- Partition memory references that exhibit temporal or spatial reuse into reference groups.
- For each loop L in the a loop nest LN: a. Compute the cost of the reference group b. Compute the 'cache cost' of the loop nest by summing up the reference groups costs

For further details of the algorithm please refer to the paper.


Repository:
  rL LLVM

https://reviews.llvm.org/D63459

Files:
  llvm/include/llvm/Analysis/LoopCacheAnalysis.h
  llvm/lib/Analysis/CMakeLists.txt
  llvm/lib/Analysis/LoopCacheAnalysis.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/test/Analysis/LoopCacheAnalysis/a.ll
  llvm/test/Analysis/LoopCacheAnalysis/b.ll
  llvm/test/Analysis/LoopCacheAnalysis/c.ll
  llvm/test/Analysis/LoopCacheAnalysis/matmul.ll
  llvm/test/Analysis/LoopCacheAnalysis/matvecmul.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63459.205185.patch
Type: text/x-patch
Size: 59332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190617/4263f517/attachment.bin>


More information about the llvm-commits mailing list