Mercurial > hg > Members > Moririn
view src/parallel_execution/examples/twice/twice.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 | b3359544adbb |
children | 5a737c3df91c |
line wrap: on
line source
#include <stdio.h> #include "../../../context.h" #ifdef USE_CUDAWorker extern void cudaLoadFunction(struct Context* context, char* filename, char* function); #endif __code twice(struct Array* array, struct MultiDim* multiDim, __code next(struct Array* output, ...), struct LoopCounter* loopCounter) { struct Array* output = *O_output; 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; output->array = array->array; goto meta(context, context->next); } __code twice_stub(struct Context* context) { #ifdef USE_CUDAWorker if (context->gpu) { Array* inputArray = &context->data[context->idg]->Array; Array* outputArray = &context->data[context->odg]->Array; CUDABuffer* buffer = &ALLOCATE(context, CUDABuffer)->CUDABuffer; buffer->inputData = (union Data**)ALLOCATE_PTR_ARRAY(context, Array, 2); buffer->inputData[0] = (union Data*)inputArray->array; buffer->inputData[1] = (union Data*)inputArray; buffer->outputData = NULL; buffer->inputLen = 2; buffer->outputLen = 0; //continuationにそってGPUworkerに戻る outputArray->array = inputArray->array; Executor* executor = context->worker->worker->CUDAWorker.executor; executor->executor->CUDAExecutor.buffer = buffer; cudaLoadFunction(context, "c/examples/twice/CUDAtwice.ptx", "twice"); Gearef(context, Executor)->executor = (union Data*)executor; Gearef(context, Executor)->task = context; Gearef(context, Executor)->next = context->next; goto meta(context, executor->read); } #endif Array** O_output = (struct Array **)&context->data[context->odg]; goto twice(context, &context->data[context->idg]->Array, &context->data[context->idg+1]->MultiDim, context->next, O_output, Gearef(context, LoopCounter)); }