-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Packing of a MR x k panel from matrix A to buffer (without padding).
- Loading branch information
1 parent
bd6614c
commit 0cde241
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include <stdio.h> | ||
|
||
#define M 14 | ||
#define K 15 | ||
|
||
#define MC 8 | ||
#define KC 12 | ||
|
||
#define MR 4 | ||
|
||
double A[M*K]; | ||
double _A[MC*KC]; | ||
|
||
void | ||
initMatrix(int m, int n, double *X, int ldX, int counter) | ||
{ | ||
int i, j; | ||
|
||
for (j=0; j<n; ++j) { | ||
for (i=0; i<m; ++i) { | ||
X[i+j*ldX] = counter; | ||
++counter; | ||
} | ||
} | ||
} | ||
|
||
void | ||
printMatrix(int m, int n, double *X, int ldX) | ||
{ | ||
int i, j; | ||
|
||
for (i=0; i<m; ++i) { | ||
for (j=0; j<n; ++j) { | ||
printf("%4.0lf ", X[i+j*ldX]); | ||
} | ||
printf("\n"); | ||
} | ||
printf("\n"); | ||
} | ||
|
||
void | ||
pack_MRxk(int n, double *A, int incRowA, int incColA, double *buffer) | ||
{ | ||
int i, j; | ||
|
||
for (j=0; j<n; ++j) { | ||
for (i=0; i<MR; ++i) { | ||
buffer[i] = A[i*incRowA]; | ||
} | ||
buffer += MR; | ||
A += incColA; | ||
} | ||
} | ||
|
||
int | ||
main() | ||
{ | ||
initMatrix(M, K, A, M, 1); | ||
|
||
printf("A = \n"); | ||
printMatrix(M, K, A, M); | ||
|
||
pack_MRxk(KC, A, 1, M, _A); | ||
|
||
printf("Buffer: _A = \n"); | ||
printMatrix(MC, KC, _A, MC); | ||
|
||
pack_MRxk(KC, A+MR, 1, M, _A+MR*KC); | ||
|
||
printf("Buffer: _A = \n"); | ||
printMatrix(MC, KC, _A, MC); | ||
return 0; | ||
} |