Skip to content

Instantly share code, notes, and snippets.

@FindHao
Created July 4, 2017 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FindHao/394b2f069788e5a4c80a069638a47e1c to your computer and use it in GitHub Desktop.
Save FindHao/394b2f069788e5a4c80a069638a47e1c to your computer and use it in GitHub Desktop.
向量加法,cuda版本
__global__ void add_vectors(
const int* a,
const int* b,
int *c,
const int n)
{
const int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx >= n) return;
c[idx] = a[idx] + b[idx];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment