This is an archive of the discontinued LLVM Phabricator instance.

[cuda] Mark builtin texture/surface reference variable as 'externally_initialized'.
ClosedPublic

Authored by hliao on Aug 8 2021, 10:14 AM.

Details

Summary
  • They need to be preserved even if there's no reference within the device code as the host code may need to initialize them based on the application logic.

Diff Detail

Event Timeline

hliao created this revision.Aug 8 2021, 10:14 AM
hliao requested review of this revision.Aug 8 2021, 10:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2021, 10:14 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
yaxunl added inline comments.Aug 9 2021, 6:56 AM
clang/lib/CodeGen/CodeGenModule.cpp
4441–4443

we need also do this with variables with HIPManagedAttr and add a test for that

hliao added inline comments.Aug 9 2021, 9:05 AM
clang/lib/CodeGen/CodeGenModule.cpp
4441–4443

those managed var seems already being marked 'externally_initalized' in lib/CodeGen/CGCUDANV.cpp. Do you have missing places to mark them?

yaxunl added a comment.Aug 9 2021, 9:13 AM

LGTM on HIP side. I am not sure whether CUDA needs this.

clang/lib/CodeGen/CodeGenModule.cpp
4441–4443

sorry, I fogot. Then it should be OK. We don't have other places to handle managed variables.

tra accepted this revision.Aug 9 2021, 10:22 AM

CUDA lowers texture/surface types into a special handle. I do not think externally_initialized matters for it.
AFAICT this change is a no-op for CUDA.

This revision is now accepted and ready to land.Aug 9 2021, 10:22 AM