view src/parallel_execution/examples/twice/twice.cbc @ 431:b3359544adbb

Edit cudaExec but not work
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Tue, 17 Oct 2017 01:50:12 +0900
parents 49159fbdd1fb
children 7679093bdd72
line wrap: on
line source

#include <stdio.h>

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

#ifdef USE_CUDAWorker
extern void cudaExec(struct Context* context, Array* array);
#endif

__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) {
#ifdef USE_CUDAWorker
    struct Array* array = &context->data[context->idg]->Array;
    if (context->gpu) {
        cudaExec(context, array);
        //continuationにそってGPUworkerに戻る
        goto meta(context, context->next);
    }
#endif
    goto twice(context,
               &context->data[context->idg]->Array,
               &context->data[context->idg+1]->MultiDim,
               context->next,
               Gearef(context, LoopCounter));
}