Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Benchmarks #336

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/continuous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ jobs:
- run: python -V
- run: cmake --version
- run: ${{ matrix.make || 'make' }} --version
- run: cmake -B builds -DCLOSURE=1 ${{ matrix.cmake-args }}
- run: cmake
-B builds
-D CLOSURE=1
-D TOTAL_MEMORY=134217728
${{ matrix.cmake-args }}
- run: cmake --build builds -- VERBOSE=1
- run: npm ci
- name: Test Ammo Javascript
Expand All @@ -26,6 +30,10 @@ jobs:
run: npx ava
env:
AMMO_BUILD: builds/ammo.wasm.js
- run: node builds/benchmarks.js
- run: node builds/benchmarks.wasm.js
- run: node builds/bammo.js --benchmark_counters_tabular=true
- run: node builds/bammo.wasm.js --benchmark_counters_tabular=true
strategy:
matrix:
os:
Expand Down
69 changes: 66 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
cmake_minimum_required(VERSION 3.17)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)

FIND_PACKAGE(Python3)
Expand All @@ -10,7 +10,7 @@ set(AMMO_FRONT_MATTER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/front-matter.js)
set(AMMO_HEADER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/ammo.h)
set(AMMO_IDL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/ammo.idl)
set(AMMO_ONLOAD_FILE ${CMAKE_CURRENT_SOURCE_DIR}/onload.js)
set(BULLET_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bullet/src/)
set(BULLET_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bullet)


set(BULLET_TARGETS BulletCollision BulletDynamics BulletSoftBody LinearMath)
Expand Down Expand Up @@ -74,7 +74,7 @@ set(EMCC_WASM_ARGS ${EMCC_ARGS}

set(EMCC_GLUE_ARGS
-c
-I${BULLET_SRC_DIR}
-I${BULLET_DIR}/src
-include${AMMO_HEADER_FILE})


Expand Down Expand Up @@ -118,3 +118,66 @@ add_custom_command(
COMMENT "Building ammo webassembly"
VERBATIM)
add_custom_target(ammo-wasm ALL DEPENDS ammo.wasm.js ammo.wasm.wasm)


#######################################
# legacy benchmark emscripten targets
#######################################
set(BENCHMARK_LDFLAGS
-O3
-sALLOW_MEMORY_GROWTH=${ALLOW_MEMORY_GROWTH}
-sTOTAL_MEMORY=${TOTAL_MEMORY})
set(BENCHMARK_JS_LDFLAGS ${BENCHMARK_LDFLAGS}
-sAGGRESSIVE_VARIABLE_ELIMINATION=1
-sELIMINATE_DUPLICATE_FUNCTIONS=1
-sSINGLE_FILE=1
-sWASM=0)
set(BENCHMARK_WASM_LDFLAGS ${BENCHMARK_LDFLAGS}
-sBINARYEN_IGNORE_IMPLICIT_TRAPS=1
-sWASM=1)

add_library(benchmarks-objects OBJECT $<TARGET_PROPERTY:benchmarks,SOURCES>)
target_include_directories(benchmarks-objects PUBLIC $<TARGET_PROPERTY:benchmarks,INCLUDE_DIRECTORIES>)
target_compile_options(benchmarks-objects PUBLIC $<TARGET_PROPERTY:benchmarks,COMPILE_OPTIONS>)

add_executable(benchmarks.js $<TARGET_OBJECTS:benchmarks-objects>)
set_target_properties(benchmarks.js PROPERTIES OUTPUT_NAME benchmarks)
target_link_libraries(benchmarks.js $<TARGET_PROPERTY:benchmarks,LINK_LIBRARIES>)
target_link_options(benchmarks.js PUBLIC ${BENCHMARK_JS_LDFLAGS})

add_executable(benchmarks.wasm.js $<TARGET_OBJECTS:benchmarks-objects>)
set_target_properties(benchmarks.wasm.js PROPERTIES OUTPUT_NAME benchmarks.wasm)
target_link_libraries(benchmarks.wasm.js $<TARGET_PROPERTY:benchmarks,LINK_LIBRARIES>)
target_link_options(benchmarks.wasm.js PUBLIC ${BENCHMARK_WASM_LDFLAGS})


#######################################
# bammo emscripten targets
#######################################
add_subdirectory(bammo)
set(BAMMO_LDFLAGS
-O3
-sALLOW_MEMORY_GROWTH=${ALLOW_MEMORY_GROWTH}
-sTOTAL_MEMORY=${TOTAL_MEMORY})
set(BAMMO_JS_LDFLAGS ${BAMMO_LDFLAGS}
-sAGGRESSIVE_VARIABLE_ELIMINATION=1
-sELIMINATE_DUPLICATE_FUNCTIONS=1
-sSINGLE_FILE=1
-sWASM=0)
set(BAMMO_WASM_LDFLAGS ${BAMMO_LDFLAGS}
-sBINARYEN_IGNORE_IMPLICIT_TRAPS=1
-sWASM=1)

add_library(bammo-objects OBJECT $<TARGET_PROPERTY:bammo,SOURCES>)
target_include_directories(bammo-objects PUBLIC $<TARGET_PROPERTY:bammo,INCLUDE_DIRECTORIES>)
target_compile_options(bammo-objects PUBLIC $<TARGET_PROPERTY:bammo,COMPILE_OPTIONS>)

add_executable(bammo.js $<TARGET_OBJECTS:bammo-objects>)
set_target_properties(bammo.js PROPERTIES OUTPUT_NAME bammo)
target_link_libraries(bammo.js $<TARGET_PROPERTY:bammo,LINK_LIBRARIES>)
target_link_options(bammo.js PUBLIC ${BAMMO_JS_LDFLAGS})

add_executable(bammo.wasm.js $<TARGET_OBJECTS:bammo-objects>)
set_target_properties(bammo.wasm.js PROPERTIES OUTPUT_NAME bammo.wasm)
target_link_libraries(bammo.wasm.js $<TARGET_PROPERTY:bammo,LINK_LIBRARIES>)
target_link_options(bammo.wasm.js PUBLIC ${BAMMO_WASM_LDFLAGS})
63 changes: 63 additions & 0 deletions bammo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
cmake_minimum_required(VERSION 3.17)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)

set(CMAKE_BUILD_TYPE Release CACHE STRING "bammo build type")

########################################
# bullet
########################################
set(BULLET_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../bullet)
if(NOT TARGET BulletCollision)
set(BUILD_EXTRAS OFF)
set(BUILD_MULTITHREADING OFF)
set(BUILD_UNIT_TESTS OFF)
set(USE_GRAPHICAL_BENCHMARK OFF)
set(USE_GLUT OFF)
add_subdirectory(${BULLET_DIR} bullet EXCLUDE_FROM_ALL)
endif()


########################################
# google benchmark
#######################################
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
add_subdirectory(benchmark EXCLUDE_FROM_ALL)


########################################
# bammo
#######################################
project(bammo)

set(BAMMO_DIR
${CMAKE_CURRENT_SOURCE_DIR})
set(BAMMO_SOURCES
${BAMMO_DIR}/main.cpp
${BULLET_DIR}/Demos/Benchmarks/BenchmarkDemo.cpp)
set(BAMMO_CFLAGS
-std=c++11
-I${BULLET_DIR}/src
-I${BULLET_DIR}/Demos/Benchmarks)

add_executable(bammo ${BAMMO_SOURCES})
target_compile_options(bammo PUBLIC ${BAMMO_CFLAGS})
target_link_libraries(bammo BulletCollision)
target_link_libraries(bammo BulletDynamics)
target_link_libraries(bammo LinearMath)
target_link_libraries(bammo benchmark::benchmark)


#######################################
# legacy bullet benchmarks
#######################################
set(BENCHMARK_SOURCES
${BULLET_DIR}/Demos/Benchmarks/main.cpp
${BULLET_DIR}/Demos/Benchmarks/BenchmarkDemo.cpp)
set(BENCHMARK_CFLAGS
-I${BULLET_DIR}/src)

add_executable(benchmarks ${BENCHMARK_SOURCES})
target_compile_options(benchmarks PUBLIC ${BENCHMARK_CFLAGS})
target_link_libraries(benchmarks BulletCollision)
target_link_libraries(benchmarks BulletDynamics)
target_link_libraries(benchmarks LinearMath)
5 changes: 5 additions & 0 deletions bammo/benchmark/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
Language: Cpp
BasedOnStyle: Google
PointerAlignment: Left
...
32 changes: 32 additions & 0 deletions bammo/benchmark/.github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**System**
Which OS, compiler, and compiler version are you using:
- OS:
- Compiler and version:

**To reproduce**
Steps to reproduce the behavior:
1. sync to commit ...
2. cmake/bazel...
3. make ...
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions bammo/benchmark/.github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FR]"
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
38 changes: 38 additions & 0 deletions bammo/benchmark/.github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: build-and-test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
job:
# TODO(dominic): Extend this to include compiler and set through env: CC/CXX.
name: ${{ matrix.os }}.${{ matrix.build_type }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, ubuntu-16.04, ubuntu-20.04, macos-latest, windows-latest]
build_type: ['Release', 'Debug']
steps:
- uses: actions/checkout@v2

- name: create build environment
run: cmake -E make_directory ${{ runner.workspace }}/_build

- name: configure cmake
shell: bash
working-directory: ${{ runner.workspace }}/_build
run: cmake -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}

- name: build
shell: bash
working-directory: ${{ runner.workspace }}/_build
run: cmake --build . --config ${{ matrix.build_type }}

- name: test
shell: bash
working-directory: ${{ runner.workspace }}/_build
run: ctest -C ${{ matrix.build_type }}
26 changes: 26 additions & 0 deletions bammo/benchmark/.github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: pylint

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
pylint:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint pylint-exit conan
- name: Run pylint
run: |
pylint `find . -name '*.py'|xargs` || pylint-exit $?
24 changes: 24 additions & 0 deletions bammo/benchmark/.github/workflows/test_bindings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: test-bindings

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
python_bindings:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install benchmark
run:
python setup.py install
- name: Run example bindings
run:
python bindings/python/google_benchmark/example.py
66 changes: 66 additions & 0 deletions bammo/benchmark/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
*.a
*.so
*.so.?*
*.dll
*.exe
*.dylib
*.cmake
!/cmake/*.cmake
!/test/AssemblyTests.cmake
*~
*.swp
*.pyc
__pycache__

# lcov
*.lcov
/lcov

# cmake files.
/Testing
CMakeCache.txt
CMakeFiles/
cmake_install.cmake

# makefiles.
Makefile

# in-source build.
bin/
lib/
/test/*_test

# exuberant ctags.
tags

# YouCompleteMe configuration.
.ycm_extra_conf.pyc

# ninja generated files.
.ninja_deps
.ninja_log
build.ninja
install_manifest.txt
rules.ninja

# bazel output symlinks.
bazel-*

# out-of-source build top-level folders.
build/
_build/
build*/

# in-source dependencies
/googletest/

# Visual Studio 2015/2017 cache/options directory
.vs/
CMakeSettings.json

# Visual Studio Code cache/options directory
.vscode/

# Python build stuff
dist/
*.egg-info*
Loading