view src/parallel_execution/examples/twice/createArray.cbc @ 438:7679093bdd72

Work CUDAtwice
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Mon, 06 Nov 2017 00:11:43 +0900
parents 85b0ddbf458e
children 7d67c9cf09ee
line wrap: on
line source

#include <stdio.h>
#include "../../../context.h"

extern int length;
extern int split;

__code createArray(__code next(struct Array* output, struct Time* output1, ...), struct LoopCounter* loopCounter) {
    struct Array* output = *O_output;
    struct Time* output1 = *O_output1;
    int i = loopCounter->i;
    if (i == 0){
        output->array = (Int*)ALLOCATE_ARRAY(context, Int, length);
        output->prefix = length/split;
    }
    if (i == GET_LEN(output->array)){
        printf("created Array\n");
        loopCounter->i = 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[i] = i;
    loopCounter->i++;
    *O_output = output;
    *O_output1 = output1;
    goto meta(context, C_createArray);
}

__code createArray_stub(struct Context* context) {
    Array** O_output = (struct Array **)&context->data[context->odg];
    Time** O_output1 = (struct Time**)&context->data[context->odg+1];
    goto createArray(context,
            context->next,
            O_output,
            O_output1,
            Gearef(context, LoopCounter));
}