polly as an analysis pass in llvm
play

Polly as an analysis pass in LLVM Utpal Bora * , Johannes Doerfert + - PowerPoint PPT Presentation

Polly as an analysis pass in LLVM Utpal Bora * , Johannes Doerfert + , Tobias Grosser $ , Venugopal Raghavan and Ramakrishna Upadrasta * IIT Hyderabad * , Saarland University + , ETH Zurich $ , AMD India Pvt. Ltd. Goal Use precise dependence


  1. Polly as an analysis pass in LLVM Utpal Bora * , Johannes Doerfert + , Tobias Grosser $ , Venugopal Raghavan £ and Ramakrishna Upadrasta * IIT Hyderabad * , Saarland University + , ETH Zurich $ , AMD India Pvt. Ltd. £

  2. Goal Use precise dependence analysis of Polly in LLVM transformations ❖ 2

  3. Example for vectorization Loop Vectorizer falsely states memory dependence MultiSource/Benchmarks/TSVC/LinearDependence-flt for (int i = 0; i < LEN2; i++) { for (int j = 0; j < i; j++) { aa[i][j] = aa[j][i] + bb[i][j]; } } 3

  4. Example for vectorization MultiSource/Benchmarks/TSVC/LinearDependence-flt for (int i = 0; i < LEN2; i++) { No memory dependence because of j < i for (int j = 0; j < i ; j++) { aa[i][j] = aa[j][i] + bb[i][j]; } } 4

  5. Example for vectorization MultiSource/Benchmarks/TSVC/LinearDependence-flt for (int i = 0; i < LEN2; i++) { No memory dependence because of j < i for (int j = 0; j < i ; j++) { Polly correctly determines no dependence aa[i][j] = aa[j][i] + bb[i][j]; } } 5

  6. Example for vectorization MultiSource/Benchmarks/TSVC/LinearDependence-flt for (int i = 0; i < LEN2; i++) { No memory dependence because of j < i for (int j = 0; j < i ; j++) { Polly correctly determines no dependence aa[i][j] = aa[j][i] + bb[i][j]; Loop is parallel and vectorizable } } This loop can be vectorized using PolyhedralInfo . 6

  7. Implementation Detail PolyhedralInfo- a new interface to Polly ❖ APIs exposed for LLVM transformations ❖ check loop is parallel: isParallel (Loop *L) ➢ check vectorization legality: isVectorizable (Loop *L, unsigned int *VF) ➢ VF - Vectorization Factor We compute the maximum VF for the given loop if it is vectorizable. It is set to UINT_MAX for parallel loops 7

  8. 8

  9. Checking loop parallelism $ opt -polly-process-unprofitable \ for (i = 0; i < n; i++) -polyhedral-info \ for (j = 0; j < n; j++) -polly-check-parallel \ A[i] = 1; -analyze 1.ll loop.i: Loop is parallel . loop.j: Loop is not parallel. 9

  10. Checking loop parallelism $ opt -polly-process-unprofitable \ for (i = 0; i < n; i++) -polyhedral-info \ for (j = 0; j < n; j++) -polly-check-parallel \ A[j] = 1; -analyze 2.ll loop.i: Loop is not parallel. loop.j: Loop is parallel . 10

  11. Checking loop vectorization legality $ opt -polly-process-unprofitable \ void f ( int *A, int N ) { -polyhedral-info \ for ( int j = 0; j < N; j++ ) -polly-check-vectorizable \ for ( int i = 0; i < N; i++ ) -analyze 3.ll A[i + 8] = A[i] + 1; } loop.j: Loop is not vectorizable loop.i: Loop is vectorizable with max VF = 8 11

  12. Using PolyhedralInfo in LLVM Include the header PolyhedralInfo #include "polly/PolyhedralInfo.h" void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequired<PolyhedralInfo>(); … } bool runOnFunction(Function &F) override { auto *PHInfo = &getAnalysis<PolyhedralInfo>(); auto IsParallel = PHInfo->isParallel(TheLoop); … unsigned int VF = 0; auto IsVectorizable = PHInfo->isVectorizable(TheLoop, &VF); … } 12

  13. Future Work Derive runtime checks in LLVM for assumptions in Polly ❖ Modeling dependences at instruction granularity ❖ Parametric dependence distances ❖ Demand driven computation of dependences ❖ 13

  14. Thank You! 14

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend