shared memory issue in sorting array

Hi

I am trying to sort the array elements:
therefore to start with i have only sorted only every two elements but the codes doesn’t works:

I am attaching the code for your reference.

According to me i think there is some problem in using two shared array,one array seams to take the value of other array.

Please help me to sort the issue.

For testing purpose i am launching only 1 block & 512 threads per block.

Thanks in advance…
ArrangeArray.cu (1.49 KB)

Yup this is because you use extern shared mem. For this you allocate one big clump of mem for all your smem stuff and then need to use offsets in your kernel to access anything behind the first array.
sdata2 = &sdata1[N];
Have a look at B.2.3 on page 103 in the Programming Guide 3.1, they explain the use of shared and extern shared memory there.