I’m having trouble with the cudaMalloc/cudaMallocHost functions. The 1st call always fails with cudaErrorUnknown. The following calls are OK though (with same parameter values). Is there something I’m missing, like an initialization function? I tried moving function calls to put a cudaMalloc before the cudaMallocHost, in that case it’s the 1st call to cudaMalloc that fails.
__host__ void* _AllocateHostBuffer( int width, int height)
{
unsigned char *hostData = NULL;
int memSize = width*height;
cudaError_t errVal;
errVal = cudaMallocHost( (void**)&hostData, memSize ); // <--- on 1st call, fails
if(errVal == cudaSuccess)
return hostData;
else
{
// Try again (for some reason, the 1st call to cudaMallocxyz fails)
errVal = cudaMallocHost( (void**)&hostData, memSize ); // <--- OK
if(errVal == cudaSuccess)
return hostData;
else
return NULL;
}
}