diff options
| author | _ov4 <ov4@ov4.org> | 2026-07-21 14:49:23 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-07-21 14:49:23 +0000 |
| commit | 4c3db4aa74348d5cf41c43140d2a59d6fe2c8374 (patch) | |
| tree | 1eee3b70321deb3bc397fd594bf650d4dffbef2a /cachelab-handout/trans.c | |
| parent | 9d2d2fb779d4fc51f35eeabf2e2e1f03568203d2 (diff) | |
simple implementation for N,M are both multiple of 8
Diffstat (limited to 'cachelab-handout/trans.c')
| -rw-r--r-- | cachelab-handout/trans.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/cachelab-handout/trans.c b/cachelab-handout/trans.c index e40f6fc..d8f221b 100644 --- a/cachelab-handout/trans.c +++ b/cachelab-handout/trans.c @@ -22,6 +22,26 @@ int is_transpose(int M, int N, int A[N][M], int B[M][N]); char transpose_submit_desc[] = "Transpose submission"; void transpose_submit(int M, int N, int A[N][M], int B[M][N]) { + int i, j, tmp, i2, j2; + const int blockSize = 8; + + // given N, M are multiples of blockSize + // just to test + for (i = 0; i < N/blockSize; i++) + { + for (j = 0; j < M/blockSize; j++) + { + // now i, j are indecies of smaller groups + for (i2 = 0; i2 < blockSize; i2++) + { + for (j2 = 0; j2 < blockSize; j2++) + { + tmp = A[i*blockSize + i2][j*blockSize + j2]; + B[j*blockSize + j2][i*blockSize + i2] = tmp; + } + } + } + } } /* |
