<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - CUDA static member variable initialization issue"
href="https://bugs.llvm.org/show_bug.cgi?id=49682">49682</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>CUDA static member variable initialization issue
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>11.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>CUDA
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>kjain14@utexas.edu
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=24676" name="attach_24676" title="Program showing issue">attachment 24676</a> <a href="attachment.cgi?id=24676&action=edit" title="Program showing issue">[details]</a></span>
Program showing issue
Summary:
Currently, static member variables can be used in both host and device code.
However, it is not possible to initialize
both host and device copies of these static member variables.
Description:
Marking either the declaration or definition of the static member variable with
__device__ initializes the device copy
with the value in the definition. Attempting to define the host copy results
in a redefinition error.
In the attached code, we define the device copy on line 10. The printf
statement in the kernel prints 3 and the printf
statement in main prints 1.
If we comment out the device definition and leave the host definition, then the
printf statement in the kernel prints 1
and the printf statement in main prints 3. We also get a warning from ptxas:
ptxas warning : Unresolved extern variable '_ZN2c02v0E' in whole program
compilation, ignoring extern qualifier
Is there any way to define the host and device copies to either the same or
different values?</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>