This is an archive of the discontinued LLVM Phabricator instance.

[NVPTX] Emit .pragma "nounroll" for loops marked with nounroll
ClosedPublic

Authored by jingyue on Jan 17 2015, 11:43 PM.

Details

Summary

CUDA driver can unroll loops when jit-compiling PTX. To prevent CUDA
driver from unrolling a loop marked with llvm.loop.unroll.disable is not
unrolled by CUDA driver, we need to emit .pragma "nounroll" at the
header of that loop.

This patch also extracts getting unroll metadata from loop ID metadata
into a shared helper function.

Diff Detail

Event Timeline

jingyue updated this revision to Diff 18356.Jan 17 2015, 11:43 PM
jingyue retitled this revision from to [NVPTX] Emit .pragma "nounroll" for loops marked with nounroll.
jingyue updated this object.
jingyue edited the test plan for this revision. (Show Details)
jingyue added reviewers: jholewinski, meheff, eliben.
jingyue added a subscriber: Unknown Object (MLST).
meheff edited edge metadata.Jan 20 2015, 10:26 AM

LGTM

lib/Target/NVPTX/NVPTXAsmPrinter.cpp
426

FYI the loop unrolling pass should replace instances of "llvm.loop.unroll.count 1" from "#pragma unroll 1" with llvm.loop.unroll.disable.

lib/Transforms/Scalar/LoopUnrollPass.cpp
237

How about calling this function GetUnrollMetadataForLoop to avoid colliding with the new function you added?

jingyue updated this revision to Diff 19077.Jan 30 2015, 7:33 PM
jingyue edited edge metadata.

Rename the original GetUnrollMetadata to GetUnrollMetadataForLoop

jingyue added inline comments.Jan 30 2015, 7:35 PM
lib/Target/NVPTX/NVPTXAsmPrinter.cpp
426

Ack'ed.

lib/Transforms/Scalar/LoopUnrollPass.cpp
237

Done.

jholewinski accepted this revision.Jan 31 2015, 6:30 AM
jholewinski edited edge metadata.

Looks good to me! Sorry for the delay, missed the original email notification.

This revision is now accepted and ready to land.Jan 31 2015, 6:30 AM
jingyue closed this revision.Jan 31 2015, 6:29 PM