Mercurial > hg > Game > Cerium
diff example/bitonic_sort/ppe/swap.cc @ 2038:a78f8360c7f9 draft
modify bitonic sort. use sorting network
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 07 Feb 2015 02:34:46 +0900 |
parents | 0b3d1d2863c8 |
children | bc010492ade4 |
line wrap: on
line diff
--- a/example/bitonic_sort/ppe/swap.cc Fri Feb 06 06:21:57 2015 +0900 +++ b/example/bitonic_sort/ppe/swap.cc Sat Feb 07 02:34:46 2015 +0900 @@ -7,22 +7,19 @@ { int* inData = (int*)s->get_input(rbuf, 0); int* outData = (int*)s->get_output(wbuf, 0); - long i = (long)s->get_param(0); - long j = (long)s->get_param(1); - int k = s->x; - - int point = j^k; - int temp = inData[k]; + long block = (long)s->get_param(0); + bool first = (bool)s->get_param(1); + int x = s->x; + + int position = x/block; + int index = x+block*position; - if (k < point) { - if ((i&k)==0 && inData[point] < inData[k]) { - outData[k] = inData[point]; - outData[point] = temp; - } - if ((i&k)!=0 && inData[k] < inData[point]) { - outData[k] = inData[point]; - outData[point] = temp; - } + block = first ? ((block<<1)*(position+1))-(index%block)-1 : index+block; + + if (inData[block] < inData[index]) { + int tmp = inData[index]; + outData[index] = inData[block]; + outData[block] = tmp; } return 0;