view src/parallel_execution/examples/twice/CUDAtwice.cu @ 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

extern "C" {

#include <stdio.h>

//    __global__ void twice(struct LoopCounter* loopCounter, int prefix ,int* array) {
//         int index = blockIdx.x * blockDim.x + threadIdx.x;
//         printf("array %p, blockIdx.x = %d, blockDim.x = %d, threadIdx.x = %d\n");
//         int i = 0;
//         while (i < prefix) {
//              array[i+index*prefix] = array[i+index*prefix]*2;
//         }
//    }

    struct LoopCounter {
        int i;
    } LoopCounter;

    __global__ void twice(struct LoopCounter* loopCounter, int index, int prefix, int* array) {
         printf("array %p, index = %d, prefix = %d loopCounter->i %d\n",array,index,prefix,loopCounter->i);
C_twice:
        int i = loopCounter->i;
        if (i < prefix) {
            array[i+index*prefix] = array[i+index*prefix]*2;
            loopCounter->i++;

            goto C_twice;
        }

        loopCounter->i = 0;
    }


}