This is an archive of the discontinued LLVM Phabricator instance.

[Polly] [ManagedMemoryRewrite] Introduce a new pass to rewrite modules to use managed memory.
ClosedPublic

Authored by bollu on Aug 9 2017, 5:18 AM.

Details

Summary

This pass is useful to automatically convert a codebase that uses malloc/free
to use their managed memory counterparts.

Currently, rewrite malloc and free to the polly_{malloc,free}Managed variants.

A future patch will teach ManagedMemoryRewrite to rewrite global arrays
as pointers to globally allocated managed memory.

Diff Detail

Repository
rL LLVM

Event Timeline

bollu created this revision.Aug 9 2017, 5:18 AM
grosser accepted this revision.Aug 9 2017, 5:30 AM

LGTM!

This revision is now accepted and ready to land.Aug 9 2017, 5:30 AM
This revision was automatically updated to reflect the committed changes.
singam-sanjay edited edge metadata.Aug 14 2017, 9:36 AM

Sorry about the delayed response.

@bollu It'd helpful if you could replace cudaFree and cudaManagedMalloc with alternatives from the Driver API or add_cuda_library(GPURuntime ...)

I had a look at the code, but couldn't really figure out what was happening in polly_freeManaged until you added the ManagedMemoryRewritePass, so I've been just commenting them out till now.

polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
807

"Device must only be"

1027

unmanaged memory

polly/trunk/lib/Support/RegisterPasses.cpp
352

Should this be fenced by PollyManaged ?

384

Should this be fenced by PollyManged ?

Also, when Target=TARGET_GPU, this would default to producing PTX. So can you change,

PM.add(polly::createManagedMemoryRewritePassPass())); -> PM.add(polly::createManagedMemoryRewritePassPass(GPUArchChoice,GPURuntimeChoice));

Or was this intended behaviour ?