diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 01644f8b66..36b927ef90 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -117,6 +117,14 @@ jobs: configuration: ${{ matrix.configuration }} directory: Google + - name: Download protobuf Release artifact + uses: mockingbirdnest/actions/windows/download_artifact@main + if: ${{ matrix.configuration == 'Debug' }} + with: + name: protobuf + configuration: Release + directory: Google + - name: Download zfp artifact uses: mockingbirdnest/actions/windows/download_artifact@main with: diff --git a/README.md b/README.md index b6e7bd61b7..395d97630b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Principia -**‎[Крылов](https://github.com/mockingbirdnest/Principia/wiki/Change-Log#%D0%BA%D1%80%D1%8B%D0%BB%D0%BE%D0%B2), the first December version of Principia, is available. Download it [here for 1.8.1, 1.9.1, 1.10.1, 1.11.0, 1.11.1, 1.11.2, and 1.12.2 to 1.12.5](https://bit.ly/kryl0v).** +**‎[Kummer](https://en.wikipedia.org/wiki/Ernst_Kummer), the second December version of Principia, is available. Download it [here for 1.8.1, 1.9.1, 1.10.1, 1.11.0, 1.11.1, 1.11.2, and 1.12.2 to 1.12.5](https://bit.ly/kumm3r).** -**For the convenience of Chinese users, download from 腾讯微云: [Principia Крылов for 1.8.1—1.12.5](https://share.weiyun.com/Bp0NUHxi).** +**For the convenience of Chinese users, download from 腾讯微云: [Principia Kummer for 1.8.1—1.12.5](https://share.weiyun.com/YJkjGIPM).** Principia is a mod for Kerbal Space Program (KSP) which implements N-body and extended body gravitation. Instead of being within the sphere of influence of a single celestial body at any point in time, your vessels are influenced by all the celestials. This makes it possible to implement missions that are more complex and more realistic than in the stock game, especially if used in conjunction with a mod like RealSolarSystem which has real-life celestials. @@ -18,4 +18,4 @@ The [change log](https://github.com/mockingbirdnest/Principia/wiki/Change-Log) g Principia is released on every [new moon](https://en.wikipedia.org/wiki/New_moon) with whatever features and bug fixes are ready at the time. This ensures relatively timely improvements and bug fixes. -Download the binary (Ubuntu, macOS, and Windows) [here for 1.8.1, 1.9.1, 1.10.1, 1.11.0, 1.11.1, 1.11.2, and 1.12.2 to 1.12.5](https://bit.ly/kryl0v). Or, if you don't trust our binary, [build the mod](https://github.com/mockingbirdnest/Principia/blob/master/documentation/Setup.md) from the [Крылов](https://github.com/mockingbirdnest/Principia/releases/tag/2024120106-%D0%9A%D1%80%D1%8B%D0%BB%D0%BE%D0%B2) release. +Download the binary (Ubuntu, macOS, and Windows) [here for 1.8.1, 1.9.1, 1.10.1, 1.11.0, 1.11.1, 1.11.2, and 1.12.2 to 1.12.5](https://bit.ly/kumm3r). Or, if you don't trust our binary, [build the mod](https://github.com/mockingbirdnest/Principia/blob/master/documentation/Setup.md) from the [Kummer](https://github.com/mockingbirdnest/Principia/releases/tag/2024123022-Kummer) release. diff --git a/functions/accurate_table_generator_test.cpp b/functions/accurate_table_generator_test.cpp index 1b5763fe60..4cc6b239c6 100644 --- a/functions/accurate_table_generator_test.cpp +++ b/functions/accurate_table_generator_test.cpp @@ -15,7 +15,7 @@ #include "mathematica/logger.hpp" #include "mathematica/mathematica.hpp" #include "numerics/combinatorics.hpp" -#include "quantities/numbers.hpp" +#include "quantities/numbers.hpp" // 🧙 For π. #include "testing_utilities/approximate_quantity.hpp" #include "testing_utilities/is_near.hpp" #include "testing_utilities/matchers.hpp" diff --git a/functions/core_math_accuracy_test.cpp b/functions/core_math_accuracy_test.cpp index 66b22bb578..efe0e365c2 100644 --- a/functions/core_math_accuracy_test.cpp +++ b/functions/core_math_accuracy_test.cpp @@ -8,15 +8,15 @@ #include "glog/logging.h" #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "quantities/numbers.hpp" +#include "quantities/numbers.hpp" // 🧙 For π. #include "testing_utilities/approximate_quantity.hpp" #include "testing_utilities/is_near.hpp" namespace principia { namespace functions { -namespace _multiprecision { using namespace boost::multiprecision; +using namespace principia::functions::_multiprecision; using namespace principia::testing_utilities::_approximate_quantity; using namespace principia::testing_utilities::_is_near; @@ -74,6 +74,5 @@ TEST_F(CoreMathAccuracyTest, SinCos) { #endif -} // namespace _multiprecision } // namespace functions } // namespace principia diff --git a/functions/sin_cos_test.cpp b/functions/sin_cos_test.cpp index 9f3ac5831c..9a605e8980 100644 --- a/functions/sin_cos_test.cpp +++ b/functions/sin_cos_test.cpp @@ -9,16 +9,22 @@ #include "glog/logging.h" #include "gtest/gtest.h" #include "numerics/next.hpp" -#include "quantities/numbers.hpp" +#include "quantities/numbers.hpp" // 🧙 For π. #include "testing_utilities/almost_equals.hpp" // This test lives in `functions` to avoid pulling `boost` into `numerics`. +// It uses neither the `functions` nor the `numerics` namespace so that the Sin +// and Cos from both (`principia::functions::_multiprecision` and +// `principia::numerics::_sin_cos`) are made visible by the using directives +// below. + namespace principia { -namespace numerics { -namespace _sin_cos { +namespace functions_test { using namespace boost::multiprecision; +using namespace principia::functions::_multiprecision; using namespace principia::numerics::_next; +using namespace principia::numerics::_sin_cos; using namespace principia::testing_utilities::_almost_equals; class SinCosTest : public ::testing::Test { @@ -90,8 +96,7 @@ TEST_F(SinCosTest, Random) { double const principia_argument = uniformly_at(random); auto const boost_argument = cpp_rational(principia_argument); { - auto const boost_sin = - functions::_multiprecision::Sin(boost_argument); + auto const boost_sin = Sin(boost_argument); double const principia_sin = Sin(principia_argument); auto const sin_error = abs(boost_sin - static_cast(principia_sin)); @@ -107,8 +112,7 @@ TEST_F(SinCosTest, Random) { } } { - auto const boost_cos = - functions::_multiprecision::Cos(boost_argument); + auto const boost_cos = Cos(boost_argument); double const principia_cos = Cos(principia_argument); auto const cos_error = abs(boost_cos - static_cast(principia_cos)); @@ -191,6 +195,5 @@ TEST_F(SinCosTest, HardReduction) { #endif -} // namespace _sin_cos -} // namespace numerics +} // namespace functions_test } // namespace principia diff --git a/functions/std_accuracy_test.cpp b/functions/std_accuracy_test.cpp index 382b1660b5..693397e44c 100644 --- a/functions/std_accuracy_test.cpp +++ b/functions/std_accuracy_test.cpp @@ -15,10 +15,10 @@ namespace principia { namespace functions { -namespace _multiprecision { using ::testing::AnyOf; using namespace boost::multiprecision; +using namespace principia::functions::_multiprecision; using namespace principia::quantities::_si; using namespace principia::testing_utilities::_almost_equals; using namespace principia::testing_utilities::_approximate_quantity; @@ -85,6 +85,5 @@ TEST_F(StdAccuracyTest, SinCos) { #endif -} // namespace _multiprecision } // namespace functions } // namespace principia diff --git a/geometry/serialization_body.hpp b/geometry/serialization_body.hpp index feea4e0b95..9236f988f1 100644 --- a/geometry/serialization_body.hpp +++ b/geometry/serialization_body.hpp @@ -6,6 +6,7 @@ #include "geometry/grassmann.hpp" #include "geometry/point.hpp" #include "quantities/quantities.hpp" +#include "quantities/serialization.hpp" namespace principia { namespace geometry { diff --git a/include_what_you_using_all_the_things.ps1 b/include_what_you_using_all_the_things.ps1 index cc3b1393c8..f3aab12db4 100644 --- a/include_what_you_using_all_the_things.ps1 +++ b/include_what_you_using_all_the_things.ps1 @@ -4,12 +4,14 @@ --project:astronomy ` --project:base ` --project:benchmarks ` + --project:functions ` --project:geometry ` --project:integrators ` --project:journal ` --project:ksp_plugin ` --project:ksp_plugin_test ` --project:mathematica ` + --project:nanobenchmarks ` --project:numerics ` --project:physics ` --project:quantities ` @@ -23,4 +25,5 @@ --special_own_header:ksp_plugin/interface_*.cpp=ksp_plugin/interface.hpp ` --special_own_header:ksp_plugin_test/interface_*.cpp=ksp_plugin/interface.hpp ` --special_own_header:ksp_plugin_test/benchmark.cpp=ksp_plugin/plugin.hpp ` - --special_own_header:ksp_plugin_test/plugin*_test.cpp=ksp_plugin/plugin.hpp + --special_own_header:ksp_plugin_test/plugin*_test.cpp=ksp_plugin/plugin.hpp ` + --special_own_header:functions/sin_cos_test.cpp=numerics/sin_cos.hpp diff --git a/ksp_plugin_adapter/main_window.cs b/ksp_plugin_adapter/main_window.cs index 2278b34270..b707204f90 100644 --- a/ksp_plugin_adapter/main_window.cs +++ b/ksp_plugin_adapter/main_window.cs @@ -7,10 +7,10 @@ namespace ksp_plugin_adapter { internal class MainWindow : VesselSupervisedWindowRenderer { // Update this section before each release. - private const string next_release_name = "Kummer"; - private const int next_release_lunation_number = 309; + private const string next_release_name = "Kuratowski"; + private const int next_release_lunation_number = 310; private readonly DateTimeOffset next_release_date_ = - new DateTimeOffset(2024, 12, 30, 22, 26, 48, TimeSpan.Zero); + new DateTimeOffset(2025, 01, 29, 12, 35, 59, TimeSpan.Zero); public MainWindow( PrincipiaPluginAdapter adapter, diff --git a/nanobenchmarks/examples.cpp b/nanobenchmarks/examples.cpp index fb28f93ae2..97b74f8707 100644 --- a/nanobenchmarks/examples.cpp +++ b/nanobenchmarks/examples.cpp @@ -1,6 +1,6 @@ #include -#include "nanobenchmarks/function_registry.hpp" +#include "nanobenchmarks/function_registry.hpp" // 🧙 For BENCHMARK_FUNCTION etc. #include "numerics/cbrt.hpp" #include "numerics/sin_cos.hpp" @@ -55,6 +55,14 @@ BENCHMARK_FUNCTION(method_3²ᴄZ5¹::Cbrt); BENCHMARK_FUNCTION(method_5²Z4¹FMA::Cbrt); BENCHMARK_FUNCTION(method_5²Z4¹FMA::Cbrt); +BENCHMARKED_FUNCTION(std_sin) { + return std::sin(x); +} + +BENCHMARKED_FUNCTION(principia_sin) { + return Sin(x); +} + BENCHMARKED_FUNCTION(std_cos) { return std::cos(x); } diff --git a/nanobenchmarks/function_registry.hpp b/nanobenchmarks/function_registry.hpp index 0b056df9f7..6ee6cd5fa1 100644 --- a/nanobenchmarks/function_registry.hpp +++ b/nanobenchmarks/function_registry.hpp @@ -5,8 +5,6 @@ #include #include -#include "base/macros.hpp" - namespace principia { namespace nanobenchmarks { namespace _function_registry { diff --git a/nanobenchmarks/main.cpp b/nanobenchmarks/main.cpp index 42ecb90cbb..ce1fbf1d8e 100644 --- a/nanobenchmarks/main.cpp +++ b/nanobenchmarks/main.cpp @@ -14,21 +14,23 @@ #include #include -#include - #include "absl/flags/flag.h" #include "absl/flags/parse.h" #include "absl/strings/str_join.h" #include "absl/strings/str_split.h" -#include "base/array.hpp" -#include "base/cpuid.hpp" +#include "base/macros.hpp" // 🧙 For PRINCIPIA_COMPILER_CLANG. #include "mathematica/logger.hpp" +#include "mathematica/mathematica.hpp" #include "nanobenchmarks/function_registry.hpp" #include "nanobenchmarks/microarchitectures.hpp" #include "nanobenchmarks/performance_settings_controller.hpp" -#include "numerics/cbrt.hpp" #include "testing_utilities/statistics.hpp" + +#if PRINCIPIA_COMPILER_MSVC +#include +#endif + ABSL_FLAG(std::size_t, loop_iterations, 100, @@ -151,7 +153,11 @@ __declspec(noinline) LatencyDistributionTable double const input = absl::GetFlag(FLAGS_input); double x = input; // The CPUID barriers prevent out-of-order execution; see [Pao10]. + #if PRINCIPIA_COMPILER_MSVC __cpuid(registers, leaf); + #else + asm volatile("cpuid"); + #endif auto const tsc_start = __rdtsc(); for (int i = 0; i < loop_iterations; ++i) { x = f(x); @@ -166,7 +172,11 @@ __declspec(noinline) LatencyDistributionTable // globally visible, and subsequent instructions may begin execution before // the read operation is performed. auto const tsc_stop = __rdtscp(&tsc_aux); + #if PRINCIPIA_COMPILER_MSVC __cpuid(registers, leaf); + #else + asm volatile("cpuid"); + #endif double const δtsc = tsc_stop - tsc_start; samples[j] = δtsc / loop_iterations; } diff --git a/nanobenchmarks/microarchitectures.cpp b/nanobenchmarks/microarchitectures.cpp index e0af7168b1..e149e36822 100644 --- a/nanobenchmarks/microarchitectures.cpp +++ b/nanobenchmarks/microarchitectures.cpp @@ -6,6 +6,7 @@ #include #include "base/cpuid.hpp" +#include "base/macros.hpp" // 🧙 For PRINCIPIA_COMPILER_CLANG. #include "glog/logging.h" BENCHMARK_EXTERN_C_FUNCTION(identity); @@ -13,6 +14,28 @@ BENCHMARK_EXTERN_C_FUNCTION(sqrtps_xmm0_xmm0); BENCHMARK_EXTERN_C_FUNCTION(sqrtsd_xmm0_xmm0); BENCHMARK_EXTERN_C_FUNCTION(mulsd_xmm0_xmm0); BENCHMARK_EXTERN_C_FUNCTION(mulsd_xmm0_xmm0_4x); +#if PRINCIPIA_COMPILER_CLANG +asm(R"( +.intel_syntax +identity: + ret +sqrtps_xmm0_xmm0: + sqrtps xmm0, xmm0 + ret +sqrtsd_xmm0_xmm0: + sqrtsd xmm0, xmm0 + ret +mulsd_xmm0_xmm0: + mulsd xmm0, xmm0 + ret +mulsd_xmm0_xmm0_4x: + mulsd xmm0, xmm0 + mulsd xmm0, xmm0 + mulsd xmm0, xmm0 + mulsd xmm0, xmm0 + ret +)"); +#endif namespace principia { namespace nanobenchmarks { diff --git a/nanobenchmarks/nanobenchmarks.vcxproj b/nanobenchmarks/nanobenchmarks.vcxproj index d2b5a63f9d..902e5567be 100644 --- a/nanobenchmarks/nanobenchmarks.vcxproj +++ b/nanobenchmarks/nanobenchmarks.vcxproj @@ -4,24 +4,14 @@ 17.0 {1c6654c0-14e2-4a9e-b0e6-508b84fa8a0e} nanobenchmarks - 10.0 + - - - gmock.lib;gmock_main.lib;powrprof.lib;%(AdditionalDependencies) - - - + - gmock.lib;gmock_main.lib;powrprof.lib;%(AdditionalDependencies) - - - - - gmock.lib;gmock_main.lib;powrprof.lib;%(AdditionalDependencies) + powrprof.lib;%(AdditionalDependencies) @@ -42,7 +32,6 @@ - diff --git a/nanobenchmarks/performance_settings_controller.cpp b/nanobenchmarks/performance_settings_controller.cpp index 16246229c9..3ff1d25b3f 100644 --- a/nanobenchmarks/performance_settings_controller.cpp +++ b/nanobenchmarks/performance_settings_controller.cpp @@ -6,13 +6,15 @@ #include #include +#include "absl/flags/flag.h" +#include "base/macros.hpp" // 🧙 For OS_WIN. +#include "glog/logging.h" + +#if OS_WIN #include #include #include -#include "absl/flags/flag.h" -#include "glog/logging.h" - ABSL_FLAG(bool, keep_perf_boost, false, @@ -23,12 +25,14 @@ ABSL_FLAG(bool, keep_throttling, false, "Whether to allow processor throttling during benchmark execution"); +#endif namespace principia { namespace nanobenchmarks { namespace _performance_settings_controller { namespace internal { +#if OS_WIN class WindowsPerformanceSettingsController : public PerformanceSettingsController { public: @@ -295,6 +299,14 @@ WindowsPerformanceSettingsController::ReadAndPrintAllowThrottlingACDC() const { "PROCESSOR_THROTTLE DC={} ({})", dc, ProcessorThrottleToString(dc)); return {ac, dc}; } +#else + +not_null> +PerformanceSettingsController::New() { + return make_not_null_unique(); +} + +#endif } // namespace internal } // namespace _performance_settings_controller diff --git a/numerics/sin_cos.cpp b/numerics/sin_cos.cpp index 266139068c..4096065b23 100644 --- a/numerics/sin_cos.cpp +++ b/numerics/sin_cos.cpp @@ -276,10 +276,11 @@ Value SinImplementation(DoublePrecision const θ_reduced) { double const h² = h * (h + 2 * e); double const h³ = h² * h; double const polynomial_term = - ((sin_x₀ * h² * CosPolynomial(h²) + - cos_x₀ * FusedMultiplyAdd( - h³, SinPolynomial(h²), e)) + - sin_x₀_plus_h_cos_x₀.error); + FusedMultiplyAdd( + cos_x₀, + FusedMultiplyAdd(h³, SinPolynomial(h²), e), + sin_x₀ * h² * CosPolynomial(h²)) + + sin_x₀_plus_h_cos_x₀.error; return DetectDangerousRounding(sin_x₀_plus_h_cos_x₀.value, polynomial_term); } } @@ -310,11 +311,11 @@ Value CosImplementation(DoublePrecision const θ_reduced) { double const h² = h * (h + 2 * e); double const h³ = h² * h; double const polynomial_term = - (FusedNegatedMultiplyAdd( - sin_x₀, - FusedMultiplyAdd(h³, SinPolynomial(h²), e), - cos_x₀ * h² * CosPolynomial(h²)) + - cos_x₀_minus_h_sin_x₀.error); + FusedNegatedMultiplyAdd( + sin_x₀, + FusedMultiplyAdd(h³, SinPolynomial(h²), e), + cos_x₀ * h² * CosPolynomial(h²)) + + cos_x₀_minus_h_sin_x₀.error; return DetectDangerousRounding(cos_x₀_minus_h_sin_x₀.value, polynomial_term); } diff --git a/numerics/sin_cos.hpp b/numerics/sin_cos.hpp index 07a26ee280..c4a4b6fc4a 100644 --- a/numerics/sin_cos.hpp +++ b/numerics/sin_cos.hpp @@ -1,6 +1,6 @@ #pragma once -#include "base/macros.hpp" +#include "base/macros.hpp" // 🧙 For FORCE_INLINE. namespace principia { namespace numerics { diff --git a/principia.props b/principia.props index 679aef9cb0..69b8021e60 100644 --- a/principia.props +++ b/principia.props @@ -34,6 +34,7 @@ false Debug diff --git a/sourcerer/include_what_you_using.cs b/sourcerer/include_what_you_using.cs index 27aab28820..3fdb6793e0 100644 --- a/sourcerer/include_what_you_using.cs +++ b/sourcerer/include_what_you_using.cs @@ -186,7 +186,10 @@ private static void FixIncludes(Parser.File file, foreach (string ns in using_namespaces) { var segments = ns.Split("::", StringSplitOptions.RemoveEmptyEntries); var include_path = Array.Empty(); - bool skip = false; + if (ns == file.file_namespace_full_name) { + // Don't add an include for our own header. This matters for tests. + continue; + } foreach (string segment in segments) { if (segment == "principia") { continue; @@ -195,24 +198,17 @@ private static void FixIncludes(Parser.File file, segment == "std") { // We have using directives for namespaces in absl or std, don't emit // an include for them. - skip = true; - continue; + goto next_using_directive; } else if (segment[0] == '_') { - // Don't add an include for our own header. This matters for tests. - if (segment == file.file_namespace_simple_name) { - skip = true; - } else { - string header_filename = Regex.Replace(segment, @"^_", ""); - include_path = include_path.Append(header_filename).ToArray(); - } + string header_filename = Regex.Replace(segment, @"^_", ""); + include_path = include_path.Append(header_filename).ToArray(); break; } else { include_path = include_path.Append(segment).ToArray(); } } - if (!skip) { - new_include_paths.Add(include_path); - } + new_include_paths.Add(include_path); + next_using_directive: {} } // Extract the includes.