You are writing a new 3D game that you hope will earn you fame and fortune. You are currently working on a function to blank the screen buffer before drawing the next frame. The screen you are working with is a 640 x 480 array of pixels. The machine you are working on has a 64 KB direct-mapped cache with 4-byte lines The C structures you are using are as follows:
Assume the following:
- size of(char) = 1 and size of(int) = 4.
Homework Problem
- buffer begins at memory address 0.
- The cache is initially empty.
- The only memory accesses are to the entries of the array buffer. Variables l, j, cptr, and iptr are stored in registers.
What percentage of writes in the following code will miss in the cache?
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Additional Engineering Textbook Solutions
Starting Out with C++: Early Objects
Starting Out With Visual Basic (8th Edition)
Introduction to Programming Using Visual Basic (10th Edition)
Starting Out With Visual Basic (7th Edition)
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
- Create a program in C++ which simulates a direct cache. The memory array that contains the data to be cached is byte addressable and can contain 256 single byte entries or lines. The cache has only 8 entries or lines. The Data field in each line of the cache is 8 bits. Since the data stored in each line of the cache is only 8 bits, there is no need for a line field. Only a tag field is needed which is log2(256) = 8 bits. The memory array can be filled with any values of your choice. The program should work by taking user input of a memory address (index). This input represents the memory data that should be cached. Your program will check the cache to see if the item is already cached. If it is not, your program should count a cache miss, and then replace the item currently in the cache with the data from the inputted address. Allow the user to input addresses (in a loop), until they so choose to end the program. The program should output the number of cache misses upon ending.arrow_forwardAssume that arrX array is already defined and allocated in memory, its base address 0xabcd3000 and already stored in $a2 and its number of elements in $a3. Answer each of the next questions as required. arrX: .word 0x99,0x20,0x73,0x40,0x50,0x69, ... Please write question numbers and answer parts in this question in order. Q4) Write NO more than 3 MIPS instructions to decrement the fourth element of arrX: ______________________________ Q5) Write no more than 6 instructions to calculate $v0= first element - last element in arrX.arrow_forwardFor the following loop assume the array arr2[][] has never been referenced before in the code. Also assume that a cache line is 32 Bytes, and an int is 4 Bytes. 1. How many memory references are there?arrow_forward
- Write and simulate a MIPS assembly-language routine that: 1. Prints your group number, for example “Group 1”, 2. Computes the dot product of two vectors, A_vec and B_vec, as described in Lab 4 of the Lab Manual, 3. Stores the result at memory word DOTPROD, and 4. Prints the result preceded by the phrase: “The result of the dot product is: “. Your data segment should look like the following: .data group: .asciiz “\nGroup x” msg: .asciiz "\nThe result of the dot product is: " A_vec: .word x, 4, 20, 13, 3, 10, 5 B_vec: .word 4, 2, 1, 2, 5, 2, 4 n: .word 7 DOTPROD: .word 0 Replace each “x” with your group number.arrow_forwardInput file sample.txt contains a hex dump of some data in the following format:<address> <byte1> <byte2> ... <byte16>Example Input File:00000000 54 68 69 73 20 69 73 20 61 6e 20 65 78 61 6d00000010 70 6c 65 20 6f 66 20 68 65 78 20 64 75 6d 70...Construct a pipeline using Ubuntu bash to discard the first column (address) and to reformat bytesinto a single column:arrow_forwardIn MIPS assembly, how do I iteratively read a file that contains only 2 numbers on each line, and calculate the distance between the two numbers on each line. Ex: file contains 1 5 4 7 function returns $v0=2 $a2 contains the array address [4, 3, default, default, default] also the file won't be greater than 300 mb and is never emptyarrow_forward
- This function will be able to determine the fields in a log entry it needs to look at in order to do its job properly. The following line of code computes the average number of cache misses for each item in the cache when 64-byte cache blocks are used without any prefetching being performed by the program.arrow_forwardYour task is to write an assembly-language program that finds the most frequently occurring valuein a data array that starts at memory address $0 and contains $1 words. The most frequent value must be stored in register $2. If multiple distinct values have the maximum number of occurrences in the data array, returning any one of these values $2 will do. Hints: Recall that the study material for Round 5 contains example armlet programs that sort an array. You may want to sort the array first and then find the most frequent value in the sorted data. Indeed, once the data is sorted, it is easy to find out how many times each value occurs by making one scan through the data. You probably want to keep track of a value that occurs the maximum number of times in the array scanned so far, and update this value whenever a more frequent value occurs.arrow_forwardIn layman's terms, here's how dynamic memory allocation works.arrow_forward
- Please calculate the total clock cycles for each functionseperately then calculate how much faster would the functions be if a better data cache reduced the average memory operations time to 4 cycles? Code: # Calculating Fibonacci numbers# fib(0) = 0# fib(1) = 1# fib(n) = fib(n-1)+fib(n-2).text.globl mainprint_str:li $v0, 4 # print string at ($a0)syscall #jr $ra # return; print_eol:la $a0, eol # print "\n"li $v0, 4 #syscall #jr $ra # return; print_int:li $v0, 1 # print integer ($a0)syscall #jr $ra # return; # fib(n) - recursive function to compute nth Fibonacci number#fib: sub $sp,$sp,12 # save registers on stacksw $a0, 0($sp) # save $a0 = nsw $s0, 4($sp) # save $s0sw $ra, 8($sp) # save $ra to allow recursive calls bgt $a0,1, gen # if n>1 then goto generic casemove $v0,$a0 # output = input if n=0 or n=1j rreg # goto restore registers gen: sub $a0,$a0,1 # param = n-1jal fib # compute fib(n-1)move $s0,$v0 # save fib(n-1) sub $a0,$a0,1 # set param to n-2jal fib # and make recursive…arrow_forwardwrite your own MIPS program that allocates space for two integer arrays (P and Q) of size 9 each. You can use pointers or indices for traversing arrays. The program should do the following:a. Read in the value of N (a digit between 1 and 9, the actual working size of your array).b. Read in from the keyboard the first N values of the array P. Note that we want both arrays P and Q to haveidentical elements (see the example below for additional explanation).c. Output to the console the N values of both arrays P and Q (use any format and additional text you like).Textbook i use is "Computer Organization and Design 4th Edition by John L hennesyExample: let’s say that the digit read from the keyboard was 3. This means that N=3; them our program will initialise two arrays with elements P[0], P[1], P[2] and Q[0], Q[1], Q[2]. Elements of the arrays are to be read from the keyboard, let’s assume that they were: 25, 11 and 2. The arrays are to be initialised as following:Q[0]=25 Q[1]=11 Q[2]=…arrow_forwardBelow is a list of 32-bit memory address references, given as memory addresses. 12, 720, 172, 8, 764, 352, 760, 56, 724, 176, 744You would like to access a cache with the given memory addresses. The size of cache is 23 = 8-blocks. Your task is to: (1) find out the binary address, (2) fill out the tag and index for each memory address and (3) indicate whether the access is hit or miss in the following table:arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education