Arithmetic on device memory pointer possible ?

I wonder if I can address memory subregions by adding offsets on the host to CUdevptr values ? I.e. can I do like this:

CUdeviceptr mem = cuMalloc(16);

cuMemcpyHtoD(mem + 0, &x, 8);
cuMemcpyHtoD(mem + 8, &x, 8);

Can I also pass pointers offseted like that into kernels ?



A) Looks like it will work, though I don’t know
B ) Looks like the exact same thing I’ve been doing, and it works


I also assumed it’d work, but in my test application I create an MxN matrix on device, and try to initialize it by copying M times into matrix rows of width N. Somewhere on the row in middle of the matrix copying fails with “invalid parameter” error. So now I need a confirmation on if it is ok to do so or not.

yes, it is officially supported.