stuff
This commit is contained in:
@@ -41,7 +41,7 @@ Matrix getCompleteInitialCondition(int n) {
|
||||
return getInitialCondition(n, 0, 1);
|
||||
}
|
||||
|
||||
Matrix run(Jacobi& jacobi, const Matrix& init, double eps, int maxNumIter) {
|
||||
Matrix run(Jacobi &jacobi, const Matrix &init, double eps, int maxNumIter) {
|
||||
auto [m, dist, nIter] = jacobi.run(init, eps, maxNumIter);
|
||||
int rank;
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
||||
@@ -52,9 +52,7 @@ Matrix run(Jacobi& jacobi, const Matrix& init, double eps, int maxNumIter) {
|
||||
return m;
|
||||
}
|
||||
|
||||
double benchmark(Jacobi& jacobi,
|
||||
const Matrix& init,
|
||||
double eps,
|
||||
double benchmark(Jacobi &jacobi, const Matrix &init, double eps,
|
||||
int maxNumIter) {
|
||||
auto start = std::chrono::system_clock::now();
|
||||
jacobi.run(init, eps, maxNumIter);
|
||||
@@ -142,7 +140,7 @@ void runParallel(int n, double eps, int maxNumIter) {
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int main(int argc, char *argv[]) {
|
||||
MPI_Init(&argc, &argv);
|
||||
|
||||
int rank, numProc;
|
||||
@@ -158,26 +156,25 @@ int main(int argc, char* argv[]) {
|
||||
// Result is saved to file.
|
||||
// Use this to graphically verify the correctness of the parallel
|
||||
// implementation.
|
||||
//runSerial(n, eps, maxNumIter);
|
||||
// runSerial(n, eps, maxNumIter);
|
||||
|
||||
runParallel(n, eps, maxNumIter);
|
||||
|
||||
|
||||
// Run the benchmark
|
||||
//double serialTime = 0;
|
||||
double parallelTime = 0;
|
||||
// double serialTime = 0;
|
||||
// double parallelTime = 0;
|
||||
|
||||
//serialTime = serialBenchmark(n, eps, maxNumIter);
|
||||
parallelTime = parallelBenchmark(n, eps, maxNumIter);
|
||||
|
||||
if (rank == 0) {
|
||||
//std::cout << "Serial time: " << serialTime << "ms" << std::endl;
|
||||
std::cout << "Serial time: ms" << std::endl;
|
||||
std::cout << "Parallel time: " << parallelTime << "ms" << std::endl;
|
||||
//std::cout << "Speedup: " << serialTime / parallelTime << std::endl;
|
||||
std::ofstream fout("benchmark.txt", std::ios::app);
|
||||
fout << numProc << "\t" << parallelTime << "\n";
|
||||
}
|
||||
// serialTime = serialBenchmark(n, eps, maxNumIter);
|
||||
// parallelTime = parallelBenchmark(n, eps, maxNumIter);
|
||||
//
|
||||
// if (rank == 0) {
|
||||
// //std::cout << "Serial time: " << serialTime << "ms" << std::endl;
|
||||
// std::cout << "Serial time: ms" << std::endl;
|
||||
// std::cout << "Parallel time: " << parallelTime << "ms" << std::endl;
|
||||
// //std::cout << "Speedup: " << serialTime / parallelTime << std::endl;
|
||||
// std::ofstream fout("benchmark.txt", std::ios::app);
|
||||
// fout << numProc << "\t" << parallelTime << "\n";
|
||||
// }
|
||||
|
||||
MPI_Finalize();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ Jacobi::Result JacobiMPI::run(const Matrix &init, double epsilon,
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
||||
MPI_Comm_size(MPI_COMM_WORLD, &numProc);
|
||||
std::cout << "rank: " << rank << std::endl;
|
||||
std::cout << "numProc: " << numProc << std::endl;
|
||||
// std::cout << "numProc: " << numProc << std::endl;
|
||||
|
||||
std::vector<Matrix> phi(2, init);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user