Question: 3. (exercise 1.3) Try to write pseudo-code for the tree-structured global sum illustrated in Figure 1.1. Assume the number of cores is a power of

3. (exercise 1.3) Try to write pseudo-code for the tree-structured global sum illustrated in Figure 1.1. Assume the number of cores is a power of two (1,2,4, 8,...). Hints: Use a variable divisor to determine whether a core should send its sum or receive and add. The divisor should start with the value 2 and be doubled after each iteration. Also use a variable core difference to deter- mine which core should be partnered with the current core. It should start with the value 1 and also be doubled after each iteration. For example, in the first iteration of divisor = 0 and 1 % divisor = 1, so 0 receives and adds, while 1 sends. Also, in the first iteration 0 + core difference = 1 and 1 - core_difference = 0, so 0 and 1 are paired in the first iteration. Cores 3. (exercise 1.3) Try to write pseudo-code for the tree-structured global sum illustrated in Figure 1.1. Assume the number of cores is a power of two (1,2,4, 8,...). Hints: Use a variable divisor to determine whether a core should send its sum or receive and add. The divisor should start with the value 2 and be doubled after each iteration. Also use a variable core difference to deter- mine which core should be partnered with the current core. It should start with the value 1 and also be doubled after each iteration. For example, in the first iteration of divisor = 0 and 1 % divisor = 1, so 0 receives and adds, while 1 sends. Also, in the first iteration 0 + core difference = 1 and 1 - core_difference = 0, so 0 and 1 are paired in the first iteration. Cores
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
