SWDEV-292714 - Add support for hipPointerGetAttribute (#2425)

Change-Id: I9062ab2ef88d835a35fd4c9251d03f469677fa4e

[ROCm/hip commit: 610565fe68]
This commit is contained in:
Satyanvesh Dittakavi
2021-12-02 11:47:10 +05:30
committed by GitHub
parent 051a25b447
commit a2cacf8c27
2 changed files with 72 additions and 5 deletions
+35 -1
View File
@@ -436,7 +436,41 @@ typedef enum hipFunction_attribute {
HIP_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES,
HIP_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT,
HIP_FUNC_ATTRIBUTE_MAX
}hipFunction_attribute;
} hipFunction_attribute;
typedef enum hipPointer_attribute {
HIP_POINTER_ATTRIBUTE_CONTEXT = 1, ///< The context on which a pointer was allocated
///< @warning - not supported in HIP
HIP_POINTER_ATTRIBUTE_MEMORY_TYPE, ///< memory type describing location of a pointer
HIP_POINTER_ATTRIBUTE_DEVICE_POINTER,///< address at which the pointer is allocated on device
HIP_POINTER_ATTRIBUTE_HOST_POINTER, ///< address at which the pointer is allocated on host
HIP_POINTER_ATTRIBUTE_P2P_TOKENS, ///< A pair of tokens for use with linux kernel interface
///< @warning - not supported in HIP
HIP_POINTER_ATTRIBUTE_SYNC_MEMOPS, ///< Synchronize every synchronous memory operation
///< initiated on this region
HIP_POINTER_ATTRIBUTE_BUFFER_ID, ///< Unique ID for an allocated memory region
HIP_POINTER_ATTRIBUTE_IS_MANAGED, ///< Indicates if the pointer points to managed memory
HIP_POINTER_ATTRIBUTE_DEVICE_ORDINAL,///< device ordinal of a device on which a pointer
///< was allocated or registered
HIP_POINTER_ATTRIBUTE_IS_LEGACY_HIP_IPC_CAPABLE, ///< if this pointer maps to an allocation
///< that is suitable for hipIpcGetMemHandle
///< @warning - not supported in HIP
HIP_POINTER_ATTRIBUTE_RANGE_START_ADDR,///< Starting address for this requested pointer
HIP_POINTER_ATTRIBUTE_RANGE_SIZE, ///< Size of the address range for this requested pointer
HIP_POINTER_ATTRIBUTE_MAPPED, ///< tells if this pointer is in a valid address range
///< that is mapped to a backing allocation
HIP_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES,///< Bitmask of allowed hipmemAllocationHandleType
///< for this allocation @warning - not supported in HIP
HIP_POINTER_ATTRIBUTE_IS_GPU_DIRECT_RDMA_CAPABLE, ///< returns if the memory referenced by
///< this pointer can be used with the GPUDirect RDMA API
///< @warning - not supported in HIP
HIP_POINTER_ATTRIBUTE_ACCESS_FLAGS, ///< Returns the access flags the device associated with
///< for the corresponding memory referenced by the ptr
HIP_POINTER_ATTRIBUTE_MEMPOOL_HANDLE ///< Returns the mempool handle for the allocation if
///< it was allocated from a mempool
///< @warning - not supported in HIP
} hipPointer_attribute;
#endif // !defined(__HIPCC_RTC__)
#else
#error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__");
+37 -4
View File
@@ -1977,15 +1977,48 @@ hipError_t hipEventQuery(hipEvent_t event);
/**
* @brief Return attributes for the specified pointer
*
* @param[out] attributes for the specified pointer
* @param[in] pointer to get attributes for
* @param [out] attributes attributes for the specified pointer
* @param [in] ptr pointer to get attributes for
*
* @return #hipSuccess, #hipErrorInvalidDevice, #hipErrorInvalidValue
*
* @see hipGetDeviceCount, hipGetDevice, hipSetDevice, hipChooseDevice
* @see hipPointerGetAttribute
*/
hipError_t hipPointerGetAttributes(hipPointerAttribute_t* attributes, const void* ptr);
/**
* @brief Returns information about the specified pointer.[BETA]
*
* @param [in, out] data returned pointer attribute value
* @param [in] atribute attribute to query for
* @param [in] ptr pointer to get attributes for
*
* @return #hipSuccess, #hipErrorInvalidDevice, #hipErrorInvalidValue
*
* @beta This API is marked as beta, meaning, while this is feature complete,
* it is still open to changes and may have outstanding issues.
*
* @see hipPointerGetAttributes
*/
hipError_t hipPointerGetAttribute(void* data, hipPointer_attribute attribute,
hipDeviceptr_t ptr);
/**
* @brief Returns information about the specified pointer.[BETA]
*
* @param [in] numAttributes number of attributes to query for
* @param [in] attributes attributes to query for
* @param [in, out] data a two-dimensional containing pointers to memory locations
* where the result of each attribute query will be written to
* @param [in] ptr pointer to get attributes for
*
* @return #hipSuccess, #hipErrorInvalidDevice, #hipErrorInvalidValue
*
* @beta This API is marked as beta, meaning, while this is feature complete,
* it is still open to changes and may have outstanding issues.
*
* @see hipPointerGetAttribute
*/
hipError_t hipDrvPointerGetAttributes(unsigned int numAttributes, hipPointer_attribute* attributes,
void** data, hipDeviceptr_t ptr);
/**
* @brief Imports an external semaphore.
*