I'm trying to decouple my code a bit and something fails. Compilation error:
error: calling a __host__ function("DecoupledCallGpu") from a __global__ function("kernel") is not allowed
Code excerpt:
main.c (has a call to cuda host function):
#include "cuda_compuations.h"
...
ComputeSomething(&var1,&var2);
...
cuda_computations.cu (has kernel, host master functions and includes header which has device unctions):
#include "cuda_computations.h"
#include "decoupled_functions.cuh"
...
__global__ void kernel(){
...
DecoupledCallGpu(&var_kernel);
}
void ComputeSomething(int *var1, int *var2){
//allocate memory and etc..
...
kernel<<<20,512>>>();
//cleanup
...
}
decoupled_functions.cuh:
#ifndef _DECOUPLEDFUNCTIONS_H_
#define _DECOUPLEDFUNCTIONS_H_
void DecoupledCallGpu(int *var);
#endif
decoupled_functions.cu:
#include "decoupled_functions.cuh"
__device__ void DecoupledCallGpu(int *var){
*var=0;
}
#endif
Compilation:
nvcc -g --ptxas-options=-v -arch=sm_30 -c cuda_computations.cu -o cuda_computations.o -lcudart
Question: why is it that the DecoupledCallGpu
is called from host function and not a kernel as it was supposed to?
P.S.: I can share the actual code behind it if you need me to.