Skip to content

Instantly share code, notes, and snippets.

@krk

krk/matMul2.cu Secret

Created June 27, 2017 14:08
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 krk/210df88cde7b554a0f31983027e7c1b5 to your computer and use it in GitHub Desktop.
Save krk/210df88cde7b554a0f31983027e7c1b5 to your computer and use it in GitHub Desktop.
__global__
void matMul2(
float* d_C,
float* d_A,
float* d_B,
int m,
int n,
int r)
{
int i = blockIdx.x * BLOCK_SIZE + threadIdx.x;
int k = blockIdx.y * BLOCK_SIZE + threadIdx.y;
int cIdx = i*m + k;
float val = 0; // ara toplam değişkeni
// C matrisinin her bir hücresi için
for(int j=0; j<n; j++)
{
val += *loc( d_A, n, i, j ) * *loc( d_B, r, j, k );
}
// C matrisine bir kere yazılır.
d_C[ cIdx ] = val;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment