Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6ff9a5cf9fbe
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9cfc177eb82a
Choose a head ref
  • 14 commits
  • 10 files changed
  • 1 contributor

Commits on Jan 8, 2018

  1. Copy the full SHA
    3c22250 View commit details
  2. The compiler doesn't protest.

    pleroy committed Jan 8, 2018
    Copy the full SHA
    05318f7 View commit details

Commits on Jan 9, 2018

  1. Copy the full SHA
    51948b6 View commit details
  2. Inlining is necessary.

    pleroy committed Jan 9, 2018
    Copy the full SHA
    b424d48 View commit details

Commits on Jan 10, 2018

  1. Copy the full SHA
    331df5c View commit details
  2. Make the polynomial test pass.

    pleroy committed Jan 10, 2018
    Copy the full SHA
    39707a8 View commit details
  3. Tests.

    pleroy committed Jan 10, 2018
    Copy the full SHA
    a401af8 View commit details
  4. Plural.

    pleroy committed Jan 10, 2018
    Copy the full SHA
    04b39b0 View commit details
  5. Lint.

    pleroy committed Jan 10, 2018
    1
    Copy the full SHA
    61b9509 View commit details

Commits on Jan 11, 2018

  1. Comma the right way.

    pleroy committed Jan 11, 2018
    Copy the full SHA
    2436d44 View commit details

Commits on Jan 12, 2018

  1. After egg's review.

    pleroy committed Jan 12, 2018
    Copy the full SHA
    4898240 View commit details

Commits on Jan 13, 2018

  1. Copy the full SHA
    6d2399f View commit details
  2. Lint.

    pleroy committed Jan 13, 2018
    Copy the full SHA
    56b7d61 View commit details
  3. Merge pull request #1672 from pleroy/Estrin

    Add an evaluator for Estrin's method; move the evaluators to a separate file and test them separately
    pleroy authored Jan 13, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9cfc177 View commit details
8 changes: 4 additions & 4 deletions base/macros.hpp
Original file line number Diff line number Diff line change
@@ -121,13 +121,13 @@ __attribute__((noreturn))
inline void noreturn() { std::exit(0); }

// Used to force inlining.
#if PRINCIPIA_COMPILER_CLANG || \
PRINCIPIA_COMPILER_CLANG_CL || \
PRINCIPIA_COMPILER_GCC
#if PRINCIPIA_COMPILER_GCC
# define FORCE_INLINE [[gnu::always_inline]] inline // NOLINT
#elif PRINCIPIA_COMPILER_MSVC
# define FORCE_INLINE __forceinline
#elif PRINCIPIA_COMPILER_ICC
#elif PRINCIPIA_COMPILER_CLANG || \
PRINCIPIA_COMPILER_CLANG_CL || \
PRINCIPIA_COMPILER_ICC
# define FORCE_INLINE __attribute__((always_inline))
#else
# error "What compiler is this?"
101 changes: 74 additions & 27 deletions benchmarks/polynomial.cpp
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
#include "geometry/named_quantities.hpp"
#include "geometry/r3_element.hpp"
#include "numerics/polynomial.hpp"
#include "numerics/polynomial_evaluators.hpp"
#include "quantities/quantities.hpp"
#include "quantities/si.hpp"

@@ -75,9 +76,10 @@ struct RandomTupleGenerator<Tuple, size, size> {
static void Fill(Tuple& t, std::mt19937_64& random) {}
};

