the usage of unified memory assumes that I don’t need to copy data (cuMemCpu) between host and device.
Typical usage of array allocating is
double CPUarray=new double; CUdeviceptr ptr=new CUdeviceptr(); cuMemAlloc(ptr, CPUarray.length*Sizeof.DOUBLE); cuMemcpyHtoD(ptr, Pointer.to(CPUarray), CPUarray.length*Sizeof.DOUBLE);
Unified Memory (minimum requirements is compute capability 3.0) usage is
double CPUarray=new double; CUdeviceptr ptr=new CUdeviceptr(); cuMemAllocManaged(ptr, CPUarray.length*Sizeof.DOUBLE, 0);
So the problem is the ‘cuMemAllocManaged’ require the ‘CUdeviceptr ptr’ and I can’t make relation between ‘CUdeviceptr ptr’ and ‘double CPUarray’. This relation I can make in ‘cuMemcpyHtoD’ but the sense of Unified Memory is the absence of ‘cuMemcpyHtoD’.
Another way is the usage ‘Pointer.to(CPUarray)’ but ‘cuMemAllocManaged’ pointer should be of ‘CUdeviceptr’ type.