Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a bogus maybe-unitialized warning/error in release mode #389

Merged
merged 1 commit into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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