Skip to content

Commit 307e9e4

Browse files
committed
disable the test when bfloat16 can not pass
1 parent afd1d9f commit 307e9e4

9 files changed

Lines changed: 50 additions & 15 deletions

File tree

core/test/mpi/base/bindings.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ TYPED_TEST(MpiBindings, CanAccumulateValues)
395395
{
396396
// one-side accumlation only supports native type
397397
SKIP_IF_HALF(TypeParam);
398+
SKIP_IF_BFLOAT16(TypeParam);
398399
using window = gko::experimental::mpi::window<TypeParam>;
399400
auto comm = gko::experimental::mpi::communicator(MPI_COMM_WORLD);
400401
auto my_rank = comm.rank();
@@ -445,6 +446,7 @@ TYPED_TEST(MpiBindings, CanNonBlockingAccumulateValues)
445446
{
446447
// one-side accumlation only supports native type
447448
SKIP_IF_HALF(TypeParam);
449+
SKIP_IF_BFLOAT16(TypeParam);
448450
using window = gko::experimental::mpi::window<TypeParam>;
449451
auto comm = gko::experimental::mpi::communicator(MPI_COMM_WORLD);
450452
auto my_rank = comm.rank();
@@ -624,6 +626,7 @@ TYPED_TEST(MpiBindings, CanGetAccumulateValuesWithLockAll)
624626
{
625627
// one-side accumlation only supports native type
626628
SKIP_IF_HALF(TypeParam);
629+
SKIP_IF_BFLOAT16(TypeParam);
627630
using window = gko::experimental::mpi::window<TypeParam>;
628631
auto comm = gko::experimental::mpi::communicator(MPI_COMM_WORLD);
629632
auto my_rank = comm.rank();
@@ -672,6 +675,7 @@ TYPED_TEST(MpiBindings, CanNonBlockingGetAccumulateValuesWithLockAll)
672675
{
673676
// one-side accumlation only supports native type
674677
SKIP_IF_HALF(TypeParam);
678+
SKIP_IF_BFLOAT16(TypeParam);
675679
using window = gko::experimental::mpi::window<TypeParam>;
676680
auto comm = gko::experimental::mpi::communicator(MPI_COMM_WORLD);
677681
auto my_rank = comm.rank();
@@ -727,6 +731,7 @@ TYPED_TEST(MpiBindings, CanFetchAndOperate)
727731
{
728732
// one-side operation only supports native type
729733
SKIP_IF_HALF(TypeParam);
734+
SKIP_IF_BFLOAT16(TypeParam);
730735
using window = gko::experimental::mpi::window<TypeParam>;
731736
auto comm = gko::experimental::mpi::communicator(MPI_COMM_WORLD);
732737
auto my_rank = comm.rank();

core/test/utils.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,5 +487,12 @@ struct TupleTypenameNameGenerator {
487487
"This assert is used to counter the false positive extra " \
488488
"semi-colon warnings")
489489

490+
#define SKIP_IF_BFLOAT16(type) \
491+
if (std::is_same<gko::remove_complex<type>, gko::bfloat16>::value) { \
492+
GTEST_SKIP() << "Skip due to float16 mode"; \
493+
} \
494+
static_assert(true, \
495+
"This assert is used to counter the false positive extra " \
496+
"semi-colon warnings")
490497

491498
#endif // GKO_CORE_TEST_UTILS_HPP_

reference/test/preconditioner/jacobi_kernels.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,8 @@ TYPED_TEST(Jacobi, AvoidsPrecisionsThatOverflow)
615615
auto precision = std::is_same<gko::remove_complex<T>, float>::value
616616
? gko::precision_reduction(0, 2) // float
617617
: gko::precision_reduction(1, 1); // double
618-
if (std::is_same<gko::remove_complex<T>, gko::float16>::value) {
618+
if (std::is_same<gko::remove_complex<T>, gko::float16>::value ||
619+
std::is_same<gko::remove_complex<T>, gko::bfloat16>::value) {
619620
precision = gko::precision_reduction(2, 0);
620621
}
621622
EXPECT_EQ(prec[0], precision);

reference/test/reorder/mc64_kernels.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,8 @@ TYPED_TEST(Mc64, CreatesCorrectPermutationAndScalingLargeExampleProduct)
391391
// to be invalid_index after the kernel such that scale_permute gives
392392
// segmentation fault.
393393
SKIP_IF_HALF(value_type);
394+
// rounding error for bfloat16
395+
SKIP_IF_BFLOAT16(value_type);
394396
// read input data
395397
std::ifstream mtx_stream{gko::matrices::location_nontrivial_mc64_example};
396398
auto mtx = gko::share(gko::read<matrix_type>(mtx_stream, this->ref));

reference/test/solver/batch_bicgstab_kernels.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ TYPED_TEST(BatchBicgstab, StencilSystemLoggerLogsResidual)
111111
ASSERT_LE(
112112
res_log_array[i] / this->linear_system.host_rhs_norm->at(i, 0, 0),
113113
this->solver_settings.residual_tol);
114-
if (!std::is_same<real_type, gko::float16>::value) {
114+
if (!std::is_same<real_type, gko::float16>::value &&
115+
!std::is_same<real_type, gko::bfloat16>::value) {
115116
// There is no guarantee of this condition. We disable this check in
116117
// float16.
117118
ASSERT_NEAR(res_log_array[i],
@@ -303,6 +304,8 @@ TYPED_TEST(BatchBicgstab, CanSolveDenseHpdSystem)
303304
// distribution, the solver can not solve the hpd matrix even with single
304305
// precision
305306
SKIP_IF_HALF(value_type);
307+
// TODO: the tol here is already smaller than epsilon of bfloat16
308+
SKIP_IF_BFLOAT16(value_type);
306309
const real_type tol = 1e-5;
307310
const int max_iters = 1000;
308311
auto solver_factory =

reference/test/solver/batch_cg_kernels.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,10 @@ TYPED_TEST(BatchCg, StencilSystemLoggerLogsResidual)
108108
ASSERT_LE(
109109
res_log_array[i] / this->linear_system.host_rhs_norm->at(i, 0, 0),
110110
this->solver_settings.residual_tol);
111-
if (!std::is_same<real_type, gko::float16>::value) {
111+
if (!std::is_same<real_type, gko::float16>::value &&
112+
!std::is_same<real_type, gko::bfloat16>::value) {
112113
// There is no guarantee of this condition. We disable this check in
113-
// half.
114+
// half and bfloat16.
114115
ASSERT_NEAR(res_log_array[i],
115116
res.host_res_norm->get_const_values()[i],
116117
10 * this->eps);
@@ -149,6 +150,8 @@ TYPED_TEST(BatchCg, ApplyLogsResAndIters)
149150
// distribution, the solver can not solve the hpd matrix even with single
150151
// precision
151152
SKIP_IF_HALF(value_type);
153+
// TODO: the tol here is already smaller than epsilon of bfloat16
154+
SKIP_IF_BFLOAT16(value_type);
152155
const real_type tol = 1e-6;
153156
const int max_iters = 1000;
154157
auto solver_factory =
@@ -194,6 +197,8 @@ TYPED_TEST(BatchCg, CanSolveHpdSystem)
194197
// distribution, the solver can not solve the hpd matrix even with single
195198
// precision
196199
SKIP_IF_HALF(value_type);
200+
// TODO: the tol here is already less than epsilon of bfloat16
201+
SKIP_IF_BFLOAT16(value_type);
197202
const real_type tol = 1e-6;
198203
const int max_iters = 1000;
199204
auto solver_factory =

reference/test/solver/bicgstab_kernels.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
1+
// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
22
//
33
// SPDX-License-Identifier: BSD-3-Clause
44

@@ -588,6 +588,8 @@ TYPED_TEST(Bicgstab, SolvesBigDenseSystemForDivergenceCheck1)
588588
// beta encounters huge value out of the half-precision range in the first
589589
// part of the second iteration
590590
SKIP_IF_HALF(value_type);
591+
// rounding error for bfloat16
592+
SKIP_IF_BFLOAT16(value_type);
591593
auto half_tol = std::sqrt(r<value_type>::value);
592594
std::shared_ptr<Mtx> locmtx =
593595
gko::initialize<Mtx>({{-19.0, 47.0, -41.0, 35.0, -21.0, 71.0},
@@ -619,6 +621,8 @@ TYPED_TEST(Bicgstab, SolvesBigDenseSystemForDivergenceCheck2)
619621
// beta encounters huge value out of the half-precision range in the first
620622
// part of second iteration
621623
SKIP_IF_HALF(value_type);
624+
// rounding error for bfloat16
625+
SKIP_IF_BFLOAT16(value_type);
622626
auto half_tol = std::sqrt(r<value_type>::value);
623627
std::shared_ptr<Mtx> locmtx =
624628
gko::initialize<Mtx>({{-19.0, 47.0, -41.0, 35.0, -21.0, 71.0},

reference/test/solver/idr_kernels.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
1+
// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
22
//
33
// SPDX-License-Identifier: BSD-3-Clause
44

@@ -330,6 +330,8 @@ TYPED_TEST(Idr, SolvesBigDenseSystemForDivergenceCheck1)
330330
// the internal vector t will be too large in the first run and then out of
331331
// the half precision range.
332332
SKIP_IF_HALF(value_type);
333+
// rounding error for bfloat16
334+
SKIP_IF_BFLOAT16(value_type);
333335
auto half_tol = std::sqrt(r<value_type>::value);
334336
std::shared_ptr<Mtx> locmtx =
335337
gko::initialize<Mtx>({{-19.0, 47.0, -41.0, 35.0, -21.0, 71.0},
@@ -369,6 +371,8 @@ TYPED_TEST(Idr, SolvesBigDenseSystemForDivergenceCheck2)
369371
// the internal vector t will be too large in the first run and then out of
370372
// the half precision range.
371373
SKIP_IF_HALF(value_type);
374+
// rounding error for bfloat16
375+
SKIP_IF_BFLOAT16(value_type);
372376
auto half_tol = std::sqrt(r<value_type>::value);
373377
std::shared_ptr<Mtx> locmtx =
374378
gko::initialize<Mtx>({{-19.0, 47.0, -41.0, 35.0, -21.0, 71.0},

test/matrix/fbcsr_kernels.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
1+
// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
22
//
33
// SPDX-License-Identifier: BSD-3-Clause
44

@@ -128,9 +128,10 @@ TYPED_TEST(Fbcsr, SpmvIsEquivalentToRefSorted)
128128
using Dense = typename TestFixture::Dense;
129129
using value_type = typename Mtx::value_type;
130130
if (this->exec->get_master() != this->exec) {
131-
// FBCSR on accelerator does not have half precision apply through
132-
// vendor libraries.
131+
// FBCSR on accelerator does not have half/bfloat16 precision apply
132+
// through vendor libraries.
133133
SKIP_IF_HALF(value_type);
134+
SKIP_IF_BFLOAT16(value_type);
134135
}
135136
auto drand = gko::clone(this->exec, this->rsorted);
136137
auto x =
@@ -155,9 +156,10 @@ TYPED_TEST(Fbcsr, SpmvMultiIsEquivalentToRefSorted)
155156
using Dense = typename TestFixture::Dense;
156157
using value_type = typename Mtx::value_type;
157158
if (this->exec->get_master() != this->exec) {
158-
// FBCSR on accelerator does not have half precision apply through
159-
// vendor libraries.
159+
// FBCSR on accelerator does not have half/bfloat16 precision apply
160+
// through vendor libraries.
160161
SKIP_IF_HALF(value_type);
162+
SKIP_IF_BFLOAT16(value_type);
161163
}
162164
auto drand = gko::clone(this->exec, this->rsorted);
163165
auto x =
@@ -183,9 +185,10 @@ TYPED_TEST(Fbcsr, AdvancedSpmvIsEquivalentToRefSorted)
183185
using value_type = typename TestFixture::value_type;
184186
using real_type = typename TestFixture::real_type;
185187
if (this->exec->get_master() != this->exec) {
186-
// FBCSR on accelerator does not have half precision apply through
187-
// vendor libraries.
188+
// FBCSR on accelerator does not have half/bfloat16 precision apply
189+
// through vendor libraries.
188190
SKIP_IF_HALF(value_type);
191+
SKIP_IF_BFLOAT16(value_type);
189192
}
190193
auto drand = gko::clone(this->exec, this->rsorted);
191194
auto x =
@@ -218,9 +221,10 @@ TYPED_TEST(Fbcsr, AdvancedSpmvMultiIsEquivalentToRefSorted)
218221
using value_type = typename TestFixture::value_type;
219222
using real_type = typename TestFixture::real_type;
220223
if (this->exec->get_master() != this->exec) {
221-
// FBCSR on accelerator does not have half precision apply through
222-
// vendor libraries.
224+
// FBCSR on accelerator does not have half/bfloat16 precision apply
225+
// through vendor libraries.
223226
SKIP_IF_HALF(value_type);
227+
SKIP_IF_BFLOAT16(value_type);
224228
}
225229
auto drand = gko::clone(this->exec, this->rsorted);
226230
auto x =

0 commit comments

Comments
 (0)