Skip to content

Commit

Permalink
SIMD: suppress a uninitialized variable warning (kokkos#6294)
Browse files Browse the repository at this point in the history
* Added an extra branch in attempt to fix a spurious uninitialized variable warning

* Apply review feedback on simd/unit_tests/TestSIMD.cpp

Co-authored-by: Damien L-G <dalg24+github@gmail.com>

---------

Co-authored-by: Damien L-G <dalg24+github@gmail.com>
  • Loading branch information
ldh4 and dalg24 committed Jul 19, 2023
1 parent 1eb7c2d commit ba79dc4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions simd/unit_tests/TestSIMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,11 @@ void host_check_math_op_one_loader(UnaryOp unary_op, std::size_t n,
bool const loaded_arg = loader.host_load(args + i, nlanes, arg);
if (!loaded_arg) continue;
simd_type expected_result;
for (std::size_t lane = 0; lane < nlanes; ++lane) {
expected_result[lane] = unary_op.on_host_serial(T(arg[lane]));
// gcc 8.4.0 warns if using nlanes as upper bound about arg
// being uninitialized
for (std::size_t lane = 0; lane < simd_type::size(); ++lane) {
if (lane < nlanes)
expected_result[lane] = unary_op.on_host_serial(T(arg[lane]));
}
simd_type const computed_result = unary_op.on_host(arg);
host_check_equality(expected_result, computed_result, nlanes);
Expand Down

0 comments on commit ba79dc4

Please sign in to comment.