view src/parallel_execution/examples/bitonicSort/makeArray.cbc @ 404:c5cd9888bf2a

Fix bitonicSort
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Sun, 03 Sep 2017 00:21:16 +0900
parents
children 35b37fe8d3a7
line wrap: on
line source

#include "../../../context.h"
#include <stdio.h>
extern int length;
__code makeArray(__code next(struct SortArray* output, struct Time* output1, ...)){
    struct SortArray* output = *O_output;
    struct Time* output1 = *O_output1;
    if (output->loopCounter == 0){
        output->array = (Integer*)ALLOCATE_ARRAY(context, Integer, length);
        srand((unsigned) time(NULL));
    }
    if (output->loopCounter == GET_SIZE(output->array)){
        printf("created Array\n");
        output->loopCounter = 0;
        Gearef(context, Time)->time = (union Data*)output1;
        Gearef(context, Time)->next = context->next;
        *O_output = output;
        *O_output1 = output1;
        goto meta(context, output1->start);
    }
    output->array[output->loopCounter].value = rand() % 1000;
    //printf("%d\n", output->array[output->loopCounter]->value);
    output->loopCounter++;
    *O_output = output;
    *O_output1 = output1;
    goto meta(context, C_makeArray);
}

__code makeArray_stub(struct Context* context) {
    SortArray** O_output = (struct SortArray**)&context->data[context->odg];
    Time** O_output1 = (struct Time**)&context->data[context->odg+1];
    goto makeArray(context,
                   context->next,
                   O_output,
                   O_output1);
}