Skip to content

Commit

Permalink
separating cases to reuse result var
Browse files Browse the repository at this point in the history
  • Loading branch information
august-knox committed Feb 19, 2025
1 parent a2b62b0 commit defb6cc
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ std::vector<std::vector<double>> run_all(std::unique_ptr<Stream<T>>& stream, T&

{
switch(b.id) {
case BenchId::Copy:
case BenchId::Copy: {
#ifdef ENABLE_CALIPER
CALI_MARK_BEGIN("Copy");
#endif
Expand All @@ -168,8 +168,10 @@ std::vector<std::vector<double>> run_all(std::unique_ptr<Stream<T>>& stream, T&
CALI_MARK_END("Copy");
#endif
return result;
break;
}

case BenchId::Mul:
case BenchId::Mul: {
#ifdef ENABLE_CALIPER
CALI_MARK_BEGIN("Mul");
#endif
Expand All @@ -178,8 +180,10 @@ std::vector<std::vector<double>> run_all(std::unique_ptr<Stream<T>>& stream, T&
CALI_MARK_END("Mul");
#endif
return result;
break;
}

case BenchId::Add:
case BenchId::Add: {
#ifdef ENABLE_CALIPER
CALI_MARK_BEGIN("Add");
#endif
Expand All @@ -188,18 +192,22 @@ std::vector<std::vector<double>> run_all(std::unique_ptr<Stream<T>>& stream, T&
CALI_MARK_END("Add");
#endif
return result;
break;
}

case BenchId::Triad:
case BenchId::Triad: {
#ifdef ENABLE_CALIPER
CALI_MARK_BEGIN("Triad");
#endif
auto result = stream->triad();
#ifdef ENABLE_CALIPER
CALI_MARK_END("Triad");
#endif
return result;
return result;
break;
}

case BenchId::Dot:
case BenchId::Dot: {
#ifdef ENABLE_CALIPER
CALI_MARK_BEGIN("Dot");
#endif
Expand All @@ -208,8 +216,10 @@ std::vector<std::vector<double>> run_all(std::unique_ptr<Stream<T>>& stream, T&
CALI_MARK_END("Dot");
#endif
return sum;
break;
}

case BenchId::Nstream:
case BenchId::Nstream: {
#ifdef ENABLE_CALIPER
CALI_MARK_BEGIN("Nstream");
#endif
Expand All @@ -218,6 +228,9 @@ std::vector<std::vector<double>> run_all(std::unique_ptr<Stream<T>>& stream, T&
CALI_MARK_END("Nstream");
#endif
return result;
break;
}

default:
std::cerr << "Unimplemented benchmark: " << b.label << std::endl;
abort();
Expand Down

0 comments on commit defb6cc

Please sign in to comment.