[llvm-bugs] [Bug 49683] New: CUDA static member variable	initialization issue
    via llvm-bugs 
    llvm-bugs at lists.llvm.org
       
    Mon Mar 22 09:41:52 PDT 2021
    
    
  
https://bugs.llvm.org/show_bug.cgi?id=49683
            Bug ID: 49683
           Summary: CUDA static member variable initialization issue
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: CUDA
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kjain14 at utexas.edu
                CC: llvm-bugs at lists.llvm.org
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?
-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210322/3c0ec553/attachment.html>
    
    
More information about the llvm-bugs
mailing list