Hi, searching around the forum gave parts of answers to this but I wanted to be clear in my own mind. Say I have arrays on the host that I wish to copy to device variables declared and use them in device code e.g.
float _array1[100];
float _array2[100];
__device__ float array1[100];
__device__ float array2[100];
__device__ void update() {
array1[0]++;
}
How do I allocate memory on the device for the named arrays?
I gather I need to allocate memory to a host pointer using cudaMalloc. What I’m not sure about is then using this pointer and copying the host arrays to the device array symbols.
Edit: I’m doing this to avoid having to pass pointers to the device arrays around the various functions)