Skip to content

Commit

Permalink
Added WASM to determinism check build (#1497)
Browse files Browse the repository at this point in the history
* Update to emscripten 4.0.2
* Update node to 23.x
  • Loading branch information
jrouwe authored Feb 7, 2025
1 parent 5bd04af commit 0634fe1
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 5 deletions.
47 changes: 43 additions & 4 deletions .github/workflows/determinism_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ env:
RAGDOLL_HASH: '0xdf768b4736057c87'
PYRAMID_HASH: '0x2e2dda8c1f4eb906'
CHARACTER_VIRTUAL_HASH: '0x4ec98831ce0590ff'
EMSCRIPTEN_VERSION: 3.1.73
EMSCRIPTEN_VERSION: 4.0.2
NODE_VERSION: 23.x
UBUNTU_CLANG_VERSION: clang++-18
UBUNTU_GCC_VERSION: g++-14
UBUNTU_GCC_AARCH64_VERSION: aarch64-linux-gnu-g++-14
Expand Down Expand Up @@ -354,7 +355,7 @@ jobs:

emscripten:
runs-on: ubuntu-latest
name: Emscripten Determinism Check
name: Emscripten WASM32 Determinism Check

steps:
- name: Checkout Code
Expand All @@ -365,10 +366,10 @@ jobs:
version: ${{env.EMSCRIPTEN_VERSION}}
- name: Verify emsdk
run: emcc -v
- name: Setup Node.js 18.x
- name: Setup Node.js ${{env.NODE_VERSION}}
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: ${{env.NODE_VERSION}}
- name: Configure CMake
working-directory: ${{github.workspace}}/Build
run: ./cmake_linux_emscripten.sh Distribution -DCROSS_PLATFORM_DETERMINISTIC=ON -DTARGET_VIEWER=OFF -DTARGET_SAMPLES=OFF -DTARGET_HELLO_WORLD=OFF -DTARGET_UNIT_TESTS=ON -DTARGET_PERFORMANCE_TEST=ON
Expand All @@ -389,3 +390,41 @@ jobs:
- name: Test CharacterVirtual
working-directory: ${{github.workspace}}/Build/WASM_Distribution
run: node PerformanceTest.js -q=Discrete -t=max -s=CharacterVirtual -validate_hash=${CHARACTER_VIRTUAL_HASH}

emscripten64:
runs-on: ubuntu-latest
name: Emscripten WASM64 Determinism Check

steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v14
with:
version: ${{env.EMSCRIPTEN_VERSION}}
- name: Verify emsdk
run: emcc -v
- name: Setup Node.js ${{env.NODE_VERSION}}
uses: actions/setup-node@v4
with:
node-version: ${{env.NODE_VERSION}}
- name: Configure CMake
working-directory: ${{github.workspace}}/Build
run: ./cmake_linux_emscripten.sh Distribution -DCROSS_PLATFORM_DETERMINISTIC=ON -DTARGET_VIEWER=OFF -DTARGET_SAMPLES=OFF -DTARGET_HELLO_WORLD=OFF -DTARGET_UNIT_TESTS=ON -DTARGET_PERFORMANCE_TEST=ON -DJPH_USE_WASM64=ON
- name: Build
run: cmake --build ${{github.workspace}}/Build/WASM_Distribution -j $(nproc)
- name: Unit Tests
working-directory: ${{github.workspace}}/Build/WASM_Distribution
run: node --experimental-wasm-memory64 UnitTests.js
- name: Test ConvexVsMesh
working-directory: ${{github.workspace}}/Build/WASM_Distribution
run: node --experimental-wasm-memory64 PerformanceTest.js -q=LinearCast -t=max -s=ConvexVsMesh -validate_hash=${CONVEX_VS_MESH_HASH}
- name: Test Ragdoll
working-directory: ${{github.workspace}}/Build/WASM_Distribution
run: node --experimental-wasm-memory64 PerformanceTest.js -q=LinearCast -t=max -s=Ragdoll -validate_hash=${RAGDOLL_HASH}
- name: Test Pyramid
working-directory: ${{github.workspace}}/Build/WASM_Distribution
run: node --experimental-wasm-memory64 PerformanceTest.js -q=LinearCast -t=max -s=Pyramid -validate_hash=${PYRAMID_HASH}
- name: Test CharacterVirtual
working-directory: ${{github.workspace}}/Build/WASM_Distribution
run: node --experimental-wasm-memory64 PerformanceTest.js -q=Discrete -t=max -s=CharacterVirtual -validate_hash=${CHARACTER_VIRTUAL_HASH}
4 changes: 4 additions & 0 deletions Build/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ option(USE_FMADD "Enable FMADD" ON)
# See: https://caniuse.com/?search=WebAssembly%20SIMD (Safari got support in March 2023 and was the last major browser to get support).
option(USE_WASM_SIMD "Enable SIMD for WASM" OFF)

# Enable 64 bit WASM instead of the default 32 bit WASM. Note that this currently requires special commandline flags in browsers and nodejs to enable.
# E.g. use 'node --experimental-wasm-memory64 UnitTests.js' to run the unit tests in nodejs in 64 bit.
option(JPH_USE_WASM64 "Enable 64 bit WASM" OFF)

# Enable all warnings
option(ENABLE_ALL_WARNINGS "Enable all warnings and warnings as errors" ON)

Expand Down
3 changes: 2 additions & 1 deletion Docs/Architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,8 @@ It is quite difficult to verify cross platform determinism, so this feature is l
* Linux gcc RISC-V 64-bit
* Linux gcc PowerPC (Little Endian) 64-bit
* Linux gcc LoongArch 64-bit
* WASM emscripten running in nodejs
* WASM32 emscripten running in nodejs
* WASM64 emscripten running in nodejs

The most important things to look out for in your own application:

Expand Down
4 changes: 4 additions & 0 deletions Jolt/Jolt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,10 @@ else()
# Note that this does not require the browser to actually support SSE 4.2 it merely means that it can translate those instructions to WASM SIMD instructions
target_compile_options(Jolt PUBLIC -msimd128 -msse4.2)
endif()
if (JPH_USE_WASM64)
target_compile_options(Jolt PUBLIC -sMEMORY64)
target_link_options(Jolt PUBLIC -sMEMORY64)
endif()
elseif ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i386")
# x86 and x86_64
# On 32-bit builds we need to default to using SSE instructions, the x87 FPU instructions have higher intermediate precision
Expand Down

0 comments on commit 0634fe1

Please sign in to comment.