It seems the examples in one of the CUDA books (CUDA by Example: An Introduction to General-Purpose GPU Programming) never nullify pointers when initializing them.
Two questions:
Does GPU use 0x0 (or integer 0) as NULL pointer? Should we follow the C/C++ pointer practice with device pointers (e.g. nullify them when initializing)
Do we need to check whether the pointer is NULL before cudaFree it ? if (devPtr) HANDLE_ERROR(cudaFree(devPtr));
Someone said that for Fermi architecture, 0x0 is used for on-chip shared memory, it seems that it's still okay for use to assume that 0x0 should not be pointed by a used pointer.
http://forums.thedailywtf.com/forums/p/25369/273567.aspx
What about Kepler architecture? What does GPU do with 0x0 address?
Thank you!