ptxas fatal : Unresolved extern function

Problem

nvcc said

ptxas fatal : Unresolved extern function
when I wrote a __global__ and __device__ function separately in two .cu files.

Like this:

a.cu
__global__ void kernel(...){
    some_func(...);
}
b.cu
__device__ void some_func(...){
    ...
}
compile
nvcc a.cu b.cu

Cause

__deivce__ functions are performed inline expansion.
If __global__ and __device__ functions are written on two separated files, nvcc can't perform inline expansion.

Solutions

There are tow ways to solve.

1. Use nvcc option

$ nvcc --device-c a.cu b.cu
or
$ nvcc -dc a.cu b.cu

2. Write on a same file

a.cu
__device__ void some_func(...){
    ...
}

__global__ void kernel(...){
    some_func(...);
}
Date:2018-08-26