view src/parallel_execution/twice.cbc @ 282:a3448b0f0a56

Add input data gear
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Sun, 05 Feb 2017 04:08:30 +0900
parents 23767f714f4a
children f1b0cc555b6e
line wrap: on
line source

#include <stdio.h>

#include "../context.h"

__code twice(struct LoopCounter* loopCounter, int index, int prefix, int* array, struct Context* workerContext) {
    int i = loopCounter->i;
    if (i < prefix) {
        array[i+index*prefix] = array[i+index*prefix]*2;
        loopCounter->i++;

        goto meta(context, C_twice);
    }

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

__code twice_stub(struct Context* context) {
    struct Context* workerContext = context->worker->worker->CPUWorker.context;
    struct LoopCounter* loopCounter = &context->data[context->dataNum]->LoopCounter;
    struct Array* array = &context->data[context->dataNum+1]->Array;
    goto twice(context,
               loopCounter,
               array->index,
               array->prefix,
               array->array,
               workerContext);
}