What is the difference between (void **)&x and (void *)x? I will give you some code, please help me out.
float *xd;
int size=width*width*size(float);
cudaMalloc((void **)&x,size); 1
cudaMalloc((void *)x,size); 2
cudaMalloc(&x,size); 3
cudaMalloc(*x,size); 4
cudaFree(xd);
I just want to know the difference.
The first parameter of the cudaMalloc() function is the address of a pointer variable that must point to the allocated object after allocation. The address of the pointer variable should be cast to (void **) because the function expects a generic pointer value; the memory allocation function is a generic function that is not restricted to any particular type of objects. This address allows the cudaMalloc() function to write the address of the allocated object into the pointer variable.3 The second parameter of the cudaMalloc() function gives the size of the object to be allocated, in terms of bytes. The usage of this second parameter is consistent with the size parameter of the C malloc() function.