This is an archive of the discontinued LLVM Phabricator instance.

[HIP] Add option -fgpu-allow-device-init
ClosedPublic

Authored by yaxunl on Oct 21 2019, 10:28 AM.

Details

Summary

Add this option to allow device side class type global variables
with non-trivial ctor/dtor. device side init/fini functions will
be emitted, which will be executed by HIP runtime when
the fat binary is loaded/unloaded.

This feature is to facilitate implementation of device side
sanitizer which requires global vars with non-trival ctors.

By default this option is disabled.

Diff Detail

Event Timeline

yaxunl created this revision.Oct 21 2019, 10:28 AM
tra accepted this revision.Oct 21 2019, 10:51 AM

Nice. I wish we could do that for CUDA.

lib/Frontend/CompilerInvocation.cpp
2530 ↗(On Diff #225911)

It would be useful if we could get a warning if someone attempts to use this option for CUDA compilation, where the compiler will not enable device-side init.

This revision is now accepted and ready to land.Oct 21 2019, 10:51 AM
yaxunl updated this revision to Diff 226044.Oct 22 2019, 7:17 AM

Add warning

yaxunl marked 2 inline comments as done.Oct 22 2019, 7:18 AM
yaxunl added inline comments.
lib/Frontend/CompilerInvocation.cpp
2530 ↗(On Diff #225911)

I added a warning about this option is ignored for CUDA.

tra accepted this revision.Oct 22 2019, 8:52 AM

Thank you for adding the warning. One small nit about the name. LGTM otherwise.

include/clang/Basic/DiagnosticCommonKinds.td
308 ↗(On Diff #226044)

warn_ignore*d*_hip_only_option ?

yaxunl marked 3 inline comments as done.Oct 22 2019, 8:57 AM
yaxunl added inline comments.
include/clang/Basic/DiagnosticCommonKinds.td
308 ↗(On Diff #226044)

will do when commit. thanks.

This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptOct 22 2019, 1:08 PM