Add option to alloc fingrained system memory
Change-Id: Ia13c8e058cb988b5857e75a590a4d67411362ae1
[ROCm/clr commit: 23de0e1b50]
Tento commit je obsažen v:
@@ -154,6 +154,16 @@ hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags)
|
||||
if(ctx){
|
||||
// am_alloc requires writeable __acc, perhaps could be refactored?
|
||||
auto device = ctx->getWriteableDevice();
|
||||
// If HIP_COHERENT_HOST_ALLOC is defined, we always alloc coherent host system memroy
|
||||
#ifdef HIP_COHERENT_HOST_ALLOC
|
||||
*ptr = hc::am_alloc(sizeBytes, device->_acc, amHostPinned);
|
||||
if(sizeBytes < 1 && (*ptr == NULL)){
|
||||
hip_status = hipErrorMemoryAllocation;
|
||||
} else {
|
||||
hc::am_memtracker_update(*ptr, device->_deviceId, amHostCoherent);
|
||||
}
|
||||
tprintf(DB_MEM, " %s: pinned ptr=%p\n", __func__, *ptr);
|
||||
#else
|
||||
if((flags == hipHostMallocDefault)|| (flags == hipHostMallocPortable)){
|
||||
*ptr = hc::am_alloc(sizeBytes, device->_acc, amHostPinned);
|
||||
if (sizeBytes < 1 && (*ptr == NULL)) {
|
||||
@@ -179,6 +189,7 @@ hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags)
|
||||
tprintf(DB_MEM, "allocated pinned host ptr=%p on dev=%d, allow access to %d peer(s)\n", *ptr, device->_deviceId, peerCnt);
|
||||
}
|
||||
}
|
||||
#endif //HIP_COHERENT_HOST_ALLOC
|
||||
}
|
||||
return ihipLogStatus(hip_status);
|
||||
}
|
||||
|
||||
Odkázat v novém úkolu
Zablokovat Uživatele