SWDEV-251360 - Add tracing for memory allocation/free.

This can be used to debug VM fault

Change-Id: I7685485b0450ea84d10b710639ad7b6c5ec2fcf3
This commit is contained in:
Alex Xie
2020-09-27 19:02:57 -04:00
zatwierdzone przez AlexBin Xie
rodzic a224dc2a7b
commit e4e6c46356
2 zmienionych plików z 8 dodań i 0 usunięć
+4
Wyświetl plik
@@ -1778,6 +1778,7 @@ void* Device::hostAlloc(size_t size, size_t alignment, bool atomics) const {
: system_segment_;
assert(segment.handle != 0);
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) {
LogError("Fail allocation host memory");
return nullptr;
@@ -1804,6 +1805,7 @@ void* Device::hostAgentAlloc(size_t size, const AgentInfo& agentInfo, bool atomi
: agentInfo.fine_grain_pool;
assert(segment.handle != 0);
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) {
LogPrintfError("Fail allocation host memory with err %d", stat);
return nullptr;
@@ -1910,6 +1912,7 @@ void* Device::deviceLocalAlloc(size_t size, bool atomics) const {
void* ptr = nullptr;
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) {
LogError("Fail allocation local memory");
return nullptr;
@@ -1925,6 +1928,7 @@ void* Device::deviceLocalAlloc(size_t size, bool atomics) const {
void Device::memFree(void* ptr, size_t size) const {
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) {
LogError("Fail freeing local memory");
}
+4
Wyświetl plik
@@ -261,6 +261,9 @@ bool Memory::createInteropBuffer(GLenum targetType, int miplevel) {
1, &agent, out.dmabuf_fd, 0, &size, &deviceMemory_, &metadata_size, (const void**)&metadata);
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;
if (status != HSA_STATUS_SUCCESS) return false;
@@ -283,6 +286,7 @@ bool Memory::createInteropBuffer(GLenum targetType, int miplevel) {
void Memory::destroyInteropBuffer() {
assert(kind_ == MEMORY_KIND_INTEROP && "Memory must be interop type.");
hsa_amd_interop_unmap_buffer(deviceMemory_);
ClPrint(amd::LOG_DEBUG, amd::LOG_MEM, "Unmap GL memory %p", deviceMemory_);
deviceMemory_ = nullptr;
}