Skip to content

Instantly share code, notes, and snippets.

@bast
Last active August 29, 2015 14:10
Show Gist options
  • Save bast/29627e8c50c8d4b6dfe9 to your computer and use it in GitHub Desktop.
Save bast/29627e8c50c8d4b6dfe9 to your computer and use it in GitHub Desktop.
Basic CUDA kernel construct.
// Copyright (c) 2015 Radovan Bast
// Licensed under the MIT license - http://opensource.org/licenses/MIT
__global__ void foo_kernel(int n,
                           double *a,
                           double *b,
                           double *c)
{
    int tid = threadIdx.x + blockIdx.x*blockDim.x;
    while (tid < n) {
c[tid] = a[tid]*b[tid];
        tid += blockDim.x*gridDim.x;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment