Skip to content

Commit

Permalink
log with half
Browse files Browse the repository at this point in the history
  • Loading branch information
yhmtsai committed Oct 29, 2024
1 parent 3b67cc2 commit 3537d26
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 43 deletions.
2 changes: 1 addition & 1 deletion core/log/convergence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void Convergence<ValueType>::on_iteration_complete(


#define GKO_DECLARE_CONVERGENCE(_type) class Convergence<_type>
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_CONVERGENCE);
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE_WITH_HALF(GKO_DECLARE_CONVERGENCE);


} // namespace log
Expand Down
2 changes: 1 addition & 1 deletion core/log/papi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void Papi<ValueType>::on_iteration_complete(


#define GKO_DECLARE_PAPI(_type) class Papi<_type>
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_PAPI);
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE_WITH_HALF(GKO_DECLARE_PAPI);


} // namespace log
Expand Down
8 changes: 8 additions & 0 deletions core/log/solver_progress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ class SolverProgressStore : public SolverProgress {
run<gko::matrix::Dense<double>, gko::matrix::Dense<float>,
gko::matrix::Dense<std::complex<double>>,
gko::matrix::Dense<std::complex<float>>,
#if GINKGO_ENABLE_HALF
gko::matrix::Dense<gko::half>,
gko::matrix::Dense<std::complex<gko::half>>,
gko::WritableToMatrixData<gko::half, int32>,
gko::WritableToMatrixData<std::complex<gko::half>, int32>,
gko::WritableToMatrixData<gko::half, int64>,
gko::WritableToMatrixData<std::complex<gko::half>, int64>,
#endif
// fallback for other matrix types
gko::WritableToMatrixData<double, int32>,
gko::WritableToMatrixData<float, int32>,
Expand Down
2 changes: 1 addition & 1 deletion core/log/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ void Stream<ValueType>::on_iteration_complete(


#define GKO_DECLARE_STREAM(_type) class Stream<_type>
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_STREAM);
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE_WITH_HALF(GKO_DECLARE_STREAM);


} // namespace log
Expand Down
3 changes: 2 additions & 1 deletion core/test/log/convergence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class Convergence : public ::testing::Test {
gko::array<gko::stopping_status> status = {exec, 1};
};

TYPED_TEST_SUITE(Convergence, gko::test::ValueTypes, TypenameNameGenerator);
TYPED_TEST_SUITE(Convergence, gko::test::ValueTypesWithHalf,
TypenameNameGenerator);


TYPED_TEST(Convergence, CanGetEmptyData)
Expand Down
2 changes: 1 addition & 1 deletion core/test/log/papi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Papi : public ::testing::Test {
int eventset;
};

TYPED_TEST_SUITE(Papi, gko::test::ValueTypes, TypenameNameGenerator);
TYPED_TEST_SUITE(Papi, gko::test::ValueTypesWithHalf, TypenameNameGenerator);


TYPED_TEST(Papi, CatchesAllocationStarted)
Expand Down
3 changes: 2 additions & 1 deletion core/test/log/solver_progress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class SolverProgress : public ::testing::Test {
std::unique_ptr<Cg> solver;
};

TYPED_TEST_SUITE(SolverProgress, gko::test::ValueTypes, TypenameNameGenerator);
TYPED_TEST_SUITE(SolverProgress, gko::test::ValueTypesWithHalf,
TypenameNameGenerator);


TYPED_TEST(SolverProgress, TableWorks)
Expand Down
70 changes: 35 additions & 35 deletions core/test/log/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,17 +380,17 @@ TYPED_TEST(Stream, CatchesLinOpApplyStartedWithVerbose)
std::stringstream out;
auto logger = gko::log::Stream<TypeParam>::create(
gko::log::Logger::linop_apply_started_mask, out, true);
auto A = gko::initialize<Dense>({1.1}, exec);
auto b = gko::initialize<Dense>({-2.2}, exec);
auto x = gko::initialize<Dense>({3.3}, exec);
auto A = gko::initialize<Dense>({1.5}, exec);
auto b = gko::initialize<Dense>({-2.25}, exec);
auto x = gko::initialize<Dense>({3.125}, exec);

