Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. kernel void bubbleSort2(global int* A, global int* B, local int* scratch) {
  2. int id = get_global_id(0);
  3. int lid = get_local_id(0);
  4. int N = get_global_size(0);
  5. double temp;
  6.  
  7. scratch[lid] = A[id];
  8. barrier(CLK_LOCAL_MEM_FENCE);
  9.  
  10. for (int i = N-1; i > 0; i--)
  11. {
  12. for (int j = 0; j <= i-1; j++)
  13. {
  14. if (A[j] > A[j+1])
  15. {
  16. temp = A[j];
  17. A[j] = A[j+1];
  18. A[j+1] = temp;
  19. }
  20. barrier(CLK_LOCAL_MEM_FENCE);
  21. }
  22. }
  23. B[id] = A[id];
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement