Skip to content

Commit

Permalink
UAAAH
Browse files Browse the repository at this point in the history
  • Loading branch information
eggrobin committed May 31, 2014
1 parent d9be1f9 commit 4fb85aa
Show file tree
Hide file tree
Showing 20 changed files with 295 additions and 105 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
14 changes: 12 additions & 2 deletions Principia.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Project Property Sheets", "Project Property Sheets", "{E12187B5-1432-4401-B671-FC3E06256CFD}"
ProjectSection(SolutionItems) = preProject
copy_libglog_dll.props = copy_libglog_dll.props
google_benchmark.props = google_benchmark.props
google_test_framework.props = google_test_framework.props
include_solution.props = include_solution.props
EndProjectSection
Expand All @@ -34,14 +35,23 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testing_utilities", "testin
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "integrators", "integrators\integrators.vcxproj", "{86AFF67D-38CD-487E-B4C1-B93984A9ED0D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{71A8A85A-3694-4E4F-85C1-D2A1FE773EB7}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "benchmarks", "benchmarks\benchmarks.vcxproj", "{7B174B21-0837-4BEE-864E-08AD3C74046A}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "clr_benchmarks_adapter", "clr_benchmarks_adapter\clr_benchmarks_adapter.vcxproj", "{940828E3-AAA8-4AA0-B371-03516A1E0242}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "clr_benchmarks", "clr_benchmarks\clr_benchmarks.vcxproj", "{36F3CAF9-1F27-42DC-B5C5-29CB2B8497F4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Git Auxiliary Files", "Git Auxiliary Files", "{0F8586AA-FAEF-4EC5-9D87-A96B9F7561EE}"
ProjectSection(SolutionItems) = preProject
.gitattributes = .gitattributes
.gitignore = .gitignore
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Legal", "Legal", "{4B25658F-A202-4286-B0CA-5CE54882787C}"
ProjectSection(SolutionItems) = preProject
LICENSE.txt = LICENSE.txt
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
4 changes: 4 additions & 0 deletions benchmarks/benchmarks.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
<ClCompile Include="main.cpp" />
<ClCompile Include="symplectic_partitioned_runge_kutta_integrator.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="symplectic_partitioned_runge_kutta_integrator.hpp" />
<ClInclude Include="symplectic_partitioned_runge_kutta_integrator_body.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
8 changes: 8 additions & 0 deletions benchmarks/benchmarks.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,12 @@
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="symplectic_partitioned_runge_kutta_integrator.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="symplectic_partitioned_runge_kutta_integrator_body.hpp">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
49 changes: 8 additions & 41 deletions benchmarks/symplectic_partitioned_runge_kutta_integrator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

#include "benchmarks/symplectic_partitioned_runge_kutta_integrator.hpp"

// .\Release\benchmarks_tests.exe --benchmark_repetitions=5 --benchmark_min_time=300 // NOLINT(whitespace/line_length)
// Benchmarking on 1 X 3310 MHz CPU
// 2014/05/30-20:51:41
Expand All @@ -11,13 +12,11 @@
// BM_SolveHarmonicOscillator 1231751867 1225231854 50 1.37019e-013, 1.37057e-013 // NOLINT(whitespace/line_length)
// BM_SolveHarmonicOscillator_mean 1256726528 1220847667 251 1.37019e-013, 1.37057e-013 // NOLINT(whitespace/line_length)
// BM_SolveHarmonicOscillator_stddev 66665752 5858502 251 1.37019e-013, 1.37057e-013 // NOLINT(whitespace/line_length)

#define GLOG_NO_ABBREVIATED_SEVERITIES
#undef TRACE_SYMPLECTIC_PARTITIONED_RUNGE_KUTTA_INTEGRATOR

#include <algorithm>
#include <vector>

#include "integrators/symplectic_partitioned_runge_kutta_integrator.hpp"
// Must come last to avoid conflicts when defining the CHECK macros.
#include "benchmark/benchmark.h"

Expand All @@ -26,44 +25,12 @@ using principia::integrators::SPRKIntegrator;
namespace principia {
namespace benchmarks {

namespace {

inline void compute_harmonic_oscillator_force(double const t,
std::vector<double> const& q,
std::vector<double>* result) {
(*result)[0] = -q[0];
}

inline void compute_harmonic_oscillator_velocity(std::vector<double> const& p,
std::vector<double>* result) {
(*result)[0] = p[0];
}

} // namespace

void SolveHarmonicOscillator(benchmark::State* state,
double* q_error,
double* p_error) {
SPRKIntegrator integrator;
SPRKIntegrator::Parameters parameters;
void SolveHarmonicOscillatorAndComputeError(benchmark::State* state,
double* q_error,
double* p_error) {
SPRKIntegrator::Solution solution;

integrator.Initialize(integrator.Order5Optimal());

parameters.q0 = {1.0};
parameters.p0 = {0.0};
parameters.t0 = 0.0;
#ifdef _DEBUG
parameters.tmax = 100.0;
#else
parameters.tmax = 1000.0;
#endif
parameters.Δt = 1.0E-4;
parameters.sampling_period = 1;
integrator.Solve(&compute_harmonic_oscillator_force,
&compute_harmonic_oscillator_velocity,
parameters,
&solution);
SolveHarmonicOscillator(&solution);

state->PauseTiming();
*q_error = 0;
Expand All @@ -84,7 +51,7 @@ static void BM_SolveHarmonicOscillator(
double q_error;
double p_error;
while (state.KeepRunning()) {
SolveHarmonicOscillator(&state, &q_error, &p_error);
SolveHarmonicOscillatorAndComputeError(&state, &q_error, &p_error);
}
std::stringstream ss;
ss << q_error << ", " << p_error;
Expand Down
17 changes: 17 additions & 0 deletions benchmarks/symplectic_partitioned_runge_kutta_integrator.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#undef TRACE_SYMPLECTIC_PARTITIONED_RUNGE_KUTTA_INTEGRATOR

#include "integrators/symplectic_partitioned_runge_kutta_integrator.hpp"

using principia::integrators::SPRKIntegrator;

namespace principia {
namespace benchmarks {

inline void SolveHarmonicOscillator(SPRKIntegrator::Solution* solution);

} // namespace benchmarks
} // namespace principia

#include "benchmarks/symplectic_partitioned_runge_kutta_integrator_body.hpp"
40 changes: 40 additions & 0 deletions benchmarks/symplectic_partitioned_runge_kutta_integrator_body.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#pragma once

#include <vector>

#undef TRACE_SYMPLECTIC_PARTITIONED_RUNGE_KUTTA_INTEGRATOR

#include "integrators/symplectic_partitioned_runge_kutta_integrator.hpp"
#include "testing_utilities/numerical_analysis.hpp"

using principia::integrators::SPRKIntegrator;

namespace principia {
namespace benchmarks {

inline void SolveHarmonicOscillator(SPRKIntegrator::Solution* solution) {
using principia::testing_utilities::ComputeHarmonicOscillatorForce;
using principia::testing_utilities::ComputeHarmonicOscillatorVelocity;
SPRKIntegrator integrator;
SPRKIntegrator::Parameters parameters;

integrator.Initialize(integrator.Order5Optimal());

parameters.q0 = {1.0};
parameters.p0 = {0.0};
parameters.t0 = 0.0;
#ifdef _DEBUG
parameters.tmax = 100.0;
#else
parameters.tmax = 1000.0;
#endif
parameters.Δt = 1.0E-4;
parameters.sampling_period = 1;
integrator.Solve(&ComputeHarmonicOscillatorForce,
&ComputeHarmonicOscillatorVelocity,
parameters,
solution);
}

} // namespace benchmarks
} // namespace principia
84 changes: 84 additions & 0 deletions clr_benchmarks/clr_benchmarks.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{36F3CAF9-1F27-42DC-B5C5-29CB2B8497F4}</ProjectGuid>
<RootNamespace>clr_benchmarks</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<CLRSupport>true</CLRSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<CLRSupport>true</CLRSupport>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\include_solution.props" />
<Import Project="..\google_benchmark.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\include_solution.props" />
<Import Project="..\google_benchmark.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
<ClCompile Include="symplectic_partitioned_runge_kutta.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\clr_benchmarks_adapter\clr_benchmarks_adapter.vcxproj">
<Project>{940828e3-aaa8-4aa0-b371-03516a1e0242}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
21 changes: 21 additions & 0 deletions clr_benchmarks/clr_benchmarks.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="symplectic_partitioned_runge_kutta.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
7 changes: 7 additions & 0 deletions clr_benchmarks/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "benchmark/benchmark.h"

int main(int argc, const char* argv[]) {
benchmark::Initialize(&argc, argv);

benchmark::RunSpecifiedBenchmarks();
}
19 changes: 19 additions & 0 deletions clr_benchmarks/symplectic_partitioned_runge_kutta.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#define GLOG_NO_ABBREVIATED_SEVERITIES

// Must come last to avoid conflicts when defining the CHECK macros.
#include "benchmark/benchmark.h"

namespace principia {
namespace clr_benchmarks {

static void BM_CLR_SolveHarmonicOscillator(
benchmark::State& state) { // NOLINT(runtime/references)
while (state.KeepRunning()) {
principia::clr_benchmarks_adapter::SPRKIntegratorCLRBenchmark::SolveHarmonicOscillator();
}
}

BENCHMARK(BM_CLR_SolveHarmonicOscillator);

} // namespace clr_benchmarks
} // namespace principia
2 changes: 1 addition & 1 deletion clr_benchmarks_adapter/clr_benchmarks_adapter.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
Loading

0 comments on commit 4fb85aa

Please sign in to comment.