logger->template on<gko::log::Logger::linop_apply_started>(A.get(), b.get(),
x.get());

auto os = out.str();
GKO_ASSERT_STR_CONTAINS(os, "1.1");
GKO_ASSERT_STR_CONTAINS(os, "-2.2");
GKO_ASSERT_STR_CONTAINS(os, "3.3");
GKO_ASSERT_STR_CONTAINS(os, "1.5");
GKO_ASSERT_STR_CONTAINS(os, "-2.25");
GKO_ASSERT_STR_CONTAINS(os, "3.125");
}


Expand Down Expand Up @@ -429,17 +429,17 @@ TYPED_TEST(Stream, CatchesLinOpApplyCompletedWithVerbose)
std::stringstream out;
auto logger = gko::log::Stream<TypeParam>::create(
gko::log::Logger::linop_apply_completed_mask, out, true);
auto A = gko::initialize<Dense>({1.1}, exec);
auto b = gko::initialize<Dense>({-2.2}, exec);
auto x = gko::initialize<Dense>({3.3}, exec);
auto A = gko::initialize<Dense>({1.5}, exec);
auto b = gko::initialize<Dense>({-2.25}, exec);
auto x = gko::initialize<Dense>({3.125}, exec);

logger->template on<gko::log::Logger::linop_apply_completed>(
A.get(), b.get(), x.get());

auto os = out.str();
GKO_ASSERT_STR_CONTAINS(os, "1.1");
GKO_ASSERT_STR_CONTAINS(os, "-2.2");
GKO_ASSERT_STR_CONTAINS(os, "3.3");
GKO_ASSERT_STR_CONTAINS(os, "1.5");
GKO_ASSERT_STR_CONTAINS(os, "-2.25");
GKO_ASSERT_STR_CONTAINS(os, "3.125");
}


Expand Down Expand Up @@ -486,21 +486,21 @@ TYPED_TEST(Stream, CatchesLinOpAdvancedApplyStartedWithVerbose)
std::stringstream out;
auto logger = gko::log::Stream<TypeParam>::create(
gko::log::Logger::linop_advanced_apply_started_mask, out, true);
auto A = gko::initialize<Dense>({1.1}, exec);
auto alpha = gko::initialize<Dense>({-4.4}, exec);
auto b = gko::initialize<Dense>({-2.2}, exec);
auto A = gko::initialize<Dense>({1.5}, exec);
auto alpha = gko::initialize<Dense>({-4.75}, exec);
auto b = gko::initialize<Dense>({-2.25}, exec);
auto beta = gko::initialize<Dense>({-5.5}, exec);
auto x = gko::initialize<Dense>({3.3}, exec);
auto x = gko::initialize<Dense>({3.125}, exec);

logger->template on<gko::log::Logger::linop_advanced_apply_started>(
A.get(), alpha.get(), b.get(), beta.get(), x.get());

auto os = out.str();
GKO_ASSERT_STR_CONTAINS(os, "1.1");
GKO_ASSERT_STR_CONTAINS(os, "-4.4");
GKO_ASSERT_STR_CONTAINS(os, "-2.2");
GKO_ASSERT_STR_CONTAINS(os, "1.5");
GKO_ASSERT_STR_CONTAINS(os, "-4.75");
GKO_ASSERT_STR_CONTAINS(os, "-2.25");
GKO_ASSERT_STR_CONTAINS(os, "-5.5");
GKO_ASSERT_STR_CONTAINS(os, "3.3");
GKO_ASSERT_STR_CONTAINS(os, "3.125");
}


Expand Down Expand Up @@ -547,21 +547,21 @@ TYPED_TEST(Stream, CatchesLinOpAdvancedApplyCompletedWithVerbose)
std::stringstream out;
auto logger = gko::log::Stream<TypeParam>::create(
gko::log::Logger::linop_advanced_apply_completed_mask, out, true);
auto A = gko::initialize<Dense>({1.1}, exec);
auto alpha = gko::initialize<Dense>({-4.4}, exec);
auto b = gko::initialize<Dense>({-2.2}, exec);
auto A = gko::initialize<Dense>({1.5}, exec);
auto alpha = gko::initialize<Dense>({-4.75}, exec);
auto b = gko::initialize<Dense>({-2.25}, exec);
auto beta = gko::initialize<Dense>({-5.5}, exec);
auto x = gko::initialize<Dense>({3.3}, exec);
auto x = gko::initialize<Dense>({3.125}, exec);

