Skip to content

Commit

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

Signed-off-by: Shreyas Atre <[email protected]>
  • Loading branch information
SAtacker committed Dec 18, 2024
1 parent 520f161 commit 08b257b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 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 @@ -351,7 +353,7 @@ namespace hpx::parallel::detail::rfa {

///Get index of float-point precision
///The index of a non-binned type is the smallest index a binned type would
///need to have to sum it reproducibly. Higher indicies correspond to smaller
///need to have to sum it reproducibly. Higher indices correspond to smaller
///bins.
static inline constexpr int binned_dindex(const ftype x)
{
Expand All @@ -365,15 +367,15 @@ 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;
}

///Get index of manually specified binned double precision
///The index of a binned type is the bin that it corresponds to. Higher
///indicies correspond to smaller bins.
///indices correspond to smaller bins.
inline int binned_index() const
{
return ((MAX_EXP + MANT_DIG - BIN_WIDTH + 1 + EXP_BIAS) -
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 08b257b

Please sign in to comment.