Skip to content

Commit

Permalink
Address inspect tool
Browse files Browse the repository at this point in the history
- missing includes
- prevent max/min being expanded as macros

Signed-off-by: Shreyas Atre <shreyasatre16@gmail.com>
  • Loading branch information
SAtacker committed Dec 18, 2024
1 parent 520f161 commit 6f2ce12
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <hpx/parallel/util/loop.hpp>

#include <cstddef>
#include <cstring>
#include <limits>
#include <type_traits>
#include <utility>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <cmath>
#include <cstdint>
#include <limits>
#include <type_traits>
#include <vector>

namespace hpx::parallel::detail::rfa {
template <typename F>
Expand Down Expand Up @@ -365,7 +367,7 @@ namespace hpx::parallel::detail::rfa {
else
{
std::frexp(x, &exp);
return std::max((MAX_EXP - exp) / BIN_WIDTH, MAXINDEX);
return (std::max)((MAX_EXP - exp) / BIN_WIDTH, MAXINDEX);
}
}
return ((MAX_EXP + EXP_BIAS) - exp) / BIN_WIDTH;
Expand Down Expand Up @@ -564,8 +566,8 @@ namespace hpx::parallel::detail::rfa {
{
scale_down = std::ldexp(0.5, 1 - (2 * MANT_DIG - BIN_WIDTH));
scale_up = std::ldexp(0.5, 1 + (2 * MANT_DIG - BIN_WIDTH));
scaled = std::max(
std::min(FOLD, (3 * MANT_DIG) / BIN_WIDTH - X_index), 0);
scaled = (std::max)(
(std::min)(FOLD, (3 * MANT_DIG) / BIN_WIDTH - X_index), 0);
if (X_index == 0)
{
Y += carry(0) * ((bins[0] / 6.0) * scale_down * EXPANSION);
Expand Down Expand Up @@ -888,7 +890,8 @@ namespace hpx::parallel::detail::rfa {
{
const double X = std::abs(max_abs_val);
const double S = std::abs(binned_sum);
return static_cast<ftype>(max(X, std::ldexp(0.5, MIN_EXP - 1)) *
return static_cast<ftype>(
(std::max)(X, std::ldexp(0.5, MIN_EXP - 1)) *
std::ldexp(0.5, (1 - FOLD) * BIN_WIDTH + 1) * N +
((7.0 * EPSILON) /
(1.0 - 6.0 * std::sqrt(static_cast<double>(EPSILON)) -
Expand Down Expand Up @@ -973,7 +976,7 @@ namespace hpx::parallel::detail::rfa {
T max_abs_val = input[0];
for (size_t i = 0; i < N; i++)
{
max_abs_val = max(max_abs_val, std::abs(input[i]));
max_abs_val = (std::max)(max_abs_val, std::abs(input[i]));
}
add(input, N, max_abs_val);
}
Expand Down Expand Up @@ -1142,4 +1145,4 @@ namespace hpx::parallel::detail::rfa {
}
};

} // namespace hpx::parallel::detail::rfa
} // namespace hpx::parallel::detail::rfa
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <limits>
#include <numeric>
#include <random>
#include <string>
#include <vector>

#include "test_utils.hpp"
Expand All @@ -27,8 +28,8 @@ int seed = std::random_device{}();
std::mt19937 gen(seed);

template <typename T>
T get_rand(
T LO = std::numeric_limits<T>::min(), T HI = std::numeric_limits<T>::max())
T get_rand(T LO = (std::numeric_limits<T>::min)(),
T HI = (std::numeric_limits<T>::max)())
{
return LO +
static_cast<T>(std::rand()) / (static_cast<T>(RAND_MAX / (HI - LO)));
Expand Down

0 comments on commit 6f2ce12

Please sign in to comment.