Question: A computer for rendering digital special effects has 8 processor cores. The rendering program has 20% serial portion and the rest of the rendering is
A computer for rendering digital special effects has 8 processor cores. The rendering program has 20% serial portion and the rest of the rendering is parallelizable and can be run on any number of cores. You have an option of increasing the number of cores to 16 or improve rendering program so that the serial portion of the program is dropped to 10%. Which of the improvements should you choose?
b. Write a program that calculates the sum of absolute values of two signed numbers. The program must check the sign of each value individually and if the value is negative then change the sign. After both values have been converted to positive numbers then calculate the sum. The value is returned to caller in R0 so make sure that the result is written to R0 before pop. Copy the following code to your source file before main().


_attribute_(( naked )) int abs_sum(int a, int b) { // the values passed to your program are in registers // RO = a, R1 = b // write your code between push and pop instructions // make sure return value is in Ro after calculation asm volatile ( "push {r4, r5, r6, r7} " "loc1: mov r4, #0 " // execute compare instruction to set flags before conditional branch "beq loci " "pop {r4, r5, r6, r7} " "bx lr " ); } void fail() { printf("Failed "); } Add the following code to your main() and set a breakpoint in fail() to see if any of the tests fail. if(abs_sum(-9, 7) != 16) fail(); if(abs_sum( -19, -1) != 20) fail(); if(abs_sum(22, 5) != 27) fail(); if(abs_sum(8, 18) != 26) fail(); if(abs_sum (0, 7) != 7) fail(); if(abs_sum(-1, 0) != 1) fail(); _attribute_(( naked )) int abs_sum(int a, int b) { // the values passed to your program are in registers // RO = a, R1 = b // write your code between push and pop instructions // make sure return value is in Ro after calculation asm volatile ( "push {r4, r5, r6, r7} " "loc1: mov r4, #0 " // execute compare instruction to set flags before conditional branch "beq loci " "pop {r4, r5, r6, r7} " "bx lr " ); } void fail() { printf("Failed "); } Add the following code to your main() and set a breakpoint in fail() to see if any of the tests fail. if(abs_sum(-9, 7) != 16) fail(); if(abs_sum( -19, -1) != 20) fail(); if(abs_sum(22, 5) != 27) fail(); if(abs_sum(8, 18) != 26) fail(); if(abs_sum (0, 7) != 7) fail(); if(abs_sum(-1, 0) != 1) fail()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
