view src/parallel_execution/examples/twice/twice.cbc @ 408:8ee89eefbc6d

Fix twice
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Wed, 06 Sep 2017 21:54:22 +0900
parents 9b35e6581b5c
children 497b154141de
line wrap: on
line source

#include <stdio.h>

#include "../../../context.h"

__code twice(struct Array* array, struct MultiDim* multiDim, __code next(...), struct LoopCounter* loopCounter) {
    int i = loopCounter->i;
    int index = multiDim->x;
    if (i < array->prefix) {
        array->array[i+index*array->prefix] = array->array[i+index*array->prefix]*2;
        loopCounter->i++;

        goto meta(context, C_twice);
    }

    loopCounter->i = 0;
    goto meta(context, context->next);
}

__code twice_stub(struct Context* context) {
    goto twice(context,
               &context->data[context->idg]->Array,
               &context->data[context->idg+1]->MultiDim,
               context->next,
               Gearef(context, LoopCounter));
}