```
for(n=2; n<1024; n=n*2){
if(threadIdx.x<(1024/n)){
if(n==2){
if(shared[threadIdx.x*2]>shared[threadIdx.x*2+1]){
printf(" n=%i tr=%i shared[%i]=%i|shared[%i]=%i \n",n, threadIdx.x, threadIdx.x*2,shared[threadIdx.x*2],threadIdx.x*2+1,shared[threadIdx.x*2+1]);
swap(shared[threadIdx.x+n/2-1],shared[threadIdx.x+n-1]);
}
}
else{
if(shared[threadIdx.x+n/2-1]>shared[threadIdx.x+n-1]){
printf(" n=%i tr=%i shared[%i]=%i|shared[%i]=%i \n",n, threadIdx.x, threadIdx.x+n/2-1,shared[threadIdx.x+n/2-1],threadIdx.x+n-1,shared[threadIdx.x+n-1]);
swap(shared[threadIdx.x+n/2-1],shared[threadIdx.x+n-1]);
}
}}
__syncthreads();
```

start in a mode of emulation

and have: