Skip to content

Commit

Permalink
Merge pull request eth-cscs#58 from eth-cscs/features/templatize_mini…
Browse files Browse the repository at this point in the history
…apps

Fixed bugs with command-line options in miniapps.
  • Loading branch information
kabicm authored Jun 23, 2020
2 parents 7d0fd6d + 9255eff commit 782d5d7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
27 changes: 16 additions & 11 deletions miniapp/pxgemm_miniapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,12 @@ int main(int argc, char **argv) {
std::cout << "COSMA(pxgemm_miniapp.cpp): WARNING: correctness checking enabled, setting `n_rep` to 1." << std::endl;
if (algorithm != "both") {
std::cout << "COSMA(pxgemm_miniapp.cpp): WARNING: correctness checking enabled, setting `algorithm` to `both`." << std::endl;
algorithm = "both";
}
}

std::vector<long> cosma_times(n_rep);
std::vector<long> scalapack_times(n_rep);
std::vector<long> cosma_times;
std::vector<long> scalapack_times;

bool result_correct = true;

Expand All @@ -184,7 +185,7 @@ int main(int argc, char **argv) {
MPI_Comm_size(MPI_COMM_WORLD, &P);

// check if processor grid corresponds to P
if (p_grid[0] * p_grid[0] != P) {
if (p_grid[0] * p_grid[1] != P) {
p_grid[0] = 1;
p_grid[1] = P;
if (rank == 0) {
Expand Down Expand Up @@ -342,17 +343,21 @@ int main(int argc, char **argv) {
// output times
// *****************
if (rank == 0) {
std::cout << "COSMA TIMES [ms] = ";
for (auto &time : cosma_times) {
std::cout << time << " ";
if (algorithm == "both" || algorithm == "cosma") {
std::cout << "COSMA TIMES [ms] = ";
for (auto &time : cosma_times) {
std::cout << time << " ";
}
std::cout << std::endl;
}
std::cout << std::endl;

std::cout << "SCALAPACK TIMES [ms] = ";
for (auto &time : scalapack_times) {
std::cout << time << " ";
if (algorithm == "both" || algorithm == "scalapack") {
std::cout << "SCALAPACK TIMES [ms] = ";
for (auto &time : scalapack_times) {
std::cout << time << " ";
}
std::cout << std::endl;
}
std::cout << std::endl;
}

if (test_correctness) {
Expand Down
16 changes: 8 additions & 8 deletions utils/pxgemm_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ bool benchmark_pxgemm(cosma::pxgemm_params<T>& params, MPI_Comm comm, int n_rep,
std::vector<long>& cosma_times, std::vector<long>& scalapack_times,
bool test_correctness = false, bool exit_blacs = false) {
assert(algorithm == "both" || algorithm == "cosma" || algorithm == "scalapack");
if (algorithm == "both" || "cosma") {
if (algorithm == "both" || algorithm == "cosma") {
cosma_times.resize(n_rep);
}
if (algorithm == "both" || "scalapack") {
if (algorithm == "both" || algorithm == "scalapack") {
scalapack_times.resize(n_rep);
}

Expand Down Expand Up @@ -271,10 +271,10 @@ bool benchmark_pxgemm(cosma::pxgemm_params<T>& params, MPI_Comm comm, int n_rep,
try {
a = std::vector<T>(size_a);
b = std::vector<T>(size_b);
if (algorithm == "both" || "cosma") {
if (algorithm == "both" || algorithm == "cosma") {
c_cosma = std::vector<T>(size_c);
}
if (algorithm == "both" || "scalapack") {
if (algorithm == "both" || algorithm == "scalapack") {
c_scalapack = std::vector<T>(size_c);
}
} catch (const std::bad_alloc& e) {
Expand Down Expand Up @@ -312,7 +312,7 @@ bool benchmark_pxgemm(cosma::pxgemm_params<T>& params, MPI_Comm comm, int n_rep,
fill_randomly(c_scalapack);
}

if (algorithm == "both" || "cosma") {
if (algorithm == "both" || algorithm == "cosma") {
// ***********************************
// run COSMA PDGEMM
// ***********************************
Expand All @@ -332,7 +332,7 @@ bool benchmark_pxgemm(cosma::pxgemm_params<T>& params, MPI_Comm comm, int n_rep,
cosma_times[i] = time;
}

if (algorithm == "both" || "scalapack") {
if (algorithm == "both" || algorithm == "scalapack") {
// ***********************************
// run ScaLAPACK PDGEMM
// ***********************************
Expand All @@ -353,10 +353,10 @@ bool benchmark_pxgemm(cosma::pxgemm_params<T>& params, MPI_Comm comm, int n_rep,
}
}

if (algorithm == "both" || "cosma") {
if (algorithm == "both" || algorithm == "cosma") {
std::sort(cosma_times.rbegin(), cosma_times.rend());
}
if (algorithm == "both" || "scalapack") {
if (algorithm == "both" || algorithm == "scalapack") {
std::sort(scalapack_times.rbegin(), scalapack_times.rend());
}

Expand Down

0 comments on commit 782d5d7

Please sign in to comment.