This is an archive of the discontinued LLVM Phabricator instance.

[CUDA] Replace 'nv_weak' attributes in CUDA headers with 'weak'.
ClosedPublic

Authored by tra on Jun 5 2018, 4:51 PM.

Details

Summary

An alternative to implementing nv_weak attribute (D47201).

The patch should make runtime sub functions to have .weak attribute in PTX and that should avoid GPU-side linking errors.

Diff Detail

Repository
rC Clang

Event Timeline

tra created this revision.Jun 5 2018, 4:51 PM
jlebar accepted this revision.Jun 5 2018, 4:56 PM

What could possibly go wrong.

This revision is now accepted and ready to land.Jun 5 2018, 4:56 PM
tra added a comment.Jun 5 2018, 5:13 PM

I'll wait to see if that fixes @Hahnfeld's problem.

AFAICT, nv_weak is not used for anything interesting other than the device-side runtime stubs that return errors (apparently, until they are linked with the proper device runtime which would have strong version of the symbols.

I've tested with 8.0, 9.0 and 9.2 with -fcuda-rdc and all appear to produce .weak variants of those stubs in PTX.
One thing that I've noticed that we do differently is that those stubs being present in clang-generated PTX regardless of whether -fcuda-rdc is in effect. Well, there's only so much we can do with preprocessor magic. Other than wasted space, it's benign AFAICT. If it turns out that it's problematic after all, we should be able to disable them away with attribute((if_enabled...)).

Hahnfeld accepted this revision.Jun 5 2018, 11:47 PM
Hahnfeld added a subscriber: fwyzard.

Works for me, I'll abandon D47201 if you prefer this.

aaron.ballman accepted this revision.Jun 5 2018, 11:57 PM

LGTM as well, for what little it's worth. :-)

This revision was automatically updated to reflect the committed changes.