CUDA memory management

Hi,

I’m working in a part of code that calls a function which loops several times a cuda wrapper function that includes multiple memory copies of constant data. So I was thinking about the possibility of use a method that only copies the data one time in the constant memory and then only use the reference to these data for next computes.

I was looking about cudaMemcpyToSymbol but I’m not sure if this will work.

There’s anyone that would know some about that?

Thanks.

Divide the wrapper in two parts, one which copy data and one which makes the rest of the work. Why are not sure if cudaMemcpyToSymbol would work? Just give it a try.

If you can split the wrapper function try giving the constant variables as parameters to the kernels you can give up to 256 bytes aruments:

kernel<<< >>>( , , N)

Thanks for the answer.

I made some test declaring the data (arrays of double datatype) as constant and transfered the data using cudaMemcpyToSymbol and all works fine, but I not totally convinced about that due the limitations of declare the array size in compile time.

There is another way in which I can alloc and fill a vector in runtime and then, in another execution get the reference of that block of memory?

Thanks in advance.

Constant memory allocation is always static (dynamic allocation would be of limited use due to its 64k size limit). You can also use a texture (which can be dynamically allocated), or just place the constants in global memory on compute capability 2.x devices.