Question: Let us analyze the relative performance of using conditional data transfers versus conditional control transfers for the programs you wrote for Problems 4.5 and 4.6.

Let us analyze the relative performance of using conditional data transfers versus conditional control transfers for the programs you wrote for Problems 4.5 and 4.6. Assume that we are using these programs to compute the sum of the absolute values of a very long array, and so the overall performance is determined largely by the number of cycles required by the inner loop. Assume that our jump instructions are predicted as being taken, and that around 50% of the array values are positive.

A. On average, how many instructions are executed in the inner loops of the two programs?

B. On average, how many bubbles would be injected into the inner loops of the two programs?

C. What is the average number of clock cycles required per array element for the two programs?

Problems 4.5

Modify the Y86-64 code for the sum function (Figure 4.6) to implement a function absSum that computes the sum of absolute values of an array. Use a conditional jump instruction within your inner loop.

Problems 4.6

Modify the Y86-64 code for the sum function (Figure 4.6) to implement a function  absSum that computes the sum of absolute values of an array. Use a conditional  move instruction within your inner loop.

Figure 4.6

x86-64 code 1 2 3 4 5 6 7 8 9 10 11 1 2 3 5 7 9 10 11 long sun(long start, long count) start in %rdi, count

x86-64 code 1 2 3 4 5 6 7 8 9 10 11 1 2 3 5 7 9 10 11 long sun(long start, long count) start in Erdi, count in irsi 12 13 14 sum: novl Y86-64 code jap L3: addq addq subq L2: testq jne rep: ret So, Zeax L2 (%rd1). %rax $8. %rdi $1. %rsi %rai, rai L3 test: irnova $8,%r8 irmovq $1.%r9 xorq %rax. %rax andq Xrsi,%rsi jap test loop: mrmong (Krd1).Xr10 addq %r10.%rax addq %r8.%rdi subq %r9.%rai 0 Goto test jne loop ret 30.0 loop: Add start to sum long sum(long start, long count) start in %rdi, count in rai sun: start++ count test: Test sun If 1-0. goto loop Return Constant 8 Constant 1 sum - 0 Set CC Goto test Get start Add to sus start++ count-- Set CC Stop when 0 Return

Step by Step Solution

3.41 Rating (154 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

This simplified analysis where we focus on the inner loop is a useful way to estimate program perfor... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Systems A Programmers Perspective Questions!