Skip to content

Commit

Permalink
Merge remote-tracking branch 'la-vache/master' into osaca-macros
Browse files Browse the repository at this point in the history
  • Loading branch information
eggrobin committed Dec 31, 2024
2 parents 4c86f36 + 604379e commit c64ab59
Show file tree
Hide file tree
Showing 19 changed files with 121 additions and 70 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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.
2 changes: 1 addition & 1 deletion functions/accurate_table_generator_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions functions/core_math_accuracy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -74,6 +74,5 @@ TEST_F(CoreMathAccuracyTest, SinCos) {

#endif

} // namespace _multiprecision
} // namespace functions
} // namespace principia
21 changes: 12 additions & 9 deletions functions/sin_cos_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<cpp_bin_float_50>(principia_sin));
Expand All @@ -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<cpp_bin_float_50>(principia_cos));
Expand Down Expand Up @@ -191,6 +195,5 @@ TEST_F(SinCosTest, HardReduction) {

#endif

} // namespace _sin_cos
} // namespace numerics
} // namespace functions_test
} // namespace principia
3 changes: 1 addition & 2 deletions functions/std_accuracy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -85,6 +85,5 @@ TEST_F(StdAccuracyTest, SinCos) {

#endif

} // namespace _multiprecision
} // namespace functions
} // namespace principia
1 change: 1 addition & 0 deletions geometry/serialization_body.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "geometry/grassmann.hpp"
#include "geometry/point.hpp"
#include "quantities/quantities.hpp"
#include "quantities/serialization.hpp"

namespace principia {
namespace geometry {
Expand Down
5 changes: 4 additions & 1 deletion include_what_you_using_all_the_things.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 `
Expand All @@ -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
6 changes: 3 additions & 3 deletions ksp_plugin_adapter/main_window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 9 additions & 1 deletion nanobenchmarks/examples.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <emmintrin.h>

#include "nanobenchmarks/function_registry.hpp"
#include "nanobenchmarks/function_registry.hpp" // 🧙 For BENCHMARK_FUNCTION etc.
#include "numerics/cbrt.hpp"
#include "numerics/sin_cos.hpp"

Expand Down Expand Up @@ -55,6 +55,14 @@ BENCHMARK_FUNCTION(method_3²ᴄZ5¹::Cbrt<Rounding::Correct>);
BENCHMARK_FUNCTION(method_5²Z4¹FMA::Cbrt<Rounding::Faithful>);
BENCHMARK_FUNCTION(method_5²Z4¹FMA::Cbrt<Rounding::Correct>);

BENCHMARKED_FUNCTION(std_sin) {
return std::sin(x);
}

BENCHMARKED_FUNCTION(principia_sin) {
return Sin(x);
}

BENCHMARKED_FUNCTION(std_cos) {
return std::cos(x);
}
Expand Down
2 changes: 0 additions & 2 deletions nanobenchmarks/function_registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include <string>
#include <string_view>

#include "base/macros.hpp"

namespace principia {
namespace nanobenchmarks {
namespace _function_registry {
Expand Down
20 changes: 15 additions & 5 deletions nanobenchmarks/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@
#include <utility>
#include <vector>

#include <intrin.h>

#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 <intrin.h>
#endif

ABSL_FLAG(std::size_t,
loop_iterations,
100,
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down
23 changes: 23 additions & 0 deletions nanobenchmarks/microarchitectures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,36 @@
#include <vector>

#include "base/cpuid.hpp"
#include "base/macros.hpp" // 🧙 For PRINCIPIA_COMPILER_CLANG.
#include "glog/logging.h"

BENCHMARK_EXTERN_C_FUNCTION(identity);
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 {
Expand Down
17 changes: 3 additions & 14 deletions nanobenchmarks/nanobenchmarks.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,14 @@
<VCProjectVersion>17.0</VCProjectVersion>
<ProjectGuid>{1c6654c0-14e2-4a9e-b0e6-508b84fa8a0e}</ProjectGuid>
<RootNamespace>nanobenchmarks</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(SolutionDir)principia.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" />
</ImportGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Link>
<AdditionalDependencies>gmock.lib;gmock_main.lib;powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ItemDefinitionGroup>
<Link>
<AdditionalDependencies>gmock.lib;gmock_main.lib;powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_LLVM|x64'">
<Link>
<AdditionalDependencies>gmock.lib;gmock_main.lib;powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand All @@ -42,7 +32,6 @@
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
<Import Project="$(SolutionDir)principia.props" />
<ImportGroup Label="Shared">
<Import Project="..\shared\base.vcxitems" Label="Shared" />
<Import Project="..\shared\numerics.vcxitems" Label="Shared" />
Expand Down
18 changes: 15 additions & 3 deletions nanobenchmarks/performance_settings_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
#include <utility>
#include <string_view>

#include "absl/flags/flag.h"
#include "base/macros.hpp" // 🧙 For OS_WIN.
#include "glog/logging.h"

#if OS_WIN
#include <windows.h>
#include <powersetting.h>
#include <powrprof.h>

#include "absl/flags/flag.h"
#include "glog/logging.h"

ABSL_FLAG(bool,
keep_perf_boost,
false,
Expand All @@ -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:
Expand Down Expand Up @@ -295,6 +299,14 @@ WindowsPerformanceSettingsController::ReadAndPrintAllowThrottlingACDC() const {
"PROCESSOR_THROTTLE DC={} ({})", dc, ProcessorThrottleToString(dc));
return {ac, dc};
}
#else

not_null<std::unique_ptr<PerformanceSettingsController>>
PerformanceSettingsController::New() {
return make_not_null_unique<PerformanceSettingsController>();
}

#endif

} // namespace internal
} // namespace _performance_settings_controller
Expand Down
Loading

0 comments on commit c64ab59

Please sign in to comment.