Skip to content

Instantly share code, notes, and snippets.

@krk

krk/matMul1-2.cu Secret

Created June 27, 2017 14:12
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/f4ec6a99917972f19a296f702bf65628 to your computer and use it in GitHub Desktop.
Save krk/f4ec6a99917972f19a296f702bf65628 to your computer and use it in GitHub Desktop.
// matMul1 (n adet global store):
d_C[ cIdx ] = 0;
// C matrisinin her bir hücresi için
for(int j=0; j<n; j++)
{
// her bir eleman için C matrisinin bir elemanı okunur ve yazılır.
d_C[ cIdx ] += *loc( d_A, n, i, j ) * *loc( d_B, r, j, k ); // global hafızaya yazılır(d_C).
}
// matMul2 (1 adet global store):
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 ); // local registera(val) yazılır.
}
// 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