Skip to content

Instantly share code, notes, and snippets.

@gidili
Created March 10, 2013 15:50
Show Gist options
  • Save gidili/5129090 to your computer and use it in GitHub Desktop.
Save gidili/5129090 to your computer and use it in GitHub Desktop.
Alternate sorting for PCI-SPH runSort step
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