Concept explainers
A)
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)
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)
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)
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)
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.
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
- Quiz-1: Refer to Lecture-3 Module 1 swap (int* V, int k) { temp = V[k]; /* temp in $t0 */ V[k] = V[k+1]; V[k+1] = temp; } Write the swap() function using special registers required for accessing parameters passed to this function. Use “t” registers for any needed temporary registers.arrow_forwardwrite assembly x86-64 language File Types c, cpp, and asmarrow_forwardProgramming Language Pragmatics, 4th Editionarrow_forward
- We can solve memory leaks with using a tombstone or lock and keys approach to the dangling pointer problem using a tombstone or mark-sweep approach to the dangling pointer problem some form of garbage collection such as mark-sweep or reference counters some form of garbage collection such as tombstones or lock-and-keysarrow_forwardCOAL - Computer Organization and Assembly Languagearrow_forwardWrite a c++ code that implements a program that compares the running time for two loops which access very different number of array elements but which should have roughly the same number of cache misses. Try to estimate the average time for an array access with a cache miss and one without. use the following two loops (in the screenshot provided)arrow_forward
- COMPUTER ORGANISATION :: Use RARS simulator to write and execute the two codes below using RISC-V Assembly language.arrow_forwardAssume that you have a A= 5x5 Matrix with one byte size elements.. Write an Assembly program that places its transpose A' just after A in 8086 physical memory and also places transpose of transpose (A) just after A' . The basic mechanism must use SI and DI registers.The whole codes must work, otherwise no points. WHEN YOU FINISHED THIS QUESTION ONLY, YOU HAVE TO SEND THE COPY OF THIS CODE to YOUR INSTRUCTOR as a TXT or WORD FILE THRU STIX AFTER EXAM ( IF YOU ARE SURE THE CODES ARE WORKING FINE!! OTHERWISE DON'T SEND !)arrow_forwardWrite a subroutine that finds the total number of elements in an array that are divisible by 8. The starting address of the array is passed in Z pointer and the array count is passed in r16. The count of elements that are divisible by 8 is returned in r22. Also write a test program to test this subroutine. The test program should define an array of 40 elements in program memory (immediately after the test program) to test this subroutine. use atmel studio pleasearrow_forward
- subject microprocessor and assembly language Create a procedure that fills an array of doublewords with N random integers, making sure the values fall within the range j...k, inclusive. When calling the procedure, pass a pointer to the array that will hold the data, pass N, and pass the values of j and k. Preserve all register values between calls to the procedure. Write a test program that calls the procedure twice, using different values for j and k. Verify your results using a debugger.arrow_forwardCache Memory Caches depend on the locality principle – if you access memory locations near to each other, then you will get better performance because the cache will pull in a bunch of nearby locations every time you access main memory. Assume that multi-dimensional arrays in C are stored in “row major order”, that is, the elements in each row are stored together Example: int test[3][5] = { {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15} } Would be laid out in memory like: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Which of these two programs fragments (a or b) should have better cache performance? You need only answer “a” or “b” – no explanation needed. // begin fragment a int big[100,1000]; for (i=0, i<100, i++) { for (j=0, j<999, j++) { big[i,j] += big[i,j+1]; } } // end fragment a // begin fragment b int big[100,1000]; for (j=0, j<999, j++) { for (i=0, i<100, i++) { big[i,j] += big[i,j+1]; } } // end fragment barrow_forwardUsing C Language In this function, b has the address of a memory buffer that is num_bytes long. The function should repeatedly copy the 16 byte pattern that pattern16 points at into the memory buffer until num_bytes have been written. If num_bytes is not a multple of 16, the final write of the 16 byte pattern should be truncated to finish filling the buffer. void memset16(void *b, int num_bytes, void *pattern16) For example if the 16 bytes that pattern16 points at is 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff, then memset(b, 20, pattern16) should write to the buffer pointed at by p the 20 bytes 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff 00 11 22 33. Use SSE instructions to improve efficiency. Here's pseudocode. x = SSE unaligned load from pattern16while (num_bytes >= 16) SSE unaligned store x to p advance p by 16 bytes decrement num_bytes by 16while (num_bytes > 0) store 1 byte from pattern16 to p advance p by 1 byte advance pattern16 by 1 byte…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