I'm running CentOS release 5.9 (Final) with CUDA, having a Tesla card with major version 1 and minor version 3. The following is my kernel code:
__global__ void foo(int* pos, int t)
{
int index = blockDim.x * blockIdx.x + threadIdx.x;
t = pos [index + 1] - pos [index];
char* temp = (char*)malloc(t);
}
I want to allocate t bytes dynamically.
This gives me the error:
calling a host function("malloc") from a __device__/__global__ function("foo") is not allowed.
What can I do to solve this problem?
malloc, notcudaMalloc(though, according to your error message, this is what you are doing in your actual code). - aland