@Eugene provided the answer to this question.
I created the prototype of the called-to function like this
__device__ void RestoreThreadState(SimState *d_state, GPUThreadStates *tstates,
PhotonStructGPU *photon,
UINT64 *rnd_x, UINT32 *rnd_a,
UINT32 *is_active);
But, with an example given by Eugene it should be like this (NOT A PROTOTYPE! See other answer)
__device__ void RestoreThreadState(SimState *d_state, GPUThreadStates *tstates,
PhotonStructGPU *photon,
UINT64 *rnd_x, UINT32 *rnd_a,
UINT32 *is_active){}
Note the {}
at the end.
Next in the code I call to functions which actually return values like this
__device__ int HitBoundary(PhotonStructGPU *photon);
Called from the same MCMLKernel
template function. It is giving me a warning:
- warning: missing return statement at end of non-void function "HitBoundary"
UPDATE: In another source file kernel.cu I have the following declaration and definition (reason why I have multiple definition problems):
__device__ void RestoreThreadState(SimState *d_state, GPUThreadStates *tstates,
PhotonStructGPU *photon,
UINT64 *rnd_x, UINT32 *rnd_a,
UINT32 *is_active)
{
UINT32 tid = blockIdx.x * NUM_THREADS_PER_BLOCK + threadIdx.x;
*rnd_x = d_state->x[tid];
*rnd_a = d_state->a[tid];
photon->x = tstates->photon_x[tid];
photon->y = tstates->photon_y[tid];
photon->z = tstates->photon_z[tid];
photon->ux = tstates->photon_ux[tid];
photon->uy = tstates->photon_uy[tid];
photon->uz = tstates->photon_uz[tid];
photon->w = tstates->photon_w[tid];
photon->sleft = tstates->photon_sleft[tid];
photon->layer = tstates->photon_layer[tid];
*is_active = tstates->is_active[tid];
}
IN SUMMARY: I have four source files
- main.cu
- kernel.cu
- rng.cu
- mem.cu
Each source file, except main.cu has an associated header
- kernel.cuh
- rng.cuh
- mem.cuh
where I want to forward-declare functions to use in main.cu.
Everything is fine until I get to the template function which calls functions from kernel.cu and rng.cu.