Add option to alloc fingrained system memory

Change-Id: Ia13c8e058cb988b5857e75a590a4d67411362ae1


[ROCm/clr commit: 23de0e1b50]
Tento commit je obsažen v:
pensun
2016-11-08 01:01:26 -06:00
rodič 68b4d20b26
revize 61635b585f
+11
Zobrazit soubor
@@ -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);
}