You are on page 1of 1

Prefix Sums

Problem: To calculate cumulative sum of an array given unlimited processors and resources and to minimize
the number of computational steps and the total number of instructions. It is assumed that we can perform only 1 kind of binary operation, namely addition of the form A+B=C which means that contents of Processor A and Processor B are added and stored in the Processor C. Moreover, we assume that concurrent read and write is not possible. Our goal is to optimize both the number of computational steps and the number of instructions. It is assumed that all instructions in a given step are completed before the subsequent step. The need for decreasing the number of instructions arises because: 1. To minimize the communication between processors. It is often seen that communication delay is usually much more than the computational delay which affects the total execution time. 2. To minimize power consumption in each processor. Using conventional algorithms, this can be achieved in log(n) steps but it takes too many instructions. Thereby, facing a lot of communication delay between processors. For instance, for n=20 where n is the number of processors we have, Number of Steps = 6 Total Number of Instructions = 33 10 1+2=2 3+4=4 5+6=6 7+8=8 9+10=10 11+12=12 13+14=14 15+16=16 17+18=18 19+20=20 6 2+3=3 2+4=4 6+8=8 10+12=12 14+16=16 18+20=20 4 4+5=5 4+6=6 4+8=8 12+16=16 5 6+7=7 8+9=9 8+10=10 8+12=12 8+16=16 6 10+11=11 12+13=13 12+14=14 16+17=17 16+18=18 16+20=20 2 14+15=15 18+19=19

This approach takes (2*log(n) 1) steps and around 2*n-log(n) instructions. The code is attached. It exploits bit manipulation techniques to identify when a processor needs to execute an operation. The code takes n as the number of processors as standard input and displays the total number of steps required. In the subsequent lines, it displays the number of instructions to be performed in each step followed by the steps itself.

Link to the code : http://paste.ubuntu.com/957392/


-Mukul Gupta 260/CO/09 COE-1

You might also like