From cbcae4eecc2544175322b9de6af726518887d4a3 Mon Sep 17 00:00:00 2001 From: Yong Zhao Date: Wed, 29 Nov 2017 11:48:10 -0500 Subject: [PATCH] Workaround: make mmap memory resident for gfx902 Change-Id: I5f90f316740f7995d54cb083a6d7e05bc4e2966e Signed-off-by: Yong Zhao [ROCm/ROCR-Runtime commit: 716755b1de0bf0da68be5f00187a5494b0796719] --- projects/rocr-runtime/src/fmm.c | 4 ++++ projects/rocr-runtime/src/queues.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/projects/rocr-runtime/src/fmm.c b/projects/rocr-runtime/src/fmm.c index ceae462d79..44492b63f3 100644 --- a/projects/rocr-runtime/src/fmm.c +++ b/projects/rocr-runtime/src/fmm.c @@ -933,6 +933,8 @@ void *fmm_allocate_scratch(uint32_t gpu_id, uint64_t MemorySizeInBytes) munmap(aligned_end, VOID_PTRS_SUB(padded_end, aligned_end)); mem = aligned_start; + + memset(mem, 0, aligned_size); } /* Remember scratch backing aperture for later */ @@ -1131,6 +1133,8 @@ static void *fmm_allocate_host_cpu(uint64_t MemorySizeInBytes, if (mem == MAP_FAILED) return NULL; + memset(mem, 0, MemorySizeInBytes); + pthread_mutex_lock(&cpuvm_aperture.fmm_mutex); vm_obj = aperture_allocate_object(&cpuvm_aperture, mem, 0, MemorySizeInBytes, flags.Value); diff --git a/projects/rocr-runtime/src/queues.c b/projects/rocr-runtime/src/queues.c index c698c5ca6e..42c86a395f 100644 --- a/projects/rocr-runtime/src/queues.c +++ b/projects/rocr-runtime/src/queues.c @@ -323,6 +323,9 @@ static void *allocate_exec_aligned_memory_cpu(uint32_t size) if (ptr == MAP_FAILED) return NULL; + + memset(ptr, 0, size); + return ptr; }