32x32 matrix now with <300 misses

master
anna_schlittenhardt 2020-12-19 12:39:46 +01:00
parent 8e9a49a0c8
commit f1ab745063
1 changed files with 31 additions and 2 deletions

View File

@ -29,14 +29,23 @@ void transpose_submit(int M, int N, int A[N][M], int B[M][N])
{
//343 misses (goal: <300; 0 points if >600)
if(N == 32){
int n, m, nn, mm;
int n, m, nn, mm, diag_pos, diag_value;
for (n=0; n<N;n+=8){
for (m=0;m<M; m+=8){
for(nn=n; nn<n+8;nn++){
for(mm=m; mm<m+8;mm++){
if(nn!=mm){
B[mm][nn] = A[nn][mm];
}else{
diag_pos = nn;
diag_value = A[nn][mm];
}
}
if(n==m){
B[diag_pos][diag_pos]= diag_value;
}
}
}
@ -44,7 +53,27 @@ void transpose_submit(int M, int N, int A[N][M], int B[M][N])
}
if(N == 64){
int n, m, nn, mm, diag_pos, diag_value;
for (n=0; n<N;n+=4){
for (m=0;m<M; m+=4){
for(nn=n; nn<n+4;nn++){
for(mm=m; mm<m+4;mm++){
if(nn!=mm){
B[mm][nn] = A[nn][mm];
}else{
diag_pos = nn;
diag_value = A[nn][mm];
}
}
if(n==m){
B[diag_pos][diag_pos]= diag_value;
}
}
}
}
}
}