This is useful for several kinds of tests proposed.
Change-Id: If9fdd29e73f16299190b5485f473f6388aab9ec9
}
}
+bool isHostMemoryPinned(void *h_ptr)
+{
+ cudaPointerAttributes memoryAttributes;
+ cudaError_t stat = cudaPointerGetAttributes(&memoryAttributes, h_ptr);
+
+ bool result = false;
+ switch (stat)
+ {
+ case cudaSuccess:
+ result = true;
+ break;
+
+ case cudaErrorInvalidValue:
+ // If the buffer was not pinned, then it will not be recognized by CUDA at all
+ result = false;
+ // Reset the last error status
+ cudaGetLastError();
+ break;
+
+ default:
+ CU_RET_ERR(stat, "Unexpected CUDA error");
+ }
+ return result;
+}
+
/*!
* \brief Runs GPU sanity checks.
*
CUDA_FUNC_QUALIFIER
void stopGpuProfiler(void) CUDA_FUNC_TERM
+//! Tells whether the host buffer was pinned for non-blocking transfers. Only implemented for CUDA.
+CUDA_FUNC_QUALIFIER
+bool isHostMemoryPinned(void *CUDA_FUNC_ARGUMENT(h_ptr)) CUDA_FUNC_TERM_WITH_RETURN(false)
#endif