<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 separable compilation support"
href="https://bugs.llvm.org/show_bug.cgi?id=49555">49555</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>CUDA separable compilation support
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>enhancement
</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>carlosgalvezp@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Hi!
Since long time ago CUDA supports separable compilation:
<a href="https://developer.nvidia.com/blog/separate-compilation-linking-cuda-device-code/">https://developer.nvidia.com/blog/separate-compilation-linking-cuda-device-code/</a>
Is this expected to be supported in Clang? The following example doesn't work:
// lib.h
__device__ int foo();
// lib.cu
#include "lib.h"
__device__ int foo()
{
return 123;
}
// main.cu
#include "lib.h"
#include <cstdio>
__global__ kernel()
{
printf("%d\n", foo());
}
int main()
{
kernel<<<1,10>>>();
cudaDeviceSynchronize();
}
Compiling with:
clang++ ... lib.cu main.cu
Gives a linker error: cannot find reference to extern function "foo".
If this is not supported out of the box, would the following procedure be
reasonable?
1) Compile object files with clang, adding -fgpu-rdc.
2) Device link them using "nvcc -dlink *.o -o device_link.o"
3) Link everything with clang: "clang *.o device_link.o"
Thanks!</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>