/********************************************************************** FFT The following program calculates the FFT of a given N numbers. P or 2^Log_P is the number of processes. For calculating the FFT of N nodes each process evaluates FFT of N/P numbers locally, and then communicates with other processes to evaluate the FFT of N numbers. For evaluating this FFT there are log(P) phases. In the ith phase jth process interchanges its data with j+2^i or j-2^i depending on j mod 2^i+1 < 2^i or not. Since each process communicates with only one communicator at each phase and there are only log P phases, each process is a part of log P communicators. These newly declared communicators have size 2. In all there are (P/2)log P communicators. For validity inverse FFT is calculated in the same manner on the evaluated FFT and a check at the end is done, as FFT^-1(FFT) gives identical values with a factor of N. cluster is N/P. In this case the N numbers given are 1 and hence after FFT and inverse FFT the final array would have all numbers as N. ***********************************************************************/ #include #include #include #include #define N 32768 #define Log_N 15 #define cluster 4096 #define Log_P 3 int power(int i, int j){ /* Evaluates i^j */ int k; int prod=1; for ( k = 0;k