view src/parallel_execution/examples/twice/CUDAtwice.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 0eba9a04633f
children
line wrap: on
line source

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


extern void CUDAExec(struct Context* context, Array* array);

__code CUDAtwice(struct Context* context, 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 CUDAtwice_stub(struct Context* context) {
printf("CUDAtwice stub\n");
    struct Array* array = &context->data[context->idg]->Array;
    CUDAExec(context,array);

    //continuationにそってGPUworkerに戻る
    goto meta(context, context->next);
}