Page MenuHomePhabricator

[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

Unit TestsFailed

TimeTest
110 msx64 debian > ORC-x86_64-linux.TestCases/Linux/x86-64::trivial-cxa-atexit.S
Script: -- : 'RUN: at line 3'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang -m64 -c -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/orc/X86_64LinuxConfig/TestCases/Linux/x86-64/Output/trivial-cxa-atexit.S.tmp /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/orc/TestCases/Linux/x86-64/trivial-cxa-atexit.S
100 msx64 debian > ORC-x86_64-linux.TestCases/Linux/x86-64::trivial-static-initializer.S
Script: -- : 'RUN: at line 7'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang -m64 -c -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/orc/X86_64LinuxConfig/TestCases/Linux/x86-64/Output/trivial-static-initializer.S.tmp /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/orc/TestCases/Linux/x86-64/trivial-static-initializer.S
110 msx64 debian > ORC-x86_64-linux.TestCases/Linux/x86-64::trivial-tls.S
Script: -- : 'RUN: at line 1'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang -m64 -c -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/orc/X86_64LinuxConfig/TestCases/Linux/x86-64/Output/trivial-tls.S.tmp /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/orc/TestCases/Linux/x86-64/trivial-tls.S

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