This is an archive of the discontinued LLVM Phabricator instance.

[Polly-ACC] disallow managed memory code generation for OpenCL
AcceptedPublic

Authored by alaindenzler on Jul 6 2018, 6:57 AM.

Details

Summary

This patch disables the ManagedMemoryRewrite pass if we are not generating CUDA code. The pass was enabled by default when generating GPU code, which resulted in a failed compilation when only OpenCL was present. Additionally it attempted to rewrite alloc() and free() calls even when the command line flag was set to false, because the cli option did not guard the pass correctly.

Using this patch, the ManagedMemoryRewrite pass is only enabled if both the command line option is set and we are generating ptx code.

Diff Detail

Repository
rPLO Polly

Event Timeline

alaindenzler created this revision.Jul 6 2018, 6:57 AM

I don't like that this messes with global state. This destroys local reasoning and makes refactoring unnecessarily harder in the future.

How about instead wrapping accesses to the flag in a helper function like useManagedMemory() that performs this check?

lib/CodeGen/PPCGCodeGeneration.cpp
3569

This modifies global state.

Checking the flag using its own function now. Is this the right place to define it?

I'd prefer putting it into PPCGCodeGeneration.cpp/PPCGCodeGeneration.h.

alaindenzler updated this revision to Diff 155861.EditedJul 17 2018, 5:43 AM

Placed the useManagedMemory() function inside PPCGCodeGeneration.

Thank, only nits left!

Please upload future patches with the full context: diff -U999999 <ref-base>, or use the arcanist tool. Otherwise you can't browse it with phabricator.

include/polly/CodeGen/PPCGCodeGeneration.h
30

Is this outside the namespace?

lib/CodeGen/PPCGCodeGeneration.cpp
93

This change is unrelated.

lib/Support/RegisterPasses.cpp
245

Unrelated change.

Thanks, now using polly namespace.

philip.pfaffe accepted this revision.Jul 17 2018, 6:39 AM

Thanks! LGTM.

This revision is now accepted and ready to land.Jul 17 2018, 6:39 AM