-
-
Save krk/0133d4fcce46c18edb3b8f656eb624e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline | |
float* h_loc(float* h_B, int width, int i, int j) | |
{ | |
return h_B + i*width + j; | |
} | |
void hostMatrixMultiply( | |
float* h_C, | |
float* h_A, | |
float* h_B, | |
int m, | |
int n, | |
int r) | |
{ | |
clock_t start = clock(), diff; | |
for(int i=0; i<m; i++) | |
{ | |
for(int k=0; k<r; k++) | |
{ | |
float sum = 0; | |
for(int j=0; j<n; j++) | |
{ | |
sum += *h_loc(h_A, n, i, j) * *h_loc(h_B, r, j, k); | |
} | |
*h_loc(h_C, r, i, k) = sum; | |
} | |
} | |
diff = clock() - start; | |
int msec = diff * 1000 / CLOCKS_PER_SEC; | |
printf("hostMatrixMultiply: %i ms\n", msec); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment