view src/parallel_execution/examples/swap.cbc @ 379:2744cb933ebc

Fix compile error for bitonicSort but not work
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Sun, 23 Jul 2017 07:01:14 +0900
parents b4677965afa7
children 783017f6dfbe
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 index = i->value+block->value*position;
    block->value = (first->value == 1)? ((block->value<<1)*(position+1))-(index%block->value)-1 : index+block->value;
    struct Integer** array = inputArray->array;
    printf("block:%d\n", block->value);
    printf("index:%d\n", index);
    if (array[block->value] < array[index]) {
        struct Integer *tmp = array[index];
        array[index] = array[block->value];
        array[block->value] = 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);
}