Created
March 10, 2013 15:50
-
-
Save gidili/5129090 to your computer and use it in GitHub Desktop.
Alternate sorting for PCI-SPH runSort step
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int runSort(){ | |
// get values out of buffer | |
Pointer<Integer> particleInd = _particleIndex.read(_queue); | |
_queue.finish(); | |
int[] particleIndex = new int[_particleCount * 2]; | |
// copy to array of primitives | |
for(int i = 0;i< _particleCount*2;i++){ | |
particleIndex[i] = particleInd.get(i); | |
} | |
// quicksort | |
Arrays.sort(particleIndex); | |
// copy back to OpenCL type | |
for(int i = 0;i< _particleCount*2;i++){ | |
System.out.println(particleIndex[i]); | |
particleInd.set(i, particleIndex[i]); | |
} | |
// put results back | |
_particleIndex.write(_queue, particleInd, true); | |
_queue.finish(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment