From 9b39bdf3e01bdb9f112447006e2c57777bd38e85 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 16 Mar 2016 07:32:54 -0500 Subject: [PATCH] src/ fixed hipHostAllocDefault flags [ROCm/hip commit: b76856890261bc4dc0f9c46f043b73b56640ec4e] --- projects/hip/src/hip_hcc.cpp | 34 ++++++++++++------------- projects/hip/tests/src/hipHostAlloc.cpp | 9 ++++--- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 41aea51c0c..af03c49dcd 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -2054,31 +2054,31 @@ hipError_t hipHostAlloc(void** ptr, size_t sizeBytes, unsigned int flags){ auto device = ihipGetTlsDefaultDevice(); if(device){ - if(flags & hipHostAllocDefault){ - const unsigned am_flags = amHostPinned; + if(flags == hipHostAllocDefault){ + const unsigned am_flags = amHostPinned; - *ptr = hc::am_alloc(sizeBytes, device->_acc, am_flags); - if(sizeBytes && (*ptr == NULL)){ - hip_status = hipErrorMemoryAllocation; - }else{ - hc::am_memtracker_update(*ptr, device->_device_index, 0); - } - tprintf(DB_MEM, " %s: pinned ptr=%p\n", __func__, *ptr); + *ptr = hc::am_alloc(sizeBytes, device->_acc, am_flags); + if(sizeBytes && (*ptr == NULL)){ + hip_status = hipErrorMemoryAllocation; + }else{ + hc::am_memtracker_update(*ptr, device->_device_index, 0); + } + tprintf(DB_MEM, " %s: pinned ptr=%p\n", __func__, *ptr); } if(flags & hipHostAllocMapped){ - const unsigned am_flags = amHostPinned; + const unsigned am_flags = amHostPinned; - *ptr = hc::am_alloc(sizeBytes, device->_acc, am_flags); - if(sizeBytes && (*ptr == NULL)){ - hip_status = hipErrorMemoryAllocation; - }else{ - hc::am_memtracker_update(*ptr, device->_device_index, flags); + *ptr = hc::am_alloc(sizeBytes, device->_acc, am_flags); + if(sizeBytes && (*ptr == NULL)){ + hip_status = hipErrorMemoryAllocation; + }else{ + hc::am_memtracker_update(*ptr, device->_device_index, flags); // void *srcPtr; // hsa_status_t hsa_status = hsa_amd_memory_lock((*ptr), sizeBytes, &device->_hsa_agent, 1, &srcPtr); // assert(hsa_status == HSA_STATUS_SUCCESS); // hc::am_memtracker_add(srcPtr, sizeBytes, device->_acc, false); - } - tprintf(DB_MEM, " %s: pinned ptr=%p\n", __func__, *ptr); + } + tprintf(DB_MEM, " %s: pinned ptr=%p\n", __func__, *ptr); } } return ihipLogStatus(hip_status); diff --git a/projects/hip/tests/src/hipHostAlloc.cpp b/projects/hip/tests/src/hipHostAlloc.cpp index 072582d85f..fe82a0c78f 100644 --- a/projects/hip/tests/src/hipHostAlloc.cpp +++ b/projects/hip/tests/src/hipHostAlloc.cpp @@ -39,14 +39,14 @@ int device; HIPCHECK(hipGetDevice(&device)); HIPCHECK(hipGetDeviceProperties(&prop, device)); if(prop.canMapHostMemory != 1){ -std::cout<<"Exiting..."<