Skip to content

Instantly share code, notes, and snippets.

@krk

krk/matMul1.cu Secret

Created June 27, 2017 14:07
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/6436abe676ae2268c8e392dfcfdc77a6 to your computer and use it in GitHub Desktop.
Save krk/6436abe676ae2268c8e392dfcfdc77a6 to your computer and use it in GitHub Desktop.
__global__
void matMul1(
float* d_C,
float* d_A,
float* d_B,
int m,
int n,
int r)
{
int i = blockIdx.x * BLOCK_SIZE + threadIdx.x; // GPU threadinin hesaplayacağı C matrisinin satırı.
int k = blockIdx.y * BLOCK_SIZE + threadIdx.y; // GPU threadinin hesaplayacağı C matrisinin sütunu
int cIdx = i*m + k; // Hesaplanacak elemanın C indisi.
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 );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment