Skip to content

Commit

Permalink
Packing of a MR x k panel from matrix A to buffer (without padding).
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-lehn committed Jun 1, 2014
1 parent bd6614c commit 0cde241
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions playground/pack-test.c
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;
}

0 comments on commit 0cde241

Please sign in to comment.