aboutsummaryrefslogtreecommitdiff
path: root/cachelab-handout
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-07-21 14:49:23 +0000
committer_ov4 <ov4@ov4.org>2026-07-21 14:49:23 +0000
commit4c3db4aa74348d5cf41c43140d2a59d6fe2c8374 (patch)
tree1eee3b70321deb3bc397fd594bf650d4dffbef2a /cachelab-handout
parent9d2d2fb779d4fc51f35eeabf2e2e1f03568203d2 (diff)
simple implementation for N,M are both multiple of 8
Diffstat (limited to 'cachelab-handout')
-rw-r--r--cachelab-handout/.gitignore6
-rw-r--r--cachelab-handout/Makefile16
-rwxr-xr-xcachelab-handout/csimbin0 -> 236568 bytes
-rw-r--r--cachelab-handout/trans.c20
4 files changed, 33 insertions, 9 deletions
diff --git a/cachelab-handout/.gitignore b/cachelab-handout/.gitignore
new file mode 100644
index 0000000..50eaddd
--- /dev/null
+++ b/cachelab-handout/.gitignore
@@ -0,0 +1,6 @@
+.csim_results
+.marker
+csim_results
+test-trans
+trace.*
+tracegen
diff --git a/cachelab-handout/Makefile b/cachelab-handout/Makefile
index 6fc127d..249098e 100644
--- a/cachelab-handout/Makefile
+++ b/cachelab-handout/Makefile
@@ -8,22 +8,20 @@ CFLAGS = -g -Wall -Werror -std=c99 -m64
CXX = g++
CXXFLAGS = -g -Wall -Werror -std=c++17 -m64
-# all: csim test-trans tracegen
-# # Generate a handin tar file each time you compile
-# -tar -cvf ${USER}-handin.tar csim.c trans.c
+all: csim test-trans tracegen
csim: csim.cc cachelab.c cachelab.h
$(CC) $(CFLAGS) -c cachelab.c -o cachelab.o
$(CXX) $(CXXFLAGS) -o csim csim.cc cachelab.o -lm
-# test-trans: test-trans.c trans.o cachelab.c cachelab.h
-# $(CC) $(CFLAGS) -o test-trans test-trans.c cachelab.c trans.o
+test-trans: test-trans.c trans.o cachelab.c cachelab.h
+ $(CC) $(CFLAGS) -o test-trans test-trans.c cachelab.c trans.o
-# tracegen: tracegen.c trans.o cachelab.c
-# $(CC) $(CFLAGS) -O0 -o tracegen tracegen.c trans.o cachelab.c
+tracegen: tracegen.c trans.o cachelab.c
+ $(CC) $(CFLAGS) -O0 -o tracegen tracegen.c trans.o cachelab.c
-# trans.o: trans.c
-# $(CC) $(CFLAGS) -O0 -c trans.c
+trans.o: trans.c
+ $(CC) $(CFLAGS) -O0 -c trans.c
#
# Clean the src dirctory
diff --git a/cachelab-handout/csim b/cachelab-handout/csim
new file mode 100755
index 0000000..5d4de8a
--- /dev/null
+++ b/cachelab-handout/csim
Binary files differ
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;
+ }
+ }
+ }
+ }
}
/*