CSE_142_WI24_HW3

pdf

School

University of California, San Diego *

*We aren’t endorsed by this school

Course

142

Subject

Computer Science

Date

May 17, 2024

Type

pdf

Pages

7

Report

Uploaded by KidSpider1136

CSE 142: Computer Architecture: A Software Perspective Winter 2024 Homework 3 Instructor: Leo Porter Due on: Tuesday, 13 February (32 points) Name: Date: Instructions Answer each problem in the boxes provided. Any writing outside of the boxes will NOT be graded. Do not turn in responses recorded on separate sheets. Handwritten or typed responses are accepted. In either case, make sure all answers are in the appropriate boxes. All responses must be neat and legible. Illegible answers will result in zero points. 1. Locality (2 point - Completeness ): For a 2-D array, the first index is the row, and the second index is the column. Assume each word is a 32 bit integer and the array is stored in row major order. Also assume that the variables i,j and sum are stored in registers: for (i=0; i<100; i++){ for(j=0; j<4000; j++){ sum+= a[j][i] + b[j][i]; } } It is observed that the above piece of code suffers from significant memory latency. Why do you think it has these large memory delays and how can we improve the code to reduce this?
2. Cache Basics (6 points - Correctness ): We want to explore three different 1024 byte cache designs: direct-mapped, 4-way set-associative, and fully- associative. All three caches have 64-byte block size and use 32-bit byte addressing. How many bits do you need to assign for the tag, index, and block offset field for the three different caches? Please write down the number of bits in the table below. Cache direct-mapped 4-way set-associative fully-associative block offset Index Tag
3. Cache Accesses (6 points - Correctness ): Complete the following table for each of the below cache configurations: (a) Cache size - 512 byte, 2-way set associative cache with 64-byte block size. (b) Cache size - 512 byte, fully associative cache with 64-byte block size. For each access fill the last column with the type of cache miss if it is a miss (Just write hit if it’s a cache hit). Use Least Recently Used (LRU) as the replacement policy. Show tag, index and offset bits calculation in the box below to get full credits. (You may use the empty space on the right side of the tables to keep track of the cache contents.) Cache (a) Cache (b) block offset Index Tag Sr. No. Address (in binary) Cache (a) (Type of Cache Miss) 1 0010 0110 0000 2 1101 1000 0100 3 0000 0110 0110 4 0101 1110 1010 5 1110 0100 1110 6 1010 0010 0000 7 0010 0110 0001 8 1011 1010 0011 9 1101 1000 1100 10 1000 1100 1100 11 1111 1010 0000 12 1011 1000 1011 13 0100 0000 1110 14 0111 1110 0010 15 0101 1111 1010 16 0111 1111 0011 17 1010 0000 0001 18 0010 0110 0001 19 1110 0110 0010 20 0100 0001 1000 21 1111 1010 1110 22 1011 1001 1011 23 1001 0011 1111 24 0101 1110 0010
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Sr. No. Address (in binary) Cache (b) (Type of Cache Miss) 1 0010 0110 0000 2 1101 1000 0100 3 0000 0110 0110 4 0101 1110 1010 5 1110 0100 1110 6 1010 0010 0000 7 0010 0110 0001 8 1011 1010 0011 9 1101 1000 1100 10 1000 1100 1100 11 1111 1010 0000 12 1011 1000 1011 13 0100 0000 1110 14 0111 1110 0010 15 0101 1111 1010 16 0111 1111 0011 17 1010 0000 0001 18 0010 0110 0001 19 1110 0110 0010 20 0100 0001 1000 21 1111 1010 1110 22 1011 1001 1011 23 1001 0011 1111 24 0101 1110 0010 4. Cache Characterization (2 points - Completeness ): Show your work to receive full credit. It is observed in the following code that each iteration requires two loads (a[i], then a[i+256]) followed by a store (a[i]), and the cache hit rate on the store is 0% due to conflict misses. Tell me everything you can conclude about the cache. Assume that the order of loads and store are as mentioned above and there are no other memory operations apart from the ones mentioned above. (Hint: You should be able to find the associativity of the cache and an upper bound on the cache size) uint64_t a[MAX]; for (i=0; i<MAX; i++) { a[i] = a[i] + a[i+256]; }
5. Virtual Memory (4 points - Correctness ): You are given the following page table mappings. Valid Virtual Page (24 bits) Physical Page (28 bits) 1 0xAD1C62 0xBAC112C 1 0xAD1C63 0xBBC121D 1 0xAD1C64 0xBCBABA2 1 0xAD1C65 0xBDDA11A 1 0xAD1C66 0xEEEDAD1 ...All other entries invalid... (a) How many bytes does a single page in this system hold? (Assume 32 bit virtual addresses.) (b) Your processor receives the instruction mov (%ebx), %eax. List the complete physical memory address being accessed given the following values of %ebx (32 bits), or indicate if the access causes a page fault. Assume 32 bit virtual addresses. i. 0xAD1C6447 ii. 0xAD1C67AD iii. 0xAD1C63F9
6. TLB (6 points - Correctness ): Your TLB is 2-way set associative and holds 8 translations. It has the following entries. Virtual memory address consist of 32 bits with a 12 bit page offset. The virtual page number tag in the TLB excludes the 2 bit index and therefore is 18 bits. The 18 bit of Virtual Page # Tag is shown in the TLB table below in the form: top 16 bits in hex (0xXXXX), bottom 2 bits (bXX) in binary. The physical page number consists of 28 bits. Index Virtual Page # Tag Physical Page # Tag Virtual Page # Tag Physical Page # Tag 0 0x73C7, b10 0x1234567 0x5CDD, b01 0x7642861 1 0x6200, b00 0x345df44 0x3EEE, b10 0x2345647 2 0xCCD3, b01 0xDBB234D 0x1265, b10 0x234BDCE 3 0xF13F, b01 0xAB568BC 0x8DF1, b11 0x0187109 (a) Fill out the rightmost column of the memory access table below to denote whether the memory access was a hit or a miss in the TLB. The cache uses an LRU replacement policy, and you may assume that to start with, the right entry is the least recently used. You can use the below empty table to keep track of the entries in TLB while processing the memory accesses. Index Virtual Page # Tag Physical Page # Tag Virtual Page # Tag Physical Page # Tag 0 1 2 3 Virtual Mem Access Result (Physical Mem Address) Hit/Miss 0x73C78000 0x1234567000 0x62001077 0x345DF44077 0x8703C12E 0x764286712E 0x5CDD4AD2 0x7642861AD2 0x339541D0 0xDB32D781D0 0xBEEDD020 0x3091834020 0xA667B9DC 0x23456479DC 0xCCD35293 0xDBD234D293 (b) What are the contents of the TLB after processing the page accesses from (a)? Index Virtual Page # Tag Physical Page # Tag Virtual Page # Tag Physical Page # Tag 0 1 2 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
7. Cache Basics - Accessing a cache (6 points - Correctness ): Show your work to receive full credit. Given a 256 byte cache, 16-byte block size, and 16-bit byte addressing, we want to run following C code with direct-mapped and 4-way set-associative caches. How many cache hits, cache misses, compulsory misses, conflict misses, and capacity misses are there on these two caches? Assume that the load operations are performed in the following order: A[i], then A[i+1], then A[i+128]. Code optimization at compiler-level is unavailable (i.e. Your processor executes the given code strictly in the given order.) // the address of A[0] is 0x0000 and the array A grows in increasing numbers // each element of array A is of 4 bytes for (int i = 0 ; i <= 7 ; i++ ) { int a = A[i] + A[i+1] + A[i+128]; printf("%d", a); } Write your answer in the tables below. Total hits Total misses Compulsory misses Conflict misses Capacity misses direct-mapped 4-way set-associative Direct-mapped (Hit or Miss with miss type) i A[i] A[i+1] A[i+128] 0 1 2 3 4 5 6 7 4-way set associative (Hit or Miss with miss type) i A[i] A[i+1] A[i+128] 0 1 2 3 4 5 6 7