view src/parallel_execution/examples/twice/CUDAtwice.cbc @ 462:8d7e5d48cad3

Running CPU examples
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Wed, 20 Dec 2017 22:05:08 +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);
}