Skip to content

Commit

Permalink
Fixing the error that was happening only at the solo cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
eeprude committed Nov 23, 2023
1 parent 88cec7b commit 4450d20
Showing 1 changed file with 41 additions and 31 deletions.
72 changes: 41 additions & 31 deletions blas/unit_test/Test_Blas1_axpby_unification.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,45 +356,48 @@ void impl_test_axpby_mv_unification_compare(
(void)valueB; // Avoid "set but not used" error
int a_k(a.h_view.extent(0) == 1 ? 0 : k);
int b_k(b.h_view.extent(0) == 1 ? 0 : k);
if (b.h_view(b_k) == Kokkos::ArithTraits<tScalarB>::zero()) {
vanillaValue =
static_cast<ScalarTypeY>(a.h_view(a_k) * x.h_view(i, k));
} else {
vanillaValue =
static_cast<ScalarTypeY>(a.h_view(a_k) * x.h_view(i, k) +
b.h_view(b_k) * org_y.h_view(i, k));
}
#if 0
std::cout << "In impl_test_axpby_mv_unification_compare()"
<< ": i = " << i
<< ", k = " << k
<< ", a.h_view.extent(0) = " << a.h_view.extent(0)
<< ", a_k = " << a_k
<< ", b.h_view.extent(0) = " << b.h_view.extent(0)
<< ", b_k = " << b_k
<< ", a.h_view(a_k) = " << a.h_view(a_k)
<< ", x.h_view(i, k) = " << x.h_view(i, k)
<< ", b.h_view(b_k) = " << b.h_view(b_k)
<< ", org_y.h_view(i, k) = " << org_y.h_view(i, k)
<< std::endl;
#endif
vanillaValue =
static_cast<ScalarTypeY>(a.h_view(a_k) * x.h_view(i, k) +
b.h_view(b_k) * org_y.h_view(i, k));
} else {
int a_k(a.h_view.extent(0) == 1 ? 0 : k);
if (valueB == Kokkos::ArithTraits<tScalarB>::zero()) {
vanillaValue =
static_cast<ScalarTypeY>(a.h_view(a_k) * x.h_view(i, k));
} else {
vanillaValue = static_cast<ScalarTypeY>(
a.h_view(a_k) * x.h_view(i, k) + valueB * org_y.h_view(i, k));
}
vanillaValue = static_cast<ScalarTypeY>(
a.h_view(a_k) * x.h_view(i, k) + valueB * org_y.h_view(i, k));
}
} else {
if constexpr (bIsRank1) {
(void)valueB; // Avoid "set but not used" error
int b_k(b.h_view.extent(0) == 1 ? 0 : k);
if (b.h_view(b_k) == Kokkos::ArithTraits<tScalarB>::zero()) {
vanillaValue = static_cast<ScalarTypeY>(valueA * x.h_view(i, k));
} else {
vanillaValue = static_cast<ScalarTypeY>(
valueA * x.h_view(i, k) + b.h_view(b_k) * org_y.h_view(i, k));
}
vanillaValue = static_cast<ScalarTypeY>(
valueA * x.h_view(i, k) + b.h_view(b_k) * org_y.h_view(i, k));
} else {
if (valueB == Kokkos::ArithTraits<tScalarB>::zero()) {
vanillaValue = static_cast<ScalarTypeY>(valueA * x.h_view(i, k));
} else {
vanillaValue = static_cast<ScalarTypeY>(
valueA * x.h_view(i, k) + valueB * org_y.h_view(i, k));
}
vanillaValue = static_cast<ScalarTypeY>(
valueA * x.h_view(i, k) + valueB * org_y.h_view(i, k));
}
}

EXPECT_NEAR_KK(vanillaValue, y.h_view(i, k), 2. * max_error);
#if 0
std::cout << "In impl_test_axpby_mv_unification_compare(1)"
<< ": i = " << i
<< ", k = " << k
<< ", y.h_view(i, k) = " << y.h_view(i, k)
<< ", vanillaValue = " << vanillaValue
<< std::endl;
#endif
EXPECT_NEAR_KK(vanillaValue, y.h_view(i, k), 3. * max_error);
}
}
} else {
Expand Down Expand Up @@ -451,7 +454,14 @@ void impl_test_axpby_mv_unification_compare(
} else {
EXPECT_NE(y.h_view(i, k), Kokkos::ArithTraits<ScalarTypeY>::nan());
}

#if 0
std::cout << "In impl_test_axpby_mv_unification_compare(2)"
<< ": i = " << i
<< ", k = " << k
<< ", y.h_view(i, k) = " << y.h_view(i, k)
<< ", vanillaValue = " << vanillaValue
<< std::endl;
#endif
EXPECT_NEAR_KK(vanillaValue, y.h_view(i, k), 2. * max_error);
}
}
Expand Down Expand Up @@ -1061,7 +1071,7 @@ void impl_test_axpby_mv_unification(int const N, int const K) {
// in which the result is computed.
using MagnitudeB = typename Kokkos::ArithTraits<tScalarB>::mag_type;
MagnitudeB const eps = Kokkos::ArithTraits<tScalarB>::epsilon();
MagnitudeB const max_val = 100;
MagnitudeB const max_val = 10;
MagnitudeB const max_error =
static_cast<MagnitudeB>(
Kokkos::ArithTraits<tScalarA>::abs(valuesA[valuesA.size() - 1]) +
Expand Down

0 comments on commit 4450d20

Please sign in to comment.