diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index d9da632577..3eb59e485e 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -191,7 +191,7 @@ enum hipLimit_t { 0x2 ///< Map the allocation into the address space for the current device. The device pointer ///< can be obtained with #hipHostGetDevicePointer. #define hipHostRegisterIoMemory 0x4 ///< Not supported. - +#define hipExtHostRegisterCoarseGrained 0x8 ///< Coarse Grained host memory lock #define hipDeviceScheduleAuto 0x0 ///< Automatically select between Spin and Yield #define hipDeviceScheduleSpin \ diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index b8632970d4..0fad8ab890 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -957,15 +957,25 @@ hipError_t hipHostRegister(void* hostPtr, size_t sizeBytes, unsigned int flags) } // TODO-test : multi-gpu access to registered host memory. if (ctx) { - if (flags == hipHostRegisterDefault || flags == hipHostRegisterPortable || - flags == hipHostRegisterMapped) { + if ((flags == hipHostRegisterDefault) || (flags & hipHostRegisterPortable) || + (flags & hipHostRegisterMapped) || (flags == hipExtHostRegisterCoarseGrained)) { auto device = ctx->getWriteableDevice(); std::vector vecAcc; for (int i = 0; i < g_deviceCnt; i++) { vecAcc.push_back(ihipGetDevice(i)->_acc); } +#if (__hcc_workweek__ >= 19183) + if(flags & hipExtHostRegisterCoarseGrained) { + am_status = hc::am_memory_host_lock(device->_acc, hostPtr, sizeBytes, &vecAcc[0], + vecAcc.size()); + } else { + am_status = hc::am_memory_host_lock_with_flag(device->_acc, hostPtr, sizeBytes, &vecAcc[0], + vecAcc.size()); + } +#else am_status = hc::am_memory_host_lock(device->_acc, hostPtr, sizeBytes, &vecAcc[0], vecAcc.size()); +#endif if ( am_status == AM_SUCCESS ) { am_status = hc::am_memtracker_getinfo(&amPointerInfo, hostPtr);