Skip to content

Commit

Permalink
Merge pull request #533 from ckormanyos/update_benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
ckormanyos authored Jul 30, 2024
2 parents 3748532 + 38dcc8d commit 5ccd365
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 16 deletions.
60 changes: 45 additions & 15 deletions ref_app/src/app/benchmark/app_benchmark_trapezoid_integral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,48 @@
// See also: https://godbolt.org/z/8ahv5Ghx5

#include <cstdint>
#include <limits>

#if defined(_MSC_VER)

#include <util/STL_C++XX_stdfloat/cstdfloat>
namespace app { namespace benchmark {

using my_float_type = double;

} // namespace benchmark
} // namespace app

#elif (defined(__has_include) && (__has_include(<stdfloat>)))

#include <stdfloat>

namespace app { namespace benchmark {

#if (defined(__STDCPP_FLOAT64_T__) && (__STDCPP_FLOAT64_T__ == 1))

using my_float_type = std::float64_t;

#else

using my_float_type = float;

#endif

} // namespace benchmark
} // namespace app

#if (defined(__has_include) && (__has_include(<stdfloat>)))
#include <stdfloat>
namespace app { namespace benchmark {
#if (defined(__STDCPP_FLOAT64_T__) && (__STDCPP_FLOAT64_T__ == 1))
using my_float_type = std::float64_t;
#else
using my_float_type = float;
#endif
} } // namespace app::benchmark
#else
#include <util/STL_C++XX_stdfloat/cstdfloat>
namespace app { namespace benchmark {
using my_float_type = std::floatmax_t;
} } // namespace app::benchmark

#include <util/STL_C++XX_stdfloat/cstdfloat>

namespace app { namespace benchmark {

using my_float_type = std::floatmax_t;

} // namespace benchmark
} // namespace app

#endif

#include <app/benchmark/app_benchmark_detail.h>
Expand Down Expand Up @@ -68,8 +95,11 @@ namespace

auto app::benchmark::run_trapezoid_integral() -> bool
{
static_assert((std::numeric_limits<my_float_type>::digits >= 24),
"Error: Incorrect my_float_type type definition");
#if (defined(__GNUC__) && defined(__AVR__) && (__GNUC__ < 12))
static_assert((std::numeric_limits<my_float_type>::digits >= 24), "Error: Incorrect my_float_type type definition");
#else
static_assert((std::numeric_limits<my_float_type>::digits >= 53), "Error: Incorrect my_float_type type definition");
#endif

constexpr auto app_benchmark_tolerance =
static_cast<my_float_type>
Expand Down
9 changes: 8 additions & 1 deletion ref_app/src/util/STL/stdfloat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2018.
// Copyright Christopher Kormanyos 2007 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -15,7 +15,14 @@
namespace std
{
using float32_t = float;
#if defined(__AVR__)
using float64_t = long double;
#else
using float64_t = double;
#endif
}

#define __STDCPP_FLOAT32_T__ 1
#define __STDCPP_FLOAT64_T__ 1

#endif // STDFLOAT_2024_07_12

0 comments on commit 5ccd365

Please sign in to comment.