Tracker improvements
- add API to add / remove user-pointers from the tracker. - test for thread-safety with MultiThreadtest_2 - rapid insertions/removal. - add mutex to provide thread-safety. - rename tracker interface to "memtracker_..." for consistency. - add am_memtracker_reset, connect to hipDeviceReset. -
Цей коміт міститься в:
@@ -15,22 +15,27 @@ namespace hc {
|
||||
|
||||
// This is the data that is maintained for each pointer:
|
||||
struct AmPointerInfo {
|
||||
bool _isDeviceMem;
|
||||
void * _hostPointer;
|
||||
void * _devicePointer;
|
||||
size_t _sizeBytes;
|
||||
hc::accelerator _acc;
|
||||
unsigned _allocationFlags;
|
||||
void * _hostPointer; ///< Host pointer. If host access is not allowed, NULL.
|
||||
void * _devicePointer; ///< Device pointer.
|
||||
size_t _sizeBytes; ///< Size of allocation.
|
||||
hc::accelerator _acc; ///< Device / Accelerator to use.
|
||||
bool _isInDeviceMem; ///< Memory is physically resident on a device (if false, memory is located on host)
|
||||
bool _isAmManaged; ///< Memory was allocated by AM and should be freed when am_reset is called.
|
||||
|
||||
int _appId; ///< App-specific storage. Used by HIP to store deviceID.
|
||||
unsigned _appAllocationFlags; ///< App-specific allocation flags. Used by HIP to store allocation flags.
|
||||
|
||||
AmPointerInfo() {};
|
||||
|
||||
AmPointerInfo(bool isDeviceMem, void *hostPointer, void *devicePointer, size_t sizeBytes, hc::accelerator acc, unsigned allocationFlags) :
|
||||
_isDeviceMem(isDeviceMem),
|
||||
AmPointerInfo(void *hostPointer, void *devicePointer, size_t sizeBytes, hc::accelerator acc, bool isInDeviceMem, bool isAmManaged) :
|
||||
_hostPointer(hostPointer),
|
||||
_devicePointer(devicePointer),
|
||||
_sizeBytes(sizeBytes),
|
||||
_acc(acc),
|
||||
_allocationFlags(allocationFlags) {};
|
||||
_isInDeviceMem(isInDeviceMem),
|
||||
_isAmManaged(isAmManaged),
|
||||
_appId(-1),
|
||||
_appAllocationFlags(0) {};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -73,19 +78,46 @@ am_status_t AM_free(void* ptr);
|
||||
*/
|
||||
am_status_t AM_copy(void* dst, const void* src, size_t size);
|
||||
|
||||
am_status_t AM_get_pointer_info(hc::AmPointerInfo *info, void *ptr);
|
||||
/**
|
||||
* Return information about tracked pointer.
|
||||
*
|
||||
* AM tracks pointers when they are allocated or added to tracker with am_track_pointer.
|
||||
* The tracker tracks the base pointer as well as the size of the allocation, and will
|
||||
* find the information for a pointer anywhere in the tracked range.
|
||||
*
|
||||
* @returns AM_ERROR_MISC if pointer is not currently being tracked.
|
||||
* @returns AM_SUCCESS if pointer is tracked and writes info to @p info.
|
||||
*
|
||||
* @see AM_memtracker_add,
|
||||
*/
|
||||
am_status_t am_memtracker_getinfo(hc::AmPointerInfo *info, void *ptr);
|
||||
|
||||
//TODO-doc
|
||||
am_status_t am_memtracker_update(void* ptr, int appId, unsigned allocationFlags);
|
||||
|
||||
// TODO-implement these:
|
||||
//am_status_t AM_track_pointer(void* ptr, size_t size, bool isDeviceMem=false, unsigned allocationFlags=0x0);
|
||||
//am_status_t AM_untrack_pointer(void* ptr);
|
||||
am_status_t am_memtracker_add(void* ptr, size_t sizeBytes, hc::accelerator acc, bool isDeviceMem=false);
|
||||
|
||||
/**
|
||||
* Remove the pointer from the tracker structure.
|
||||
*
|
||||
* @p ptr may be anywhere in a tracked memory range.
|
||||
*
|
||||
* @returns AM_ERROR_MISC if pointer is not found in tracker.
|
||||
* @returns AM_SUCCESS if pointer is not found in tracker.
|
||||
*/
|
||||
am_status_t am_memtracker_remove(void* ptr);
|
||||
|
||||
/**
|
||||
* Remove all memory allocations associated with specified accelerator.
|
||||
*/
|
||||
size_t am_memtracker_reset(hc::accelerator acc);
|
||||
|
||||
/**
|
||||
* Prints the contents of the memory tracker table to stderr
|
||||
*
|
||||
* Intended primarily for debug purposes.
|
||||
**/
|
||||
void AM_print_tracker();
|
||||
void am_memtracker_print();
|
||||
|
||||
|
||||
}; // namespace hc
|
||||
|
||||
Посилання в новій задачі
Заблокувати користувача