main.s Error Code 2

102 views
Skip to first unread message

Jenna Liebe

unread,
Oct 28, 2020, 3:03:45 AM10/28/20
to cmpt-295-sfu
SFU ID: 301358537
Github username: jel-cmpt295
Github: Link to github repo (your assignment repos are private so these links are only accessible to TAs and Instructor): https://github.com/CMPT-295-SFU/assignment-3-jel-cmpt295
Line and file: main.s, "Load Matrices/Run Layers 1"
Expected behavior: Output result of m0 * input matmul
Observed behavior: Error code 2 (mismatched dimensions in matmul)
Question: I threw in a bunch of debug code to see what values my registers were storing before the jump to matmul, and I can't figure out what I'm doing wrong that I end up storing values that are all over the place - I have no idea where they're coming from. I made sure to reset the values of the a registers that I changed during my debug before going into matmul, but it still doesn't work. Where am I going wrong?

ali sedaghati

unread,
Oct 28, 2020, 1:15:55 PM10/28/20
to cmpt-295-sfu
Put a screenshot of command and error here. And make sure that you're passing the correct values to a1,a2,a4,a5 when you're calling matmul.

Arrvindh Shriraman

unread,
Oct 28, 2020, 1:34:44 PM10/28/20
to cmpt-295-sfu
Your read matrix is broken
1) the malloc of the row and column pointer have to happen in main not within read_matrix
Otherwise how does main know what the pointer is ? 
You seem to be mallocing the row and col ints within read_matrix which main does not know about.

Jenna Liebe

unread,
Oct 28, 2020, 2:55:00 PM10/28/20
to cmpt-295-sfu
Okay, I managed to fix that problem - thank you! Unfortunately now I have a different error - although I can print out Layers 1 and 2 (matmul with m0 and input, and relu on the result), for some reason I am not able to load m1 using my read_matrix file. Input and m0 are read in and loaded up fine, and I made sure that the filepath I was passing into read_matrix for m1 was correct, but I keep getting the "Venus ran into a simulator error!
Attempting to access uninitialized memory between the stack and heap. Attempting to access '4' bytes at address..." error if I don't comment out anything to do with m1.  I attached a screenshot of my output when m1 read_matrix and load are commented out, and one when they aren't (if that helps).

no m1.JPGwith m1.JPG

I'm using read_matrix on m1 in line 128 of main.s, and allocating the space for its parameters in lines 135-139.
It's formatted almost exactly the same as input and m0, so I'm not sure why it isn't working.

Arrvindh Shriraman

unread,
Oct 28, 2020, 3:21:08 PM10/28/20
to cmpt-295-sfu
That just means that the pointer to which you are trying to write is bad.
Check if you are reading the wrong location on the stack for m1's base address
- either you got the sp manipulation wrong
- OR you got the offset wrong

Jenna Liebe

unread,
Oct 28, 2020, 5:14:39 PM10/28/20
to cmpt-295-sfu
I'm pretty sure I'm reading the right location with the right offset - when I print out argv[0], argv[1] and argv[2] it gives me 
./inputs/simple0/bin/inputs/input0.bin
./inputs/simple0/bin/m0.bin
./inputs/simple0/bin/m1.bin

That's right, isn't it? So does that mean my offset and sp manipulations are right? If that's the case, why wouldn't read_matrix work with just the last input (m1 in this case)? 


Arrvindh Shriraman

unread,
Oct 28, 2020, 6:26:31 PM10/28/20
to cmpt-295-sfu
Your read matrix appears broken. 

What is this sequence doing:
lw s5, 0(s3)
mul s5, s3, s4

s3 is a pointer? 
s4 is a pointer?
s5 is going to be a bad value. You need to lw the pointers before multiplying them
Reply all
Reply to author
Forward
0 new messages