I am writing an analysis that determines which program variables may
contain different values per warp thread. This is useful, for instance, to
determine which branches in the program might diverge.
Anyway, I would like to know the best way to plug my analysis onto Ocelot.
In LLVM, normally I would implement the method getAnalysisUsage in the passes
that need my analysis, e.g:
void ScalarEvolution::getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
AU.addRequiredTransitive<LoopInfo>();
AU.addRequiredTransitive<DominatorTree>();
}
And then, to call the analysis, I would use the method getAnalysis that is
part of the Pass classes. E.g:
bool ScalarEvolution::runOnFunction(Function &F) {
this->F = &F;
LI = &getAnalysis<LoopInfo>();
TD = getAnalysisIfAvailable<TargetData>();
DT = &getAnalysis<DominatorTree>();
return false;
}
What is the best way to use my analysis in Ocelot? Any example that I could
read?
Thanks a lot,
Diogo
Currently the analysis routines are plugged into the Kernel concept and
are computed lazily on their first use. I personally like LLVM's
approach better and would like to eventually move towards something
similar. This would require a redesign of parts of the Pass interface
to include a pass manager, a concept of an analysis, and a way of
specifying that a pass requires an analysis. It shouldn't be too hard
to do, so I'll put it on my list of things to do.
If you want to start working on this immediately, I would recommend
augmenting your pass with an interface similar to the llvm functions
that you mentioned:
runOnKernel(Kernel&)/getAnalysisUsage(AnalysisUsage&). In your case,
make the analysis a member of your pass that is created in
getAnalysisUsage, referenced in runOnKernel, and destroyed in the class
destructor. This should make it relatively easy to remove the analysis
from the class, modify the destructor, and replace the initial reference
in runOnKernel with a call to getAnalysis when we change the interface.
Eventually I am going to add a pass manager concept to ocelot as well
that will be responsible for creating the analysis routines and
scheduling the passes appropriately.
Regards,
Greg
On 08/25/2010 10:11 PM, Diogo N. Sampaio wrote:
> Hi oceloters,
>
> I am writing an analysis that determines which program variables may
> contain different values per warp thread. This is useful, for instance, to
> determine which branches in the program might diverge.
> Anyway, I would like to know the best way to plug my analysis onto Ocelot.
> In LLVM, normally I would implement the method getAnalysisUsage in the passes
> that need my analysis, e.g:
>
> void ScalarEvolution::getAnalysisUsage(AnalysisUsage&AU) const {
> AU.setPreservesAll();
> AU.addRequiredTransitive<LoopInfo>();
> AU.addRequiredTransitive<DominatorTree>();
> }
>
> And then, to call the analysis, I would use the method getAnalysis that is
> part of the Pass classes. E.g:
>
> bool ScalarEvolution::runOnFunction(Function&F) {
> this->F =&F;
> LI =&getAnalysis<LoopInfo>();
> TD = getAnalysisIfAvailable<TargetData>();
> DT =&getAnalysis<DominatorTree>();