questions Device Pointer using driver API

I have a question about how to make an array of pointers using CUDevicePtr

and then how to access the value the pointers point to.

Unfortunately, the CUDevicePtr is unsigned int.
and only the API functions treat it as pointers internally. Also, you cant use * or & on them.

I cant use runtime API since i need to use some c++ features.

Thanks in advance.

I think you would create an array of CUDevicePtr’s

CUDevicePtr *x; // x is a host ptr, 32-bits or 64-bits depending on host arch

x=malloc(N*sizeof(CUDevicePtr *)); // creates an array of device pointers, length N

Now, each of those pointers x[0]…x[N] be set to a device address where the cuda arrays are allocated.

You can use the runtime API. You add function headers with

extern “C”

in order to link in C functions that you want to use in C++

Chuck

I don’t think this is possible. You’ll have to make a single large allocation, and use an indexing function to access it. Are you trying to make a 2d array or something? If so, allocate a single array that is NM in size, and then index into it using a function like idx(i,j) = j + iM.

Can you elaborate? The runtime api is more C++'y than device API.