This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Add clang option to change device RTL stack size
AcceptedPublic

Authored by jhuber6 on Sep 20 2021, 2:51 PM.

Details

Summary

The OpenMP RTL uses a stack of shared-memory to handle data-sharing
that's necessary for communicating data between threads on the device.
This patch add an option in clang to set this at compile time by using a
global varialbe in the new device runtime.

The shared memory used is set by -fopenmp-target-stack-size=. This
will configure a global <kernel>_stack_size used by the libomptarget
plugin to set the amount of dynamic shared memory allocated. The size
will also be added to the __kmpc_target_init runtime call so the
device runtime can check the size and if the stack must be initialized.

Diff Detail

Event Timeline

jhuber6 created this revision.Sep 20 2021, 2:51 PM
jhuber6 requested review of this revision.Sep 20 2021, 2:51 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptSep 20 2021, 2:51 PM

The runtime code is missing, right?

The runtime code is missing, right?

Yes, was going to make that a separate patch, also need to fix the LLVM tests.

jhuber6 updated this revision to Diff 373751.Sep 20 2021, 5:07 PM

Fixing OpenMPOpt tests.

tianshilei1992 added inline comments.Sep 20 2021, 6:24 PM
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
1057

Do we want to check somewhere if it's a valid value?

jhuber6 added inline comments.Sep 20 2021, 6:26 PM
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
1057

It's an unsigned value that corresponds to how much memory gets allocated, every value should be equally valid since we don't really know how much memory there is. I was considering making it a 64-bit unsigned as well, but I figured no one would need that much shared memory.

tianshilei1992 accepted this revision.Sep 20 2021, 6:28 PM

LGTM

clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
1057

That makes sense.

This revision is now accepted and ready to land.Sep 20 2021, 6:28 PM