Deprecating hipMallocHost to hipHostAlloc
[ROCm/hip commit: cbdc8c277c]
This commit is contained in:
@@ -36,7 +36,7 @@ void printSep()
|
||||
// The subroutine allocates memory , copies to device, runs a vector add kernel, copies back, and checks the result.
|
||||
//
|
||||
// IN: numElements controls the number of elements used for allocations.
|
||||
// IN: usePinnedHost : If true, allocate host with hipMallocHost and is pinned ; else allocate host memory with malloc.
|
||||
// IN: usePinnedHost : If true, allocate host with hipHostAlloc and is pinned ; else allocate host memory with malloc.
|
||||
// IN: useHostToHost : If true, add an extra host-to-host copy.
|
||||
// IN: useDeviceToDevice : If true, add an extra deviceto-device copy after result is produced.
|
||||
// IN: useMemkindDefault : If true, use memkinddefault (runtime figures out direction). if false, use explicit memcpy direction.
|
||||
@@ -67,8 +67,8 @@ void memcpytest2(size_t numElements, bool usePinnedHost, bool useHostToHost, boo
|
||||
|
||||
if (useHostToHost) {
|
||||
if (usePinnedHost) {
|
||||
HIPCHECK ( hipMallocHost(&A_hh, sizeElements) );
|
||||
HIPCHECK ( hipMallocHost(&B_hh, sizeElements) );
|
||||
HIPCHECK ( hipHostAlloc((void**)&A_hh, sizeElements, hipHostAllocDefault) );
|
||||
HIPCHECK ( hipHostAlloc((void**)&B_hh, sizeElements, hipHostAllocDefault) );
|
||||
} else {
|
||||
A_hh = (T*)malloc(sizeElements);
|
||||
B_hh = (T*)malloc(sizeElements);
|
||||
|
||||
@@ -33,7 +33,7 @@ void simpleNegTest()
|
||||
|
||||
size_t Nbytes = N*sizeof(float);
|
||||
A_malloc = (float*)malloc(Nbytes);
|
||||
HIPCHECK(hipMallocHost(&A_pinned, Nbytes));
|
||||
HIPCHECK(hipHostAlloc((void**)&A_pinned, Nbytes, hipHostAllocDefault));
|
||||
HIPCHECK(hipMalloc(&A_d, Nbytes));
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ struct HostTraits<Pinned>
|
||||
|
||||
static void *Alloc(size_t sizeBytes) {
|
||||
void *p;
|
||||
HIPCHECK(hipMallocHost(&p, sizeBytes));
|
||||
HIPCHECK(hipHostAlloc((void**)&p, sizeBytes, hipHostAllocDefault));
|
||||
return p;
|
||||
};
|
||||
};
|
||||
@@ -181,8 +181,8 @@ void test_manyInflightCopies(hipStream_t stream, int numElements, int numCopies,
|
||||
T *A_d;
|
||||
T *A_h1, *A_h2;
|
||||
|
||||
HIPCHECK(hipMallocHost(&A_h1, Nbytes));
|
||||
HIPCHECK(hipMallocHost(&A_h2, Nbytes));
|
||||
HIPCHECK(hipHostAlloc((void**)&A_h1, Nbytes, hipHostAllocDefault));
|
||||
HIPCHECK(hipHostAlloc((void**)&A_h2, Nbytes, hipHostAllocDefault));
|
||||
HIPCHECK(hipMalloc(&A_d, Nbytes));
|
||||
|
||||
for (int i=0; i<numElements; i++) {
|
||||
|
||||
@@ -67,8 +67,8 @@ void simpleTest2(size_t numElements, bool usePinnedHost)
|
||||
T *A_d, *A_h1, *A_h2;
|
||||
|
||||
if (usePinnedHost) {
|
||||
HIPCHECK ( hipMallocHost(&A_h1, sizeElements) );
|
||||
HIPCHECK ( hipMallocHost(&A_h2, sizeElements) );
|
||||
HIPCHECK ( hipHostAlloc((void**)&A_h1, sizeElements, hipHostAllocDefault) );
|
||||
HIPCHECK ( hipHostAlloc((void**)&A_h2, sizeElements, hipHostAllocDefault) );
|
||||
} else {
|
||||
A_h1 = (T*)malloc(sizeElements);
|
||||
A_h2 = (T*)malloc(sizeElements);
|
||||
|
||||
@@ -34,21 +34,21 @@ Array[tx] = Array[tx] + T(1);
|
||||
void run1(size_t size, hipStream_t stream){
|
||||
float *Ah, *Bh, *Cd, *Dd, *Eh;
|
||||
|
||||
hipMallocHost(&Ah, size);
|
||||
hipMallocHost(&Bh, size);
|
||||
hipMalloc(&Cd, size);
|
||||
hipMalloc(&Dd, size);
|
||||
hipMallocHost(&Eh, size);
|
||||
HIPCHECK(hipHostAlloc((void**)&Ah, size, hipHostAllocDefault));
|
||||
HIPCHECK(hipHostAlloc((void**)&Bh, size, hipHostAllocDefault));
|
||||
HIPCHECK(hipMalloc(&Cd, size));
|
||||
HIPCHECK(hipMalloc(&Dd, size));
|
||||
HIPCHECK(hipHostAlloc((void**)&Eh, size, hipHostAllocDefault));
|
||||
|
||||
for(int i=0;i<N;i++){
|
||||
Ah[i] = 1.0f;
|
||||
}
|
||||
|
||||
hipMemcpyAsync(Bh, Ah, size, hipMemcpyHostToHost, stream);
|
||||
hipMemcpyAsync(Cd, Bh, size, hipMemcpyHostToDevice, stream);
|
||||
HIPCHECK(hipMemcpyAsync(Bh, Ah, size, hipMemcpyHostToHost, stream));
|
||||
HIPCHECK(hipMemcpyAsync(Cd, Bh, size, hipMemcpyHostToDevice, stream));
|
||||
hipLaunchKernel(HIP_KERNEL_NAME(Inc), dim3(N/500), dim3(500), 0, stream, Cd);
|
||||
hipMemcpyAsync(Dd, Cd, size, hipMemcpyDeviceToDevice, stream);
|
||||
hipMemcpyAsync(Eh, Dd, size, hipMemcpyDeviceToHost, stream);
|
||||
HIPCHECK(hipMemcpyAsync(Dd, Cd, size, hipMemcpyDeviceToDevice, stream));
|
||||
HIPCHECK(hipMemcpyAsync(Eh, Dd, size, hipMemcpyDeviceToHost, stream));
|
||||
HIPCHECK(hipDeviceSynchronize());
|
||||
HIPASSERT(Eh[10] == Ah[10] + 1.0f);
|
||||
}
|
||||
@@ -58,27 +58,27 @@ void run(size_t size, hipStream_t stream1, hipStream_t stream2){
|
||||
float *Ah, *Bh, *Cd, *Dd, *Eh;
|
||||
float *Ahh, *Bhh, *Cdd, *Ddd, *Ehh;
|
||||
|
||||
hipMallocHost(&Ah, size);
|
||||
hipMallocHost(&Bh, size);
|
||||
hipMalloc(&Cd, size);
|
||||
hipMalloc(&Dd, size);
|
||||
hipMallocHost(&Eh, size);
|
||||
hipMallocHost(&Ahh, size);
|
||||
hipMallocHost(&Bhh, size);
|
||||
hipMalloc(&Cdd, size);
|
||||
hipMalloc(&Ddd, size);
|
||||
hipMallocHost(&Ehh, size);
|
||||
HIPCHECK(hipHostAlloc((void**)&Ah, size, hipHostAllocDefault));
|
||||
HIPCHECK(hipHostAlloc((void**)&Bh, size, hipHostAllocDefault));
|
||||
HIPCHECK(hipMalloc(&Cd, size));
|
||||
HIPCHECK(hipMalloc(&Dd, size));
|
||||
HIPCHECK(hipHostAlloc((void**)&Eh, size, hipHostAllocDefault));
|
||||
HIPCHECK(hipHostAlloc((void**)&Ahh, size, hipHostAllocDefault));
|
||||
HIPCHECK(hipHostAlloc((void**)&Bhh, size, hipHostAllocDefault));
|
||||
HIPCHECK(hipMalloc(&Cdd, size));
|
||||
HIPCHECK(hipMalloc(&Ddd, size));
|
||||
HIPCHECK(hipHostAlloc((void**)&Ehh, size, hipHostAllocDefault));
|
||||
|
||||
hipMemcpyAsync(Bh, Ah, size, hipMemcpyHostToHost, stream1);
|
||||
hipMemcpyAsync(Bhh, Ahh, size, hipMemcpyHostToHost, stream2);
|
||||
hipMemcpyAsync(Cd, Bh, size, hipMemcpyHostToDevice, stream1);
|
||||
hipMemcpyAsync(Cdd, Bhh, size, hipMemcpyHostToDevice, stream2);
|
||||
HIPCHECK(hipMemcpyAsync(Bh, Ah, size, hipMemcpyHostToHost, stream1));
|
||||
HIPCHECK(hipMemcpyAsync(Bhh, Ahh, size, hipMemcpyHostToHost, stream2));
|
||||
HIPCHECK(hipMemcpyAsync(Cd, Bh, size, hipMemcpyHostToDevice, stream1));
|
||||
HIPCHECK(hipMemcpyAsync(Cdd, Bhh, size, hipMemcpyHostToDevice, stream2));
|
||||
hipLaunchKernel(HIP_KERNEL_NAME(Inc), dim3(N/500), dim3(500), 0, stream1, Cd);
|
||||
hipLaunchKernel(HIP_KERNEL_NAME(Inc), dim3(N/500), dim3(500), 0, stream2, Cdd);
|
||||
hipMemcpyAsync(Dd, Cd, size, hipMemcpyDeviceToDevice, stream1);
|
||||
hipMemcpyAsync(Ddd, Cdd, size, hipMemcpyDeviceToDevice, stream2);
|
||||
hipMemcpyAsync(Eh, Dd, size, hipMemcpyDeviceToHost, stream1);
|
||||
hipMemcpyAsync(Ehh, Ddd, size, hipMemcpyDeviceToHost, stream2);
|
||||
HIPCHECK(hipMemcpyAsync(Dd, Cd, size, hipMemcpyDeviceToDevice, stream1));
|
||||
HIPCHECK(hipMemcpyAsync(Ddd, Cdd, size, hipMemcpyDeviceToDevice, stream2));
|
||||
HIPCHECK(hipMemcpyAsync(Eh, Dd, size, hipMemcpyDeviceToHost, stream1));
|
||||
HIPCHECK(hipMemcpyAsync(Ehh, Ddd, size, hipMemcpyDeviceToHost, stream2));
|
||||
HIPCHECK(hipDeviceSynchronize());
|
||||
HIPASSERT(Eh[10] = Ah[10] + 1.0f);
|
||||
HIPASSERT(Ehh[10] = Ahh[10] + 1.0f);
|
||||
|
||||
@@ -115,7 +115,7 @@ void testSimple()
|
||||
hipError_t e;
|
||||
|
||||
HIPCHECK ( hipMalloc(&A_d, Nbytes) );
|
||||
HIPCHECK ( hipMallocHost(&A_Pinned_h, Nbytes) );
|
||||
HIPCHECK ( hipHostAlloc((void**)&A_Pinned_h, Nbytes, hipHostAllocDefault) );
|
||||
A_OSAlloc_h = (char*)malloc(Nbytes);
|
||||
|
||||
size_t free, total;
|
||||
@@ -168,7 +168,7 @@ void testSimple()
|
||||
|
||||
|
||||
// Device-visible host memory
|
||||
printf ("\nDevice-visible host memory (hipMallocHost)\n");
|
||||
printf ("\nDevice-visible host memory (hipHostAlloc)\n");
|
||||
HIPCHECK( hipPointerGetAttributes(&attribs, A_Pinned_h));
|
||||
printf("getAttr:%-20s", "A_pinned_h"); printAttribs(&attribs);
|
||||
|
||||
@@ -277,13 +277,13 @@ void clusterAllocs(int numAllocs, size_t minSize, size_t maxSize)
|
||||
void * ptr;
|
||||
if (isDevice) {
|
||||
totalDeviceAllocated[reference[i]._attrib.device] += reference[i]._sizeBytes;
|
||||
HIPCHECK(hipMalloc(&ptr, reference[i]._sizeBytes));
|
||||
HIPCHECK(hipHostAlloc((void**)&ptr, reference[i]._sizeBytes, hipHostAllocDefault));
|
||||
reference[i]._attrib.memoryType = hipMemoryTypeDevice;
|
||||
reference[i]._attrib.devicePointer = ptr;
|
||||
reference[i]._attrib.hostPointer = NULL;
|
||||
reference[i]._attrib.allocationFlags = 0; // TODO-randomize these.
|
||||
} else {
|
||||
HIPCHECK(hipMallocHost(&ptr, reference[i]._sizeBytes));
|
||||
HIPCHECK(hipHostAlloc((void**)&ptr, reference[i]._sizeBytes, hipHostAllocDefault));
|
||||
reference[i]._attrib.memoryType = hipMemoryTypeHost;
|
||||
reference[i]._attrib.devicePointer = ptr;
|
||||
reference[i]._attrib.hostPointer = ptr;
|
||||
|
||||
@@ -85,7 +85,7 @@ void initArrays(T **Ad, T **Ah,
|
||||
HIPCHECK( hipMalloc(Ad, NBytes));
|
||||
}
|
||||
if(usePinnedHost){
|
||||
HIPCHECK( hipMallocHost(Ah, NBytes));
|
||||
HIPCHECK( hipHostAlloc((void**)Ah, NBytes, hipHostAllocDefault));
|
||||
}
|
||||
else{
|
||||
*Ah = new T[N];
|
||||
@@ -102,7 +102,7 @@ void initArrays(T **Ad, size_t N,
|
||||
HIPCHECK( hipMalloc(Ad, NBytes));
|
||||
}else{
|
||||
if(usePinnedHost){
|
||||
HIPCHECK(hipMallocHost(Ad, NBytes));
|
||||
HIPCHECK(hipHostAlloc((void**)Ad, NBytes, hipHostAllocDefault));
|
||||
}else{
|
||||
*Ad = new T[N];
|
||||
HIPASSERT(*Ad != NULL);
|
||||
|
||||
@@ -141,13 +141,13 @@ void initArrays(T **A_d, T **B_d, T **C_d,
|
||||
|
||||
if (usePinnedHost) {
|
||||
if (A_h) {
|
||||
HIPCHECK ( hipMallocHost(A_h, Nbytes) );
|
||||
HIPCHECK ( hipHostAlloc((void**)A_h, Nbytes, hipHostAllocDefault) );
|
||||
}
|
||||
if (B_h) {
|
||||
HIPCHECK ( hipMallocHost(B_h, Nbytes) );
|
||||
HIPCHECK ( hipHostAlloc((void**)B_h, Nbytes, hipHostAllocDefault) );
|
||||
}
|
||||
if (C_h) {
|
||||
HIPCHECK ( hipMallocHost(C_h, Nbytes) );
|
||||
HIPCHECK ( hipHostAlloc((void**)C_h, Nbytes, hipHostAllocDefault) );
|
||||
}
|
||||
} else {
|
||||
if (A_h) {
|
||||
@@ -258,7 +258,7 @@ struct Pinned {
|
||||
static void *Alloc(size_t sizeBytes)
|
||||
{
|
||||
void *p;
|
||||
HIPCHECK(hipMallocHost(&p, sizeBytes));
|
||||
HIPCHECK(hipHostAlloc((void**)&p, sizeBytes, hipHostAllocDefault));
|
||||
return p;
|
||||
};
|
||||
};
|
||||
|
||||
Fai riferimento in un nuovo problema
Block a user