From c6ef78546477bb40fa7277983dd816cb84492cb4 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Mon, 25 Mar 2019 23:07:05 +0530 Subject: [PATCH] Avoid double mapping of devices to hostMalloc buffer [ROCm/hip commit: 5e917d70f38b76b2a6f81784b762328b2ed30be6] --- projects/hip/src/hip_memory.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index d540ab782b..7cae2b2a10 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -339,15 +339,19 @@ hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags) { hip_status = hipErrorInvalidValue; } else { auto device = ctx->getWriteableDevice(); - +#if (__hcc_workweek__ >= 19115) + //Avoid mapping host pinned memory to all devices by HCC + unsigned amFlags = amHostUnmapped; +#else unsigned amFlags = 0; +#endif if (flags & hipHostMallocCoherent) { - amFlags = amHostCoherent; + amFlags |= amHostCoherent; } else if (flags & hipHostMallocNonCoherent) { - amFlags = amHostNonCoherent; + amFlags |= amHostNonCoherent; } else { // depends on env variables: - amFlags = HIP_HOST_COHERENT ? amHostCoherent : amHostNonCoherent; + amFlags |= HIP_HOST_COHERENT ? amHostCoherent : amHostNonCoherent; }