Dependence distance and basic polly usage

38 views
Skip to first unread message

Graman

unread,
Jun 22, 2021, 9:57:09 AM6/22/21
to Polly Development

Hi,

I'm trying to use polly with llvm, my idea was to use the result of the analysis with polly on one of my pass.

After some problems with the library I managed to write an empty pass with the polly lib included  (I had to add some line in the cmakelist file of the polly project).

Now I want to do something like this, in particular I want to write a pass that identify all the loop carried dependence and prints the instruction associate to it and their distance.
I started with this piece of code just to get more comfortable using the library:

virtual void getAnalysisUsage(AnalysisUsage &AU) const {

    AU.addRequiredTransitive<DependenceInfoWrapperPass>();
    AU.addRequired<LoopInfoWrapperPass>();
    AU.addRequiredTransitive<ScopInfoWrapperPass>();
    AU.setPreservesAll();

   }

  bool runOnFunction(Function &F) override {
  DependenceInfoWrapperPass *DI = &getAnalysis<DependenceInfoWrapperPass>();
  ScopInfo *SI = getAnalysis<ScopInfoWrapperPass>().getSI();
  for(ScopInfo::iterator i = SI->begin(), e = SI->end(); i!=e; i++){
    errs() << "ok\n";
  }
  }
 I run it on my code, and I don't see anything in output, but I was expecting at least one "ok".

I'm sure that I have the scop in my c program since I only wrote one loop like this:

for(int i = 1; i < 10; i++){
a[i]+=a[i-1];
}

I've double checked also by following this and those commands prints all the information that I expect.

Do you know why it doesn't print anything or do you have a short working example that prints all the dependencies and distances in a loop?


PS a simple tutorial on the site like the one on llvm would be great for new comers, I'm still not so sure about what I did. It works, but it doesn't feel right.

Michael Kruse

unread,
Jun 22, 2021, 4:50:48 PM6/22/21
to Graman, Polly Development
Most likely you did not run the canonicalization passes before your
pass. These are required in order to detect scops. You can use
polly::registerCanonicalicationPasses. Also add
polly::createCodePreparationPass().

You should be able to print dependency info using

$ clang -O3 -mllvm -polly -mllvm -debug-only=polly-dependence

Or run the canonicalization separately:

$ clang -O3 -Xclang -disable-llvm-optzns -emit-llvm -S | opt
-polly-canonicalize -polly-prepare -polly-dependences -analyze

(did not try out any of them myself, might have forgotten something)

Michael
> --
> You received this message because you are subscribed to the Google Groups "Polly Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to polly-dev+...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/polly-dev/8813dfc6-5c15-4d4d-ba61-b4395a4793fdn%40googlegroups.com.



--
Tardyzentrismus verboten!

Graman

unread,
Jun 25, 2021, 3:25:26 AM6/25/21
to Polly Development
Thank you for the response, sadly I did already try with something like the one you proposed, but it doesn't work.

I should try some different approach to get the Scops of a function

ps
-debug-only=polly-dependence doesn't seems to exist:
clang (LLVM option parsing): for the --debug-pass option: Cannot find option named 'polly-dependence'!

Graman

unread,
Jun 25, 2021, 11:34:15 AM6/25/21
to Polly Development
Ok I think I've found the problem.
Since the loop that I wrote was too simple and would not benefit from a polly optimization then it's scop was discarded.
To solve this I've added the -polly-process-unprofittable flag

Michael Kruse

unread,
Jun 25, 2021, 2:09:57 PM6/25/21
to Graman, Polly Development
Am Fr., 25. Juni 2021 um 10:34 Uhr schrieb Graman <ofey...@gmail.com>:
> Ok I think I've found the problem.
> Since the loop that I wrote was too simple and would not benefit from a polly optimization then it's scop was discarded.
> To solve this I've added the -polly-process-unprofittable flag

Good to hear you found the problem. Feel free to ask more questions if needed.


Am Fr., 25. Juni 2021 um 02:25 Uhr schrieb Graman <ofey...@gmail.com>:
> -debug-only=polly-dependence doesn't seems to exist:
> clang (LLVM option parsing): for the --debug-pass option: Cannot find option named 'polly-dependence'!

You need an assert build for this to work (LLVM_ENABLE_ASSERTIONS=ON).
The message does not match the option (`--debug-pass` vs
`-debug-only`). The -debug-only option will just not do anything if
the argument is never used. The `-debug` option prints everything.
Lookup LLVM_DEBUG to see how it works.

Michael

--
Tardyzentrismus verboten!
Reply all
Reply to author
Forward
0 new messages