From 18d577f5046f50d302e88efcf4ddd23f6b6b9aea Mon Sep 17 00:00:00 2001 From: kai Date: Sun, 1 Jun 2025 14:39:52 +0200 Subject: [PATCH] remove unnecessary --- lab10/jacobi/jacobi_main.cpp | 30 +++++++++++++++--------------- lab10/jacobi/jacobi_mpi.cpp | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lab10/jacobi/jacobi_main.cpp b/lab10/jacobi/jacobi_main.cpp index 58b08fc..82c627b 100644 --- a/lab10/jacobi/jacobi_main.cpp +++ b/lab10/jacobi/jacobi_main.cpp @@ -156,25 +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); + // 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(); } diff --git a/lab10/jacobi/jacobi_mpi.cpp b/lab10/jacobi/jacobi_mpi.cpp index 6accbe3..9b4c4f4 100644 --- a/lab10/jacobi/jacobi_mpi.cpp +++ b/lab10/jacobi/jacobi_mpi.cpp @@ -20,7 +20,7 @@ Jacobi::Result JacobiMPI::run(const Matrix &init, double epsilon, int rank, numProc; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &numProc); - std::cout << "rank: " << rank << std::endl; + // std::cout << "rank: " << rank << std::endl; // std::cout << "numProc: " << numProc << std::endl; std::vector phi(2, init); @@ -31,7 +31,7 @@ Jacobi::Result JacobiMPI::run(const Matrix &init, double epsilon, const int neighborUpper = rank - 1; const int neighborLower = rank + 1; - std::cout << neighborUpper << ":" << neighborLower << std::endl; + // std::cout << neighborUpper << ":" << neighborLower << std::endl; const int indexRowGlobalStart = (rank * numRows); const int indexRowGlobalEnd = (rank * numRows) + (numRows - 1);