logger->template on<gko::log::Logger::linop_advanced_apply_completed>(
A.get(), alpha.get(), b.get(), beta.get(), x.get());

auto os = out.str();
GKO_ASSERT_STR_CONTAINS(os, "1.1");
GKO_ASSERT_STR_CONTAINS(os, "-4.4");
GKO_ASSERT_STR_CONTAINS(os, "-2.2");
GKO_ASSERT_STR_CONTAINS(os, "1.5");
GKO_ASSERT_STR_CONTAINS(os, "-4.75");
GKO_ASSERT_STR_CONTAINS(os, "-2.25");
GKO_ASSERT_STR_CONTAINS(os, "-5.5");
GKO_ASSERT_STR_CONTAINS(os, "3.3");
GKO_ASSERT_STR_CONTAINS(os, "3.125");
}


Expand Down Expand Up @@ -782,11 +782,11 @@ TYPED_TEST(Stream, CatchesIterationsWithVerbose)
gko::solver::Bicgstab<TypeParam>::build()
.with_criteria(gko::stop::Iteration::build().with_max_iters(3u))
.on(exec);
auto solver = factory->generate(gko::initialize<Dense>({1.1}, exec));
auto solver = factory->generate(gko::initialize<Dense>({1.25}, exec));
auto right_hand_side = gko::initialize<Dense>({-5.5}, exec);
auto residual = gko::initialize<Dense>({-4.4}, exec);
auto solution = gko::initialize<Dense>({-2.2}, exec);
auto residual_norm = gko::initialize<Dense>({-3.3}, exec);
auto residual = gko::initialize<Dense>({-4.5}, exec);
auto solution = gko::initialize<Dense>({-2.25}, exec);
auto residual_norm = gko::initialize<Dense>({-3.125}, exec);
gko::array<gko::stopping_status> stop_status(exec, 1);

logger->template on<gko::log::Logger::iteration_complete>(
Expand All @@ -795,9 +795,9 @@ TYPED_TEST(Stream, CatchesIterationsWithVerbose)

auto os = out.str();
GKO_ASSERT_STR_CONTAINS(os, "-5.5");
GKO_ASSERT_STR_CONTAINS(os, "-4.4");
GKO_ASSERT_STR_CONTAINS(os, "-2.2");
GKO_ASSERT_STR_CONTAINS(os, "-3.3");
GKO_ASSERT_STR_CONTAINS(os, "-4.5");
GKO_ASSERT_STR_CONTAINS(os, "-2.25");
GKO_ASSERT_STR_CONTAINS(os, "-3.125");
GKO_ASSERT_STR_CONTAINS(os, "Finalized:")
}

Expand Down
3 changes: 2 additions & 1 deletion reference/test/log/convergence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ namespace {
template <typename T>
class Convergence : public ::testing::Test {};

TYPED_TEST_SUITE(Convergence, gko::test::ValueTypes, TypenameNameGenerator);
TYPED_TEST_SUITE(Convergence, gko::test::ValueTypesWithHalf,
TypenameNameGenerator);


TYPED_TEST(Convergence, CatchesCriterionCheckCompleted)
Expand Down
2 changes: 1 addition & 1 deletion reference/test/log/papi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Papi : public ::testing::Test {
int eventset;
};

TYPED_TEST_SUITE(Papi, gko::test::ValueTypes, TypenameNameGenerator);
TYPED_TEST_SUITE(Papi, gko::test::ValueTypesWithHalf, TypenameNameGenerator);


TYPED_TEST(Papi, CatchesCriterionCheckCompleted)
Expand Down

0 comments on commit 3537d26

Please sign in to comment.