template<typename Value, typename Argument, int degree>
template<typename Value, typename Argument, int degree,
template<typename, typename, int> class Evaluator>
void EvaluatePolynomialInMonomialBasis(benchmark::State& state) {
using P = PolynomialInMonomialBasis<Value, Argument, degree>;
using P = PolynomialInMonomialBasis<Value, Argument, degree, Evaluator>;
std::mt19937_64 random(42);
P::Coefficients coefficients;
RandomTupleGenerator<P::Coefficients, 0>::Fill(coefficients, random);
@@ -103,141 +105,186 @@ void EvaluatePolynomialInMonomialBasis(benchmark::State& state) {
state.SetLabel(ss.str().substr(0, 0));
}

template<template<typename, typename, int> class Evaluator>
void BM_EvaluatePolynomialInMonomialBasisDouble(benchmark::State& state) {
int const degree = state.range_x();
switch (degree) {
case 4:
EvaluatePolynomialInMonomialBasis<double, Time, 4>(state);
EvaluatePolynomialInMonomialBasis<double, Time, 4, Evaluator>(state);
break;
case 8:
EvaluatePolynomialInMonomialBasis<double, Time, 8>(state);
EvaluatePolynomialInMonomialBasis<double, Time, 8, Evaluator>(state);
break;
case 12:
EvaluatePolynomialInMonomialBasis<double, Time, 12>(state);
EvaluatePolynomialInMonomialBasis<double, Time, 12, Evaluator>(state);
break;
case 16:
EvaluatePolynomialInMonomialBasis<double, Time, 16>(state);
EvaluatePolynomialInMonomialBasis<double, Time, 16, Evaluator>(state);
break;
default:
LOG(FATAL) << "Degree " << degree
<< " in BM_EvaluatePolynomialInMonomialBasisDouble";
}
}

template<template<typename, typename, int> class Evaluator>
void BM_EvaluatePolynomialInMonomialBasisQuantity(benchmark::State& state) {
int const degree = state.range_x();
switch (degree) {
case 4:
EvaluatePolynomialInMonomialBasis<Length, Time, 4>(state);
EvaluatePolynomialInMonomialBasis<Length, Time, 4, Evaluator>(state);
break;
case 8:
EvaluatePolynomialInMonomialBasis<Length, Time, 8>(state);
EvaluatePolynomialInMonomialBasis<Length, Time, 8, Evaluator>(state);
break;
case 12:
EvaluatePolynomialInMonomialBasis<Length, Time, 12>(state);
EvaluatePolynomialInMonomialBasis<Length, Time, 12, Evaluator>(state);
break;
case 16:
EvaluatePolynomialInMonomialBasis<Length, Time, 16>(state);
EvaluatePolynomialInMonomialBasis<Length, Time, 16, Evaluator>(state);
break;
default:
LOG(FATAL) << "Degree " << degree
<< " in BM_EvaluatePolynomialInMonomialBasisQuantity";
}
}

template<template<typename, typename, int> class Evaluator>
void BM_EvaluatePolynomialInMonomialBasisR3ElementDouble(
benchmark::State& state) {
int const degree = state.range_x();
switch (degree) {
case 4:
EvaluatePolynomialInMonomialBasis<R3Element<double>, Time, 4>(state);
EvaluatePolynomialInMonomialBasis<R3Element<double>,
Time,
4,
Evaluator>(state);
break;
case 8:
EvaluatePolynomialInMonomialBasis<R3Element<double>, Time, 8>(state);
EvaluatePolynomialInMonomialBasis<R3Element<double>,
Time,
8,
Evaluator>(state);
break;
case 12:
EvaluatePolynomialInMonomialBasis<R3Element<double>, Time, 12>(state);
EvaluatePolynomialInMonomialBasis<R3Element<double>,
Time,
12,
Evaluator>(state);
break;
case 16:
EvaluatePolynomialInMonomialBasis<R3Element<double>, Time, 16>(state);
EvaluatePolynomialInMonomialBasis<R3Element<double>,
Time,
16,
Evaluator>(state);
break;
default:
LOG(FATAL) << "Degree " << degree
<< " in BM_EvaluatePolynomialInMonomialBasisR3ElementDouble";
}
}

template<template<typename, typename, int> class Evaluator>
void BM_EvaluatePolynomialInMonomialBasisVectorDouble(benchmark::State& state) {
int const degree = state.range_x();
switch (degree) {
case 4:
EvaluatePolynomialInMonomialBasis<
Multivector<double, ICRFJ2000Ecliptic, 1>,
Time,
4>(state);
4,
Evaluator>(state);
break;
case 8:
EvaluatePolynomialInMonomialBasis<
Multivector<double, ICRFJ2000Ecliptic, 1>,
Time,
8>(state);
8,
Evaluator>(state);
break;
case 12:
EvaluatePolynomialInMonomialBasis<
Multivector<double, ICRFJ2000Ecliptic, 1>,
Time,
12>(state);
12,
Evaluator>(state);
break;
case 16:
EvaluatePolynomialInMonomialBasis<
Multivector<double, ICRFJ2000Ecliptic, 1>,
Time,
16>(state);
16,
Evaluator>(state);
break;
default:
LOG(FATAL) << "Degree " << degree
<< " in BM_EvaluatePolynomialInMonomialBasisVectorDouble";
}
}

template<template<typename, typename, int> class Evaluator>
void BM_EvaluatePolynomialInMonomialBasisDisplacement(benchmark::State& state) {
int const degree = state.range_x();
switch (degree) {
case 4:
EvaluatePolynomialInMonomialBasis<Displacement<ICRFJ2000Ecliptic>,
Time,
4>(state);
4,
Evaluator>(state);
break;
case 8:
EvaluatePolynomialInMonomialBasis<Displacement<ICRFJ2000Ecliptic>,
Time,
8>(state);
8,
Evaluator>(state);
break;
case 12:
EvaluatePolynomialInMonomialBasis<Displacement<ICRFJ2000Ecliptic>,
Time,
12>(state);
12,
Evaluator>(state);
break;
case 16:
EvaluatePolynomialInMonomialBasis<Displacement<ICRFJ2000Ecliptic>,
Time,
16>(state);
16,
Evaluator>(state);
break;
default:
LOG(FATAL) << "Degree " << degree
<< " in BM_EvaluatePolynomialInMonomialBasisDisplacement";
}
}

BENCHMARK(BM_EvaluatePolynomialInMonomialBasisDouble)
BENCHMARK_TEMPLATE1(BM_EvaluatePolynomialInMonomialBasisDouble,
EstrinEvaluator)
->Arg(4)->Arg(8)->Arg(12)->Arg(16);
BENCHMARK_TEMPLATE1(BM_EvaluatePolynomialInMonomialBasisQuantity,
EstrinEvaluator)
->Arg(4)->Arg(8)->Arg(12)->Arg(16);
BENCHMARK_TEMPLATE1(BM_EvaluatePolynomialInMonomialBasisR3ElementDouble,
EstrinEvaluator)
->Arg(4)->Arg(8)->Arg(12)->Arg(16);
BENCHMARK_TEMPLATE1(BM_EvaluatePolynomialInMonomialBasisVectorDouble,
EstrinEvaluator)
->Arg(4)->Arg(8)->Arg(12)->Arg(16);
BENCHMARK_TEMPLATE1(BM_EvaluatePolynomialInMonomialBasisDisplacement,
EstrinEvaluator)
->Arg(4)->Arg(8)->Arg(12)->Arg(16);
BENCHMARK_TEMPLATE1(BM_EvaluatePolynomialInMonomialBasisDouble,
HornerEvaluator)
->Arg(4)->Arg(8)->Arg(12)->Arg(16);
BENCHMARK(BM_EvaluatePolynomialInMonomialBasisQuantity)
BENCHMARK_TEMPLATE1(BM_EvaluatePolynomialInMonomialBasisQuantity,
HornerEvaluator)
->Arg(4)->Arg(8)->Arg(12)->Arg(16);
BENCHMARK(BM_EvaluatePolynomialInMonomialBasisR3ElementDouble)
BENCHMARK_TEMPLATE1(BM_EvaluatePolynomialInMonomialBasisR3ElementDouble,
HornerEvaluator)
->Arg(4)->Arg(8)->Arg(12)->Arg(16);
BENCHMARK(BM_EvaluatePolynomialInMonomialBasisVectorDouble)
BENCHMARK_TEMPLATE1(BM_EvaluatePolynomialInMonomialBasisVectorDouble,
HornerEvaluator)
->Arg(4)->Arg(8)->Arg(12)->Arg(16);
BENCHMARK(BM_EvaluatePolynomialInMonomialBasisDisplacement)
BENCHMARK_TEMPLATE1(BM_EvaluatePolynomialInMonomialBasisDisplacement,
HornerEvaluator)
->Arg(4)->Arg(8)->Arg(12)->Arg(16);

} // namespace numerics
3 changes: 3 additions & 0 deletions numerics/numerics.vcxproj
Original file line number Diff line number Diff line change
@@ -266,6 +266,8 @@
<ClInclude Include="newhall.mathematica.h" />
<ClInclude Include="polynomial.hpp" />
<ClInclude Include="polynomial_body.hpp" />
<ClInclude Include="polynomial_evaluators.hpp" />
<ClInclude Include="polynomial_evaluators_body.hpp" />
<ClInclude Include="root_finders.hpp" />
<ClInclude Include="root_finders_body.hpp" />
<ClInclude Include="ulp_distance.hpp" />
@@ -278,6 +280,7 @@
<ClCompile Include="fit_hermite_spline_test.cpp" />
<ClCompile Include="fixed_arrays_test.cpp" />
<ClCompile Include="hermite3_test.cpp" />
<ClCompile Include="polynomial_evaluators_test.cpp" />
<ClCompile Include="polynomial_test.cpp" />
<ClCompile Include="root_finders_test.cpp" />
<ClCompile Include="чебышёв_series_test.cpp" />
9 changes: 9 additions & 0 deletions numerics/numerics.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -65,6 +65,12 @@
<ClInclude Include="polynomial.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="polynomial_evaluators.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="polynomial_evaluators_body.hpp">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="чебышёв_series_test.cpp">
@@ -88,5 +94,8 @@
<ClCompile Include="polynomial_test.cpp">
<Filter>Test Files</Filter>
</ClCompile>
<ClCompile Include="polynomial_evaluators_test.cpp">
<Filter>Test Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
4 changes: 3 additions & 1 deletion numerics/polynomial.hpp
Original file line number Diff line number Diff line change
@@ -70,7 +70,8 @@ class Polynomial {
virtual ~Polynomial() = default;
};

template<typename Value, typename Argument, int degree>
template<typename Value, typename Argument, int degree,
template<typename, typename, int> class Evaluator>
class PolynomialInMonomialBasis : public Polynomial<Value, Argument> {
public:
// Equivalent to:
@@ -94,6 +95,7 @@ class PolynomialInMonomialBasis : public Polynomial<Value, Argument> {

} // namespace internal_polynomial

using internal_polynomial::NthDerivative;
using internal_polynomial::Polynomial;
using internal_polynomial::PolynomialInMonomialBasis;

Loading