hipHostRegister and hipHostMalloc refactor.

Note hipHostMalloc (not hipHostAlloc or hipMallocHost).
 -  the hipHost* is used for all HIP APIs dealing with Host memory.
    (including hipHostMalloc, hipHostFree, hipHostRegister,
hipHostUnregister, hipHostGetFlags, hipHostGetDevicePointer).
  - hipMallocHost is consistent with "hipMalloc" for allocating device
    memory.  Enumerations hipHostMalloc* also used as optional
    flags parm to hipHostMalloc.
This commit is contained in:
Ben Sander
2016-03-22 02:30:10 -05:00
parent 8087bc0401
commit ab910efb96
17 changed files with 95 additions and 70 deletions
+11 -3
View File
@@ -2085,7 +2085,7 @@ hipError_t hipMallocHost(void** ptr, size_t sizeBytes)
}
hipError_t hipHostAlloc(void** ptr, size_t sizeBytes, unsigned int flags){
hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags){
std::call_once(hip_initialized, ihipInit);
hipError_t hip_status = hipSuccess;
@@ -2093,7 +2093,7 @@ hipError_t hipHostAlloc(void** ptr, size_t sizeBytes, unsigned int flags){
auto device = ihipGetTlsDefaultDevice();
if(device){
if(flags == hipHostAllocDefault){
if(flags == hipHostMallocDefault){
*ptr = hc::am_alloc(sizeBytes, device->_acc, amHostPinned);
if(sizeBytes && (*ptr == NULL)){
hip_status = hipErrorMemoryAllocation;
@@ -2101,7 +2101,7 @@ hipError_t hipHostAlloc(void** ptr, size_t sizeBytes, unsigned int flags){
hc::am_memtracker_update(*ptr, device->_device_index, 0);
}
tprintf(DB_MEM, " %s: pinned ptr=%p\n", __func__, *ptr);
} else if(flags & hipHostAllocMapped){
} else if(flags & hipHostMallocMapped){
*ptr = hc::am_alloc(sizeBytes, device->_acc, amHostPinned);
if(sizeBytes && (*ptr == NULL)){
hip_status = hipErrorMemoryAllocation;
@@ -2115,6 +2115,14 @@ hipError_t hipHostAlloc(void** ptr, size_t sizeBytes, unsigned int flags){
}
// TODO - remove me, this is deprecated.
hipError_t hipHostAlloc(void** ptr, size_t sizeBytes, unsigned int flags)
{
return hipHostMalloc(ptr, sizeBytes, flags);
};
hipError_t hipHostGetDevicePointer(void** devPtr, void* hstPtr, size_t size){
std::call_once(hip_initialized, ihipInit);