Mercurial > hg > GearsTemplate
view src/examples/bitonicSort/CUDAbitonicSwap.cu @ 590:9146d6017f18 default tip
hg mv parallel_execution/* ..
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 16 Jan 2020 15:12:06 +0900 |
parents | src/parallel_execution/examples/bitonicSort/CUDAbitonicSwap.cu@6bb391fc9e12 |
children |
line wrap: on
line source
extern "C" { struct Integer { int value; }; struct SortArray { struct Integer *array; int loopCounter; int block; int first; int prefix; }; __global__ void bitonicSwap(struct Integer* array, struct SortArray* sortArray) { int block = sortArray->block; int first = sortArray->first; int prefix = sortArray->prefix; int i = 0; C_bitonicSwap: if (i < prefix) { int index = i + (blockIdx.x * blockDim.x + threadIdx.x) * prefix; int position = index/block; int index1 = index+block*position; int index2 = (first == 1)? ((block<<1)*(position+1))-(index1%block)-1 : index1+block; if (array[index2].value < array[index1].value) { struct Integer tmp = array[index1]; array[index1] = array[index2]; array[index2] = tmp; } i++; goto C_bitonicSwap; } } }