Assign a scalar variable to multiple GPU

Hello,

I am wondering if i can assign a global scalar variable to different GPU’s (with differents values on each):

__constant__ int a_dev;

int main()
{
 for (int i_GPU = 0; i_GPU < GPUNumber; i_GPU++)
 {
   cudaSetDevice(i_GPU);
   int a_host = i_GPU;
   cudaMemcpyToSymbolAsync(a_dev, &a_host, sizeof(int), 0, cudaMemcpyHostToDevice);
 }
}

Will it work as wanted?

Thanks

Never mind. I just found a constructive response from Robert through StackOverflow (https://www.google.com/url?sa=t&source=web&rct=j&url=https://stackoverflow.com/questions/19973446/allocating-global-variables-on-multiple-gpus&ved=2ahUKEwj51oLc0fXnAhWS_aQKHfn5Dh0QjjgwAHoECAcQAQ&usg=AOvVaw2BxUZpcS63ptAzPvU7Ikqp)