I changed my method to allocate host memory from method 1 to method 2 as shown in my code below. The code can compile and run without any error. I just wonder is it a proper way or any side effect to allocate memory for pointer to pointer using method 2.
#define TESTSIZE 10
#define DIGITSIZE 5
//Method 1
int **ra;
ra = (int**)malloc(TESTSIZE * sizeof(int));
for(int i = 0; i < TESTSIZE; i++){
ra[i] = (int *)malloc(DIGITSIZE * sizeof(int));
}
//Method 2
int **ra;
cudaMallocHost((void**)&ra, TESTSIZE * sizeof(int));
for(int i = 0; i < TESTSIZE; i++){
cudaMallocHost((void**)&ra[i], DIGITSIZE * sizeof(int));
}