cuda.bindings._v2.driver.mem_get_location_info#

cuda.bindings._v2.driver.mem_get_location_info(
uint64_t ptr,
size_t size,
size_t summary_granularity,
size_t sampling_granularity,
)#

Gets residency information for a memory address range.

Retrieves memory location information for the specified address range starting at ptr with size size. The API summarizes the location information with a granularity specified by summary_granularity. For each summary region, the API determines the most common location by sampling memory at intervals defined by sampling_granularity within that region. The location information is returned in the location_out array, with one entry per summary region. The total number of locations returned will be ceil(size/summary_granularity). The user is expected to allocate the location_out array with sufficient memory. For example, with an address range of 1GB, a summary_granularity of 128MB, and a sampling_granularity of 2MB, the function will:.

  • Divide the 1GB range into 8 summary regions of 128MB each.

  • Within each 128MB region, sample every 2MB to determine the most common location. If there is a tie a random winner is chosen.

  • Populate the location_out array with 8 entries, one for each 128MB region summary_granularity should be less than or equal to size and greater than 0. sampling_granularity should be less than or equal to summary_granularity. If the sampling_granularity is set to 0, a system dependent value is used as the granularity. In all other cases, the call returns CUDA_ERROR_INVALID_VALUE.

When the memory is not resident on any processor, the call returns CUDA_SUCCESS and the returned location type for that interval is CU_MEM_LOCATION_TYPE_NONE. The memory range must refer to one of the following:.

  • Managed memory allocated via cuMemAllocManaged, via cuMemAllocFromPool from a managed memory pool or declared via managed variables.

  • System-allocated pageable memory that is not registered via cuMemHostRegister. If the memory range does not refer to one of the above, the call returns CUDA_ERROR_INVALID_VALUE.

All devices on the system must have non-zero value of device attribute CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS. If not, this call returns CUDA_ERROR_NOT_SUPPORTED.

Parameters:
  • ptr (uint64_t) – Starting address of the memory range to query.

  • size (size_t) – Size in bytes of the memory range to query.

  • summary_granularity (size_t) – Granularity in bytes at which to summarize location information.

  • sampling_granularity (size_t) – Granularity in bytes at which to sample memory within each summary region.

Returns:

Array to store location information, one entry

per summary region.

Return type:

CUmemLocation_v1

See also

cuMemGetLocationInfo