Mercurial > hg > Gears > GearsAgda
view src/parallel_execution/examples/swap.cbc @ 380:783017f6dfbe
Running bitonicSort
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 23 Jul 2017 07:28:32 +0900 |
parents | 2744cb933ebc |
children |
line wrap: on
line source
#include "../../context.h" #include <stdio.h> __code bitonicSwap(struct SortArray* inputArray, struct Integer* block, struct Integer* first, struct Integer* i, __code next(struct SortArray* output, ...)) { struct SortArray* output = *O_output; int position = i->value/block->value; int index1 = i->value+block->value*position; int index2 = (first->value == 1)? ((block->value<<1)*(position+1))-(index1%block->value)-1 : index1+block->value; struct Integer** array = inputArray->array; if (array[index2]->value < array[index1]->value) { struct Integer *tmp = array[index1]; array[index1] = array[index2]; array[index2] = tmp; } output->array = array; *O_output = output; goto meta(context, next); } __code bitonicSwap_stub(struct Context* context) { SortArray** O_output = (struct SortArray **)&context->data[context->odg]; goto bitonicSwap(context, &context->data[context->idg]->SortArray, &context->data[context->idg+1]->Integer, &context->data[context->idg+2]->Integer, &context->data[context->idg+3]->Integer, context->next, O_output); }