Consider the following fragment of C code: Assume that A and B are arrays of 64-bit integers,

Question:

Consider the following fragment of C code:

image text in transcribed

Assume that A and B are arrays of 64-bit integers, and C and i are 64-bit integers.
Assume that all data values and their addresses are kept in memory (at addresses 1000, 3000, 5000, and 7000 for A, B, C, and i, respectively) except when they are operated on. Assume that values in registers are lost between iterations of the loop. Assume all addresses and words are 64 bits.

a. Write the code for RISC-V. How many instructions are required dynamically? How many memory-data references will be executed?
What is the code size in bytes?

b. Write the code for x86. How many instructions are required dynamically? How many memory-data references will be executed? What is the code size in bytes?

c. Write the code for a stack machine. Assume all operations occur on top of the stack. Push and pop are the only instructions that access memory; all others remove their operands from the stack and replace them with the result.
The implementation uses a hardwired stack for only the top two stack entries, which keeps the processor circuit very small and low in cost. Additional stack positions are kept in memory locations, and accesses to these stack positions require memory references. How many instructions are required dynamically? How many memory-data references will be executed?

d. Instead of the code fragment above, write a routine for computing a matrix multiplication for dense, single precision matrices, also known as SGEMM. For input matrices of size 100 х 100, how many instructions are required dynamically? How many memory-data references will be executed?

e. As the matrix size increases, how does this affect the number of instructions executed dynamically or the number of memory-data references?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question

Computer Architecture A Quantitative Approach

ISBN: 9780128119051

6th Edition

Authors: John L. Hennessy, David A. Patterson

Question Posted: