HomePhabricator

[CUDA] Change initializer for CUDA device code based on CUDA documentation.

Description

[CUDA] Change initializer for CUDA device code based on CUDA documentation.

Summary:
According to CUDA documentation, global variables declared with device,
constant can be initialized from host code, so mark them as
externally initialized. Because shared variables cannot have an
initialization as part of their declaration and since the value maybe kept
across different kernel invocation, the value of shared is effectively
undefined instead of zero initialized.

Wrongly using zero initializer may cause illegitimate optimization, e.g.
removing unused constant variable because it's not updated in the device
code and the value is initialized with zero.

Test Plan: test/CodeGenCUDA/address-spaces.cu

Patch by Xuetian Weng

Reviewers: jholewinski, eliben, tra, jingyue

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12241

Details

Committed
jingyueAug 21 2015, 10:49 PM
Differential Revision
D12241: [CUDA] Change initializer for CUDA device code based on CUDA documentation.
Branches
Unknown
Tags
Unknown