Created
March 18, 2015 17:49
-
-
Save kelindar/bb78f6480b84dd3b5c52 to your computer and use it in GitHub Desktop.
Data Locality: Matmul
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
void A(int n, int** a, int** b, int** c){ | |
parallel_for(0, n, [&](int k) | |
{ | |
for (int i = 0; i<n; i++) { | |
int r = a[i][k]; | |
for (int j = 0; j<n; j++) | |
c[i][j] += r * b[k][j]; | |
} | |
}); | |
}; |
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
void Parallel_KJI(int n, int** a, int** b, int** c){ | |
parallel_for(0, n, [&](int k) | |
{ | |
for (int j = 0; j<n; j++) { | |
int r = b[k][j]; | |
for (int i = 0; i<n; i++) | |
c[i][j] += a[i][k] * r; | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment