SWDEV-251360 - Add tracing for memory allocation/free.
This can be used to debug VM fault Change-Id: I7685485b0450ea84d10b710639ad7b6c5ec2fcf3
This commit is contained in:
@@ -1778,6 +1778,7 @@ void* Device::hostAlloc(size_t size, size_t alignment, bool atomics) const {
|
|||||||
: system_segment_;
|
: system_segment_;
|
||||||
assert(segment.handle != 0);
|
assert(segment.handle != 0);
|
||||||
hsa_status_t stat = hsa_amd_memory_pool_allocate(segment, size, 0, &ptr);
|
hsa_status_t stat = hsa_amd_memory_pool_allocate(segment, size, 0, &ptr);
|
||||||
|
ClPrint(amd::LOG_DEBUG, amd::LOG_MEM, "Allocate hsa host memory %p, size 0x%zx", ptr, size);
|
||||||
if (stat != HSA_STATUS_SUCCESS) {
|
if (stat != HSA_STATUS_SUCCESS) {
|
||||||
LogError("Fail allocation host memory");
|
LogError("Fail allocation host memory");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -1804,6 +1805,7 @@ void* Device::hostAgentAlloc(size_t size, const AgentInfo& agentInfo, bool atomi
|
|||||||
: agentInfo.fine_grain_pool;
|
: agentInfo.fine_grain_pool;
|
||||||
assert(segment.handle != 0);
|
assert(segment.handle != 0);
|
||||||
hsa_status_t stat = hsa_amd_memory_pool_allocate(segment, size, 0, &ptr);
|
hsa_status_t stat = hsa_amd_memory_pool_allocate(segment, size, 0, &ptr);
|
||||||
|
ClPrint(amd::LOG_DEBUG, amd::LOG_MEM, "Allocate hsa host memory %p, size 0x%zx", ptr, size);
|
||||||
if (stat != HSA_STATUS_SUCCESS) {
|
if (stat != HSA_STATUS_SUCCESS) {
|
||||||
LogPrintfError("Fail allocation host memory with err %d", stat);
|
LogPrintfError("Fail allocation host memory with err %d", stat);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -1910,6 +1912,7 @@ void* Device::deviceLocalAlloc(size_t size, bool atomics) const {
|
|||||||
|
|
||||||
void* ptr = nullptr;
|
void* ptr = nullptr;
|
||||||
hsa_status_t stat = hsa_amd_memory_pool_allocate(pool, size, 0, &ptr);
|
hsa_status_t stat = hsa_amd_memory_pool_allocate(pool, size, 0, &ptr);
|
||||||
|
ClPrint(amd::LOG_DEBUG, amd::LOG_MEM, "Allocate hsa device memory %p, size 0x%zx", ptr, size);
|
||||||
if (stat != HSA_STATUS_SUCCESS) {
|
if (stat != HSA_STATUS_SUCCESS) {
|
||||||
LogError("Fail allocation local memory");
|
LogError("Fail allocation local memory");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -1925,6 +1928,7 @@ void* Device::deviceLocalAlloc(size_t size, bool atomics) const {
|
|||||||
|
|
||||||
void Device::memFree(void* ptr, size_t size) const {
|
void Device::memFree(void* ptr, size_t size) const {
|
||||||
hsa_status_t stat = hsa_amd_memory_pool_free(ptr);
|
hsa_status_t stat = hsa_amd_memory_pool_free(ptr);
|
||||||
|
ClPrint(amd::LOG_DEBUG, amd::LOG_MEM, "Free hsa memory %p", ptr);
|
||||||
if (stat != HSA_STATUS_SUCCESS) {
|
if (stat != HSA_STATUS_SUCCESS) {
|
||||||
LogError("Fail freeing local memory");
|
LogError("Fail freeing local memory");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -261,6 +261,9 @@ bool Memory::createInteropBuffer(GLenum targetType, int miplevel) {
|
|||||||
1, &agent, out.dmabuf_fd, 0, &size, &deviceMemory_, &metadata_size, (const void**)&metadata);
|
1, &agent, out.dmabuf_fd, 0, &size, &deviceMemory_, &metadata_size, (const void**)&metadata);
|
||||||
close(out.dmabuf_fd);
|
close(out.dmabuf_fd);
|
||||||
|
|
||||||
|
ClPrint(amd::LOG_DEBUG, amd::LOG_MEM, "Map GL memory %p, size 0x%zx, offset=0x%llx",
|
||||||
|
deviceMemory_, size, out.buf_offset);
|
||||||
|
|
||||||
deviceMemory_ = static_cast<char*>(deviceMemory_) + out.buf_offset;
|
deviceMemory_ = static_cast<char*>(deviceMemory_) + out.buf_offset;
|
||||||
|
|
||||||
if (status != HSA_STATUS_SUCCESS) return false;
|
if (status != HSA_STATUS_SUCCESS) return false;
|
||||||
@@ -283,6 +286,7 @@ bool Memory::createInteropBuffer(GLenum targetType, int miplevel) {
|
|||||||
void Memory::destroyInteropBuffer() {
|
void Memory::destroyInteropBuffer() {
|
||||||
assert(kind_ == MEMORY_KIND_INTEROP && "Memory must be interop type.");
|
assert(kind_ == MEMORY_KIND_INTEROP && "Memory must be interop type.");
|
||||||
hsa_amd_interop_unmap_buffer(deviceMemory_);
|
hsa_amd_interop_unmap_buffer(deviceMemory_);
|
||||||
|
ClPrint(amd::LOG_DEBUG, amd::LOG_MEM, "Unmap GL memory %p", deviceMemory_);
|
||||||
deviceMemory_ = nullptr;
|
deviceMemory_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user