Initializing array on device without passing it to the kernel

Hello everybody,

I’m new to CUDA but I have a problem and I didn’t find any solution.

I need to allocate and initialize 20 arrays on the device. I figured that I could allocate and initialize the arrays on the host and then copy them to the device, but it seems I will have to pass them to the kernel function.

Is there any way to initialize the arrays and make them available to the kernel without having to pass them? I need the arrays on the device only to do some calculations.

Sorry for my bad english, I hope you understand what I mean.

Edit: Forgot to add that I can’t simply define the arrays in a header file with a device prefix because those arrays are initialized at application startup in a loop.

Is it the pointers to the arrays that you don’t want to pass? If that is the case, then there is no way around it - the device doesn’t know where to find the memory otherwise.

If you are saying that you don’t want to have to allocated memory on the device but rather use the device to access arrays that are in the host memory, then this is not possible.

If you were asking something else, then please forgive me.

I think you can still use the device prefix. device constant var with an accompanying cudaMemcpyToSymbol or maybe even that done 20 times. I know there’s the 64K limit on constant memory, so I’m not sure if it’ll fit your application. I’m not sure what cuda does if its greater than 64K.

Hello again,

I think this will do it! Thanks very much for pointing that out, I’ll check it out.