Skip to content

Commit

Permalink
Fixed a bogus maybe-unitialized warning/error in release mode
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffburdick committed Mar 10, 2023
1 parent 9b5e56a commit 015908f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/matx/core/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ namespace matx
if constexpr (Rank() > 0) { \
_Pragma("unroll") \
for (int32_t i = 0; i < Rank(); i++) { \
index_t size = detail::get_expanded_size<Rank()>(op, i); \
[[maybe_unused]] index_t size = detail::get_expanded_size<Rank()>(op, i); \
MATX_ASSERT_STR(size == 0 || size == Size(i), matxInvalidSize, "incompatible op sizes:" + str()); \
} \
}
Expand Down
6 changes: 6 additions & 0 deletions include/matx/core/tensor_desc.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,13 @@ class tensor_desc_t {
return static_cast<stride_type>(0);
}

/* In release mode with O3 on g++ seems to give incorrect warnings on this line from Clone()
and clone(). It appears there's no valid code path that would cause this to be unitialized,
so we're ignoring the warning in this one spot. */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
return *(stride_.begin() + dim);
#pragma GCC diagnostic pop
}

/**
Expand Down
8 changes: 5 additions & 3 deletions include/matx/transforms/cub.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,16 @@ class matxCubPlan_t {
static inline void ReduceOutput(Func &&func, OutputOp &&out, InputOp &&in, BeginIter &&bi, EndIter &&ei) {
if constexpr (out.Rank() <= 1 && is_tensor_view_v<OutputOp>) {
if (out.IsContiguous()) {
MATX_ASSERT_STR_EXP(func(in, out.Data(), bi, ei), cudaSuccess, matxCudaError, "Error when calling CUB reduction function");
auto res = func(in, out.Data(), bi, ei);
MATX_ASSERT_STR_EXP(res, cudaSuccess, matxCudaError, "Error when calling CUB reduction function");
return;
}
}

detail::base_type_t<OutputOp> out_base = out;
auto iter = RandomOperatorOutputIterator{out_base};
MATX_ASSERT_STR_EXP(func(in, iter, bi, ei), cudaSuccess, matxCudaError, "Error when calling CUB reduction function");
auto res = func(in, iter, bi, ei);
MATX_ASSERT_STR_EXP(res, cudaSuccess, matxCudaError, "Error when calling CUB reduction function");
}

template <typename Func, typename OutputOp, typename InputOp>
Expand Down Expand Up @@ -1216,7 +1218,7 @@ inline void ExecSort(OutputTensor &a_out,
struct CubParamsKeyHash {
std::size_t operator()(const CubParams_t &k) const noexcept
{
uint64_t shash;
uint64_t shash = 0;
for (size_t r = 0; r < k.size.size(); r++) {
shash += std::hash<uint64_t>()(k.size[r]);
}
Expand Down

0 comments on commit 015908f

Please sign in to comment.