Is zero the "nullptr" for a device?

it looks like zero CUdeviceptr is a device equivalent of the nullptr

// d will be zeroed
CUdeviceptr d = 12345;
CUresult error = cuMemAlloc(&d, 0); 
assert(0 == d);
assert(1 == error);

// will succeed
CUresult ok = cuMemFree(0); 
assert(0 == ok);

but can cuMemAlloc() ever return the zero CUdeviceptr on success?

I thought may be the question was not quite clear

I want to init CUdeviceptr with an invalid value and later in the code check if it is allocated or not

bad value for pointers is nullptr, for files -1, what’s the bad value for CUdeviceptr?

This may be of interest.

1 Like