Merge pull request #987 from gargrahul/fix_hostmalloc_double_device_map

Avoid double mapping of devices to hostMalloc buffer

[ROCm/clr commit: 93906a072c]
This commit is contained in:
Maneesh Gupta
2019-03-27 05:23:47 +00:00
committato da GitHub
+9 -5
Vedi File
@@ -339,21 +339,25 @@ 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;
}
*ptr = hip_internal::allocAndSharePtr(
(amFlags & amHostCoherent) ? "finegrained_host" : "pinned_host", sizeBytes, ctx,
(trueFlags & hipHostMallocPortable) /*shareWithAll*/, amFlags, flags, 0);
true /*shareWithAll*/, amFlags, flags, 0);
if (sizeBytes && (*ptr == NULL)) {
hip_status = hipErrorMemoryAllocation;