Sorting pairs of numbers using AMP

I need numbers next to each other to be sorted (in increasing order).
On the CPU I'd do something like this:
1
2
3
4
5
for(int i=0; i < length; i+=2) {
    if(a[i]>a[i+1]) {
        switch places...
    }
}

But how would I do this using parallel_for_each (C++AMP) ?

I need this for some algorithm that works with very long arrays and I think GPU would do this faster than CPU (even if I use all threads).
Try websearch with "GPGPU sort".
My question is: is there a way to execute the kernel for every Second element of an array?
Of course. Lets say that you have N threads. Each has index from [0..N[

You have array with at least 2*N elements.

Let kernel compute: int arrayIndex = 2*threadIndex;
Topic archived. No new replies allowed.