view src/parallel_execution/examples/twice/CUDAtwice.cu @ 438:7679093bdd72

Work CUDAtwice
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Mon, 06 Nov 2017 00:11:43 +0900
parents 764c92c3b181
children
line wrap: on
line source

extern "C" {
    struct Array {
        int prefix;
        int* array;
    } Array;

    __global__ void twice(int* array, struct Array* inputArray) {
        int i = 0;
        int prefix = inputArray->prefix;
C_twice:
        if (i < prefix) {
            array[i+(blockIdx.x*blockDim.x+threadIdx.x)*prefix] = array[i+(blockIdx.x*blockDim.x+threadIdx.x)*prefix]*2;
            i++;
            goto C_twice;
        }
    }
}