view src/parallel_execution/examples/twice/CUDAtwice.cbc @ 409:4d1e3697a6b8

Add twice cbc file
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Wed, 06 Sep 2017 22:01:27 +0900
parents b81492c74d2b
children 85b0ddbf458e
line wrap: on
line source

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


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

__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 LoopCounter* loopCounter = &context->data[context->dataNum]->LoopCounter;
    struct Array* array = &context->data[context->dataNum+1]->Array;
    CUDAExec(context,array,loopCounter);

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