Shared -> Global Memory

Hey all,
Is there a way to copy shared memory data to global memory? My problem has a 2D array which every block generates and needs to store this into one massive array stored in global memory which will be finally transferred to host. I can’t find the right functions for this, could someone help me out?

OR would you’ll suggest that I write everything directly to global memory everytime?

Cheers,
Vandhan!

you can write to global memory from shared no problem. It is just like normal assignments

Example

[codebox]

shared int array[50];

//out is a global memory pointer for e.g output to host

for(i=0; i < 50; i++)

{

out[i*threadIdx.x] = array[i];

}[/codebox]