Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified Cholesky output #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,17 @@ Number of repetitions: 2
TIMINGS [ms] = 353 186
==========================

# Example for Cholesky (output is structured in the same way):
# Example for Cholesky:
mpirun -n 4 ./cholesky -N 1200 -b 128 --p_grid=2,2 -r 2
==========================
PROBLEM PARAMETERS:
==========================
Matrix size: 1200
Block size: 128
Processor grid: 2 x 2
--------------------------
86ms 6.69767GFlop/s 1200 (128, 128) (2, 2)
11ms 52.3636GFlop/s 1200 (128, 128) (2, 2)
```

## Generating and Running the Scripts on Daint
Expand All @@ -44,3 +53,4 @@ Each `.sh` file contains all jobs for one specific processor size.
- Tal Ben Nun (talbn@inf.ethz.ch)
- Jens Eirik Saethre (saethrej@ethz.ch)
- Andre Gaillard (andrega@ethz.ch)
- Raffaele Solcà (rasolca@cscs.ch)
61 changes: 40 additions & 21 deletions cholesky.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,44 @@ std::pair<int, int> getProcessorGrid(int P)
}

/**
* @brief prints the timings to the desired stream
* @brief prints the parameters to the given stream
* @param out the desired stream (e.g. std::cout or a file)
* @param timings the vector containing the timings
* @param N the matrix dimension
* @param v the tile size
* @param PX the number of processors in x-direction on the grid
* @param PY the number of processors in y-direction on the grid
*/
void printTimings(std::vector<double> &timings, std::ostream &out, int N, int v, int PX, int PY)
void printTimingPreamble(std::ostream &out, int N, int v, int PX, int PY)
{
out << "==========================" << std::endl;
out << " PROBLEM PARAMETERS:" << std::endl;
out << "==========================" << std::endl;
out << "Matrix size: " << N << std::endl;
out << "Block size: " << v << std::endl;
out << "Processor grid: " << PX << " x " << PY << std::endl;
out << "Number of repetitions: " << timings.size() << std::endl;
out << "--------------------------" << std::endl;
out << "TIMINGS [ms] = ";
for (auto &time : timings) {
out << time << " ";
}
out << std::endl;
out << "==========================" << std::endl;
}

/**
* @brief prints the timings to the desired stream
* @param out the desired stream (e.g. std::cout or a file)
* @param time elapsed time in milliseconds
* @param N the matrix dimension
* @param v the tile size
* @param PX the number of processors in x-direction on the grid
* @param PY the number of processors in y-direction on the grid
*/
void printTiming(double time, std::ostream &out, int N, int v, int PX, int PY)
{
// For complex cases the prefactor should be 4/3!
double flop = 1. / 3. * N * N * N;

// Note: time is in milliseconds
auto gflops = flop / time / 1e6;
out << " " << time << "ms"
<< " " << gflops << "GFlop/s"
<< " " << N << " (" << v << ", " << v << ") (" << PX << ", " << PY << ")"
<< std::endl;
}

/**
Expand Down Expand Up @@ -187,9 +201,13 @@ int main(int argc, char* argv[])
return value;
};

// create a vector for timings
std::vector<double> timings;
timings.reserve(rep);
if (rank == 0) {
printTimingPreamble(std::cout, N, v, PX, PY);

// if you want to print the results to a file, uncomment the following: (1/3)
//std::ofstream output("your-filename.txt", std::ios::out);
//printTimingPreamble(output, N, v, PX, PY);
}

// perform the cholesky factorization rep times and time it
for (size_t i = 0; i < rep; ++i) {
Expand All @@ -206,24 +224,25 @@ int main(int argc, char* argv[])

// check for errors that occured, and if so terminate
if (rank == 0 && info != 0) {
std::cout << "Error in dptorf, value of info: " << -info << std::endl;
std::cout << "Error in dpotrf, value of info: " << -info << std::endl;

Cblacs_gridexit(ctx);
Cblacs_exit(1);
MPI_Comm_free(&world);
MPI_Finalize();
return -1;
}
timings.push_back(timeInMS);
// let rank 0 output the timing values
if (rank == 0) {
printTiming(timeInMS, std::cout, N, v, PX, PY);

// if you want to print the results to a file, uncomment the following: (2/3)
//printTiming(timeInMS, output, N, v, PX, PY);
}
}

// let rank 0 output the timing values
if (rank == 0) {
printTimings(timings, std::cout, N, v, PX, PY);

// if you want to print the results to a file, uncomment the following:
//std::ofstream output("your-filename.txt", std::ios::out);
//printTimings(timings, output, N, nb, prows, pcols);
// if you want to print the results to a file, uncomment the following: (3/3)
//output.close();
}

Expand Down