Skip to content

Commit

Permalink
Better reproducibility across debug and release builds
Browse files Browse the repository at this point in the history
  • Loading branch information
KRM7 committed Dec 11, 2024
1 parent 7859ebc commit d24a148
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ if(MSVC) # MSVC style compiler interface
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(GAPP_CXX_FLAGS "${GAPP_CXX_FLAGS} -Zc:throwingNew")
set(GAPP_WARN_FLAGS "${GAPP_WARN_FLAGS} -external:anglebrackets")
set(GAPP_OPT_FLAGS "${GAPP_OPT_FLAGS} -fp:contract")
set(GAPP_OPT_FLAGS "${GAPP_OPT_FLAGS} -fp:precise")
endif()
# clang-cl specific options
if(GAPP_USE_MARCH_NATIVE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(GAPP_OPT_FLAGS "${GAPP_OPT_FLAGS} -march=native")
set(GAPP_OPT_FLAGS "${GAPP_OPT_FLAGS} -march=native -fp:precise -clang:-ffp-contract=off")
endif()

set(CMAKE_CXX_FLAGS "${GAPP_CXX_FLAGS} -Z7 -diagnostics:caret ${GAPP_WARN_FLAGS}")
Expand All @@ -85,7 +85,7 @@ else() # GNU style compiler interface
set(GAPP_WARN_FLAGS "${GAPP_WARN_FLAGS} -Werror -pedantic-errors")
endif()

set(GAPP_OPT_FLAGS "-O3 -fno-math-errno -fno-trapping-math -freciprocal-math -fno-signed-zeros -fno-associative-math -fno-finite-math-only")
set(GAPP_OPT_FLAGS "-O3 -fno-math-errno -fno-trapping-math -freciprocal-math -fno-signed-zeros -fno-associative-math -fno-finite-math-only -ffp-contract=off")
if(GAPP_USE_MARCH_NATIVE)
set(GAPP_OPT_FLAGS "${GAPP_OPT_FLAGS} -march=native")
endif()
Expand Down
6 changes: 3 additions & 3 deletions src/utility/math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ namespace gapp::math

if (vec.size() == 1) return 0.0;

long double var = std::transform_reduce(vec.begin(), vec.end(), 0.0L, std::plus{},
[mean, n = 1.0 / std::sqrt(vec.size())](long double val) noexcept
const double var = std::transform_reduce(vec.begin(), vec.end(), 0.0, std::plus{},
[mean, n = 1.0 / std::sqrt(vec.size())](double val) noexcept
{
return std::pow(n * (val - mean), 2);
});

return static_cast<double>(std::sqrt(var));
return std::sqrt(var);
}

double integralSinPow(size_t exponent, double x) noexcept
Expand Down
6 changes: 3 additions & 3 deletions src/utility/thread_pool.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Copyright (c) 2023 Krisztián Rugási. Subject to the MIT License. */

#ifndef GA_UTILITY_THREAD_POOL_HPP
#define GA_UTILITY_THREAD_POOL_HPP
#ifndef GAPP_UTILITY_THREAD_POOL_HPP
#define GAPP_UTILITY_THREAD_POOL_HPP

#include "concurrent_queue.hpp"
#include "algorithm.hpp"
Expand Down Expand Up @@ -202,4 +202,4 @@ namespace gapp

} // namespace gapp

#endif // !GA_UTILITY_THREAD_POOL_HPP
#endif // !GAPP_UTILITY_THREAD_POOL_HPP

0 comments on commit d24a148

Please sign in to comment.