-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfft2d-skeleton.cc
62 lines (51 loc) · 2.01 KB
/
fft2d-skeleton.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Distributed two-dimensional Discrete FFT transform
// YOUR NAME HERE
// ECE8893 Project 1
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <signal.h>
#include <math.h>
#include <mpi.h>
#include "Complex.h"
#include "InputImage.h"
using namespace std;
void Transform2D(const char* inputFN)
{ // Do the 2D transform here.
// 1) Use the InputImage object to read in the Tower.txt file and
// find the width/height of the input image.
// 2) Use MPI to find how many CPUs in total, and which one
// this process is
// 3) Allocate an array of Complex object of sufficient size to
// hold the 2d DFT results (size is width * height)
// 4) Obtain a pointer to the Complex 1d array of input data
// 5) Do the individual 1D transforms on the rows assigned to your CPU
// 6) Send the resultant transformed values to the appropriate
// other processors for the next phase.
// 6a) To send and receive columns, you might need a separate
// Complex array of the correct size.
// 7) Receive messages from other processes to collect your columns
// 8) When all columns received, do the 1D transforms on the columns
// 9) Send final answers to CPU 0 (unless you are CPU 0)
// 9a) If you are CPU 0, collect all values from other processors
// and print out with SaveImageData().
InputImage image(inputFN); // Create the helper object for reading the image
// Step (1) in the comments is the line above.
// Your code here, steps 2-9
}
void Transform1D(Complex* h, int w, Complex* H)
{
// Implement a simple 1-d DFT using the double summation equation
// given in the assignment handout. h is the time-domain input
// data, w is the width (N), and H is the output array.
}
int main(int argc, char** argv)
{
string fn("Tower.txt"); // default file name
if (argc > 1) fn = string(argv[1]); // if name specified on cmd line
// MPI initialization here
Transform2D(fn.c_str()); // Perform the transform.
// Finalize MPI here
}