Computer Systems: A Programmer's Perspective (3rd Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 6, Problem 6.36HW

A)

Program Plan Intro

Given Information:

The given code is:

//variable declaration

//matrix

Int x[2][128];

int i;

//variable to store sum

Int sum=0;

//iterate through the matrix

for(i=0;i<128;i++)

{

//sum of matrix elements

sum+= x[0][i]*x[1][i];

}

Explanation:

  • The given array is x[2][128]. The cache is initially empty and it begins to store data from “0x0” addresses.
  • Here, size of (int) =4.
  • Only memory accesses entries of array “x”.
  • C arrays allocated in row-major order which means that each row is in their contiguous memory location.

B)

Program Plan Intro

Given Information:

The given code is:

//variable declaration

//matrix

int x[2][128];

int i;

//variable to store sum

int sum=0;

//iterate through the matrix

for(i=0;i<128;i++)

{

//sum of matrix elements

sum+= x[0][i]*x[1][i];

}

Explanation:

  • The given array is x[2][128]. The cache is initially empty and it begins to store data from “0x0” addresses.
  • Here, size of (int) =4.
  • Only memory accesses entries of array “x”.
  • C arrays allocated in row-major order which means that each row is in their contiguous memory location.

C)

Program Plan Intro

Given Information:

The given code is:

//variable declaration

//matrix

Int x[2][128];

int i;

//variable to store sum

Int sum=0;

//iterate through the matrix

for(i=0;i<128;i++)

{

//sum of matrix elements

sum+= x[0][i]*x[1][i];

}

Explanation:

  • The given array is x[2][128]. The cache is initially empty and it begins to store data from “0x0” addresses.
  • Here, size of (int) =4.
  • Only memory accesses entries of array “x”.
  • C arrays allocated in row-major order which means that each row is in their contiguous memory location.

D)

Program Plan Intro

Given Information:

The given code is:

//variable declaration

//matrix

int x[2][128];

int i;

//variable to store sum

int sum=0;

//iterate through the matrix

for(i=0;i<128;i++)

     {

//sum of matrix elements

              sum+= x[0][i]*x[1][i];

     }

  • The given array is x[2][128]. The cache is initially empty and it begins to store data from “0x0” addresses.
  • Here, size of (int) =4.
  • Only memory accesses entries of array “x”.
  • C arrays allocated in row-major order which means that each row is in their contiguous memory location.

E)

Program Plan Intro

Given Information:

The given code is:

The given code is:

//variable declaration

//matrix

Int x[2][128];

int i;

//variable to store sum

Int sum=0;

//iterate through the matrix

for(i=0;i<128;i++)

{

//sum of matrix elements

sum+= x[0][i]*x[1][i];

}

Explanation:

  • The given array is x[2][128]. The cache is initially empty and it begins to store data from “0x0” addresses.
  • Here, size of (int) =4.
  • Only memory accesses entries of array “x”.
  • C arrays allocated in row-major order which means that each row is in their contiguous memory location.

Blurred answer
Students have asked these similar questions
Now, we consider a 16-byte, four-way, fully-associative cache. Since the capacity of the cache is 16 bytes, the array "a" in our example (does/does not) fit inside the cache. We can deduce that the block size for this cache is ( ? ) bytes per block. So the block index size b=2 bits. For a memory trace record such as: L 1fff000116,2 the 2-bit block offset is (0b01/0b10/0b11/0b00). The tag bits are all the rest of the bits not part of the block offset.
Suppose we have a system with the following properties:The memory is byte addressable.Memory accesses are to 1-byte words (not to 4-byte words).Addresses are 13 bits wide.The cache is 4-way set associative (E = 4), with a 4-byte block size(B = 4) and eight sets (S = 8).Consider the following cache state. All addresses, tags, and valuesare given in hexadecimal format. The Index column contains the set index for each set of four lines. The Tag columns contain the tag value for each line. The V columns contain the valid bit for each line. The Bytes 0−3 columns contain the data for each line, numbered left to right starting with byte 0 on the left.   A. What is the size (C) of this cache in bytes?B. The box that follows shows the format of an address (1 bit perbox). Indicate (by labeling the diagram) the fields that would beused to determine the following:CO. The cache block offsetCI. The cache set indexCT. The cache tag
Develop a C/C++ program that accepts the name of a memory trace file as a command line argument.  Use the data to simulate a set associative cache using LRU replacement.  Additional command line arguments will be needed to identify the details of the simulated cache.  The arguments should appear in the following order: the memory trace input file X, where 2X  ==  the number of direct-mapped sets Y, where 2Y  == the number of blocks per set Z, where 2Z  == the number of cached words per block   Your program (say it's a compiled C program) could be run like this: ./cache data.tra 3 2 4 This would simulate an 8 set associative LRU cache with 4 blocks per set, where each block caches 16 addresses. NOTE… the reason I've chosen to use exponents for arguments is to ensure we have powers of 2 for everything. Trace File The trace file is line based with each line containing a memory address requested, in hex.  Please note this data is real, so the addresses are larger than 32-bits. In…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education