This is an archive of the discontinued LLVM Phabricator instance.

[CUDA] Only __shared__ variables can be static local on device side.
ClosedPublic

Authored by tra on May 6 2016, 2:26 PM.

Details

Summary

According to CUDA programming guide (v7.5):

E.2.9.4: Within the body of a device or global function, only shared variables may be declared with static storage class.

Diff Detail

Repository
rL LLVM

Event Timeline

tra updated this revision to Diff 56463.May 6 2016, 2:26 PM
tra retitled this revision from to [CUDA] Only __shared__ variables can be static local on device side..
tra updated this object.
tra added reviewers: jingyue, jlebar.
tra added a subscriber: cfe-commits.
jlebar edited edge metadata.May 6 2016, 3:13 PM

What are we supposed to do if we encounter a static shared variable in an HD function? Presumably that also should be an error if we invoke the HD function from the device?

tra added a comment.May 6 2016, 3:31 PM

What are we supposed to do if we encounter a static shared variable in an HD function? Presumably that also should be an error if we invoke the HD function from the device?

nvcc produces an error only of such HD function is used from a host function:

error: a function scope variable cannot be declared with "shared" inside a host function

Considering that each block gets its own instance of that shared variable, there's no way to access it from host in principle so the error makes sense. I'll add it in a separate patch.

jlebar accepted this revision.May 6 2016, 3:48 PM
jlebar edited edge metadata.
This revision is now accepted and ready to land.May 6 2016, 3:48 PM
tra updated this revision to Diff 56610.May 9 2016, 12:38 PM
tra edited edge metadata.

Updated tests in CodeGenCUDA/address-spaces.cu

This revision was automatically updated to reflect the committed changes.

This patch regresses Eigen, because it raises an error even on host+device functions.