Unformatted text preview:

CMSC411 Assignment 1 Fall 2024 Dues On time September 13 by 11 00 PM Late September 14 by 11 00 PM General instruction Submit a PDF file to GradeScope You may edit the PDF file directly scan your work on paper or can also use an app e g Scannable to create a PDF file from photos of your work After uploading your work don t forget to create mapping between questions and your answers 5 points will be deducted if mapping is not or incorrectly given Unless specified all questions will be graded Unless specified justify your answers always If justifications are missing or do not show reasonably how your answers are derived 0 points will be assigned regardless of the correctness of the answers Write neatly in case you write your answers on paper Especially for table completion questions if your answers are not given neatly in well drawn tables the answers won t be graded It is also recommended to print this file and put your answers on the printout This assignment must be done by yourself without any unauthorized assistance Write your name and numeric student ID in the space below and put your signature after reading the pledge statement Name SID Numeric Signature I pledge my honor that all parts of this assignment were done by me individually and without any unauthorized assistance or collaboration with others 1 Adiah Amadou119435977 Q1 Speedup Assume that you are considering to enhance a machine by adding a new faster execution mode to it When a computation is run in the fast mode it is 10 times faster than using the normal mode of execution a What percentage of the fast mode is needed to achieve a speedup of 2 b What percentage of fast mode is required to achieve half of the maximum speedup Note that the maximum speedup will be achieved when fast mode is used continuously 2 Q2 time command Suppose that Unix time command tells that 90 seconds were spent for running user code the wall clock time was 3 mins and the utilization of the CPU was 70 How much time was spent for running kernel system code 3 Q3 MIPS ISA Consider the following fragment of C code that increases the value of every array element by 1 for i 100 i a i Consider the following assumptions and constraints to answer this question Use MIPS32 instructions For example use ADD instead of DADD for 64 bit A few more MIPS32 instructions just for your reference ADDI LW SW SLL SRL SLT LUI ORI AND z Assume that 1 i is a 32 bit integer which is stored in memory at the address 0x7FFF FFFC occupying 4 bytes from 0x7FFF FFFC to 0x7FFF FFFF and that 2 0 is stored in the space You will write code that loads the value to the register t0 once before the loop code and then uses the register during the loop i e for i instead of accessing memory repeatedly This approach will also help you simplify the code Assume that the first array element is stored in memory at the address 0x7FFF FE00 occupying 4 bytes from 0x7FFF FE00 to 0x7FFF FF8F Do NOT use Load Immediate li instruction Do NOT use Load Address la instruction Do NOT use labels for i and a Load the 32 bit memory addresses of the variables into register s Note that memory addresses are 32 bit wide but the immediate value field of ADDI is only 16 bit long We discussed in class a method to load a 32 bit value into a register a Write the MIPS code 4 lui t1 0x7FFF Load upper address of iori t1 t1 0xFFFC OR to get full addresslw t0 0 t1 Load value of i initially 0 into t0addi t2 0 100 Set t2 100 for comparison laterlui t4 0x7FFF Load upper address of array aori t4 t4 0xFE00 OR to get full addressloop slt t3 t0 t2 Set t3 to 1 if t0 i t2 100 beq t3 0 end loop If t3 0 end the loopsll t5 t0 2 t5 i 4 byte offset add t6 t4 t5 Address of a i lw t7 0 t6 Load the value of a i into t7addi t7 t7 1 Increment the value of a i by 1sw t7 0 t6 Store the incremented value back to a i addi t0 t0 1 Increment i by 1j loop Jump back to the start of the loopend loop End of loop b What is the code size in bytes c How many instructions are executed at run time If an instruction is executed multiple times count all No points will be given for incorrect code tracing d How many memory accesses both reads and writes are needed while running your code No points will be given for incorrect code tracing 5 Is it just number of instructions 4 since each instruction is 32 bits ie 4 bytes Code size 15 4 60 bytesCount all instructions multiply the ones in loop by a 100 and take note taht teh last time we enter into a loop is when we are checking to see if we can continue ie 2 instructionsexecutedcount eth number of lw and sw load store architecture as they are teh only ones accessing memory don t forget looping Q4 MIPS ISA Consider the following fragment of C code that counts the number of 1s in the binary representation of an integer do c v 2 v 2 while v 0 Consider the following constraints to answer this question Assume that c and v are 32 bit integers Use MIPS32 instructions For example use ADD instead of DADD for 64 bit A few more MIPS32 instructions just for your reference ADDI LW SW SLL SRL SLT LUI ORI AND Assume that all variables are kept in memory at 0x7FFF0004 and 0x7FFF0000 for c and v respectively Also assume that c is initialized to 0 i e zero is the value stored at the memory address 0x7FFF0004 occupying 4 bytes from 0x7FFF0004 to 0x7FFF0007 Do NOT use integer division instruction Do NOT use Load Immediate li instruction Do NOT use Load Address la instruction Do NOT use labels for c and v Load the memory addresses of the variables given above into register s Note that memory addresses are 32 bit wide but the immediate value field of ADDI is only 16 bit long 6 a Write the MIPS code Do NOT give system call code block or data section already given in the provided starter code You may use the code for checking the correctness of your MIPS code by loading the code to QtSpim or Mars for execution 7 lui t0 0x7FFF load upper adress of cori t0 t0 0X0004 Bitwise or to get full adress clw t1 0 t0 load value of c into memoryxor t0 t0 t0 clear register t0lui t0 0x7FFF load upper adress of vori t0 t0 0X0000 Bitwise or to get full adress vlw t2 0 t0 load value of v into memorywhile andi t3 t2 1 t3 v 2add t1 t1 t3 c v …


View Full Document

UMD CMSC 411 - Assignment 1

Documents in this Course
Load more
Download Assignment 1
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Assignment 1 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Assignment 1 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?