thirdparty/cuda/api/memory.hpp
inline bool is_part_of_a_region_pair(void* ptr)
{
	cudaPointerAttributes attributes;
	auto result = cudaPointerGetAttributes(&attributes, ptr);
	cuda::throw_if_error(result, "Could not obtain device pointer attributes");
#ifdef DEBUG
	auto self_copy = (attributes.memoryType == cudaMemoryTypeHost) ?
		attributes.hostPointer : attributes.devicePointer ;
	if (self_copy != ptr) {
		throw runtime_error(cudaErrorUnknown, "Inconsistent data obtained from the CUDA runtime API");
	}
#endif
	auto corresponding_buffer_ptr =
		(attributes.memoryType == cudaMemoryTypeHost) ?
		attributes.devicePointer : attributes.hostPointer;
	return (corresponding_buffer_ptr != nullptr);
}
/**
 * Determine whether a given stretch of memory was allocated as part of
 * a mapped pair of host and device memory regions
 *
 * @param ptr the beginning of a memory region - in either host or device
 * memory - to check
 * @return `true` iff the region was allocated as one side of a mapped
 * memory region pair
 */
Determine whether a given stretch of memory was allocated as part of
a mapped pair of host and device memory regions

@param ptr the beginning of a memory region - in either host or device
memory - to check
@return `true` iff the region was allocated as one side of a mapped
memory region pair
Determine whether a given stretch of memory was allocated as part of a mapped pair of host and device memory regions @param ptr the beginning of a memory region - in either host or device memory - to check @return ` true ` iff the region was allocated as one side of a mapped memory region pair
inline bool is_part_of_a_region_pair(void* ptr)
{
	cudaPointerAttributes attributes;
	auto result = cudaPointerGetAttributes(&attributes, ptr);
	cuda::throw_if_error(result, "Could not obtain device pointer attributes");
#ifdef DEBUG
	auto self_copy = (attributes.memoryType == cudaMemoryTypeHost) ?
		attributes.hostPointer : attributes.devicePointer ;
	if (self_copy != ptr) {
		throw runtime_error(cudaErrorUnknown, "Inconsistent data obtained from the CUDA runtime API");
	}
#endif
	auto corresponding_buffer_ptr =
		(attributes.memoryType == cudaMemoryTypeHost) ?
		attributes.devicePointer : attributes.hostPointer;
	return (corresponding_buffer_ptr != nullptr);
}
inline bool is_part_of_a_region_pair ( void * ptr ) { cudaPointerAttributes attributes ; auto result = cudaPointerGetAttributes ( & attributes , ptr ) ; cuda :: throw_if_error ( result , " " ) ; #ifdef DEBUG auto self_copy = ( attributes . memoryType == cudaMemoryTypeHost ) ? attributes . hostPointer : attributes . devicePointer ; if ( self_copy != ptr ) { throw runtime_error ( cudaErrorUnknown , " " ) ; } #endif auto corresponding_buffer_ptr = ( attributes . memoryType == cudaMemoryTypeHost ) ? attributes . devicePointer : attributes . hostPointer ; return ( corresponding_buffer_ptr != nullptr ) ; }
Determine whether a given stretch of memory was allocated as part of
 a mapped pair of host and device memory regions
Determine whether a given stretch of memory was allocated as part of a mapped pair of host and device memory regions