Page MenuHomePhabricator

[polly] Add accelerator code generation pass skeleton
ClosedPublic

Authored by grosser on Jul 6 2016, 12:49 AM.

Details

Summary

Add a new pass to serve as basis for automatic accelerator mapping in Polly.
The pass structure and the analyses preserved are copied from
CodeGeneration.cpp, as we will rely on IslNodeBuilder and IslExprBuilder for
LLVM-IR code generation.

Polly's accelerator code generation is enabled with -polly-target=gpu.

I would like to use this commit as opportunity to thank Yabin Hu for his work in
the context of two Google summer of code projects during which he implemented
initial prototypes of the Polly accelerator code generation -- in parts this
code is already available in todays Polly (e.g., tools/GPURuntime). More will
come as part of the upcoming Polly ACC changes.

Diff Detail

Repository
rL LLVM

Event Timeline

grosser updated this revision to Diff 62829.Jul 6 2016, 12:49 AM
grosser retitled this revision from to Add accelerator code generation pass sceleton.
grosser updated this object.
grosser added subscribers: llvm-commits, pollydev.
Meinersbur edited edge metadata.Jul 6 2016, 4:34 AM

Title: "sceleton" -> "skeleton" and missing "[Polly]".

PPCGCodeGenerationPass sounds like it would invoke PPCG. I'd remove PPCG from the name, keeping only ACC.

Any chance to make PPCGCodeGenerationPass an alternative to the optimizer pass, or even merge it, such that the CodeGeneration would see what it has been optimized and generate the relevant code, just like OpenMP code generation. This would avoid copy&paste code duplication.

grosser retitled this revision from Add accelerator code generation pass sceleton to [polly] Add accelerator code generation pass sceleton.Jul 6 2016, 4:36 AM
grosser edited edge metadata.

Title: "sceleton" -> "skeleton" and missing "[Polly]".

Changed.

PPCGCodeGenerationPass sounds like it would invoke PPCG. I'd remove PPCG from the name, keeping only ACC.

It will, internally. If you prefer, I can still rename this pass to AcceleratorCodeGenerationPass.

Any chance to make PPCGCodeGenerationPass an alternative to the optimizer pass, or even merge it, such that the CodeGeneration would see what it has been optimized and generate the relevant code, just like OpenMP code generation. This would avoid copy&paste code duplication.

As we use PPCG it is difficult to split out the dependence analysis and scheduling changes, as both are inter-tangled and especially the GPU specific scheduling that is necessary is very different to the CPU specific schedule optimizations we perform today in Polly.

My current proposal would be to first integrate accelerator code generation as an independent transformation and -- after it has proven to work reliably -- start with integrating CPU and GPU mappings. I did some early experiments on this and it seems performing such an integration on the schedule tree level is feasible. However, it will be a lot easier to discuss when we have the relevant code working next to each other in the same repository.

Regarding code duplication, I expect little code duplication. Most of the code generation is in IslNodeGenerator / IslExprGenerator / ...
and we will just call these classes when the need arises. There will be two scheduler implementations Polly's CPU focused scheduler as well as PPCG's GPU focused scheduling strategies. As said earlier, I would prefer to wait with merging them until we have a stable code base we can use for experiments and testing.

Best,
Tobias

PPCGCodeGenerationPass sounds like it would invoke PPCG. I'd remove PPCG from the name, keeping only ACC.

It will, internally. If you prefer, I can still rename this pass to AcceleratorCodeGenerationPass.

I didn't even know that PPCG has an interface for this. I'll wait further comments until I see the larger code base. Rename at your own discretion.

lib/Support/RegisterPasses.cpp
90 ↗(On Diff #62829)

"Enable" sounds like this would add accelerator code generation to the other optimizations, but effectively replaces them. Wouldn't an equivalent to -polly-vectorizer/-polly-code-generator be more appropriate?

PPCGCodeGenerationPass sounds like it would invoke PPCG. I'd remove PPCG from the name, keeping only ACC.

It will, internally. If you prefer, I can still rename this pass to AcceleratorCodeGenerationPass.

I didn't even know that PPCG has an interface for this. I'll wait further comments until I see the larger code base. Rename at your own discretion.

PPCG does not, but the changes to use it as a library are very limited. I plan to first apply these changes in the Polly repository and -- after we gained some experience -- upstream them to the official ppcg.

OK. Then I will probably leave PPCG in the name for now.

lib/Support/RegisterPasses.cpp
90 ↗(On Diff #62829)

I can use:

-polly-code-generator=cpu
-polly-code-generator=gpu
-polly-code-generator=none

if this is preferable.

The existing -polly-code-generator=isl does not really have a useful meaning since we dropped support for CLooG.

grosser updated this revision to Diff 63027.Jul 6 2016, 9:21 PM

Use -polly-code-generator=gpu to activate GPU code generation

grosser updated this revision to Diff 63028.Jul 6 2016, 9:30 PM
grosser retitled this revision from [polly] Add accelerator code generation pass sceleton to [polly] Add accelerator code generation pass skeleton.
grosser updated this object.

Second alternative: use -polly-target=gpu

-polly-target=gpu is a good idea!

This revision was automatically updated to reflect the committed changes.