Skip to content

Commit 4b48649

Browse files
committed
add comments, lower iterations, check profiles roughly match
1 parent 105ce7a commit 4b48649

File tree

8 files changed

+25
-35
lines changed

8 files changed

+25
-35
lines changed

JetStreamDriver.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1931,7 +1931,8 @@ const testPlans = [
19311931
wasmBinary: "./wasm/richards/build/richards.wasm"
19321932
},
19331933
benchmarkClass: WasmEMCCBenchmark,
1934-
iterations: 30,
1934+
iterations: 20,
1935+
worstCaseCount: 2,
19351936
testGroup: WasmGroup
19361937
},
19371938
{

wasm/richards/benchmark.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,26 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
function scheduleIter() {
6-
return Module._scheduleIter();
7-
}
8-
95
class Benchmark {
106
async runIteration() {
11-
if (!Module._main)
7+
// Instantiate the Wasm module before the first run.
8+
if (!Module._setup)
129
await setupModule(Module);
1310

11+
// Set-up the problem (fill the work queue) on each run.
1412
Module._setup();
13+
14+
// Repeatedly call into Wasm to stress test JS-to-Wasm call performance.
15+
// I (dlehmann) suppose this wrapper was added (originally in JetStream 2)
16+
// to test that a wrapping JavaScript function doesn't slow things down.
17+
function scheduleIter() {
18+
return Module._scheduleIter();
19+
}
1520
while (scheduleIter()) {}
1621
}
1722

1823
validate() {
19-
if (Module._getQpktcount() !== 2326410 || Module._getHoldcount() !== 930563)
24+
if (!Module._validate())
2025
throw new Error("Bad richards result!");
2126
}
2227
}

wasm/richards/build.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Built on 2025-01-16T15:10:49Z
1+
Built on 2025-01-20T14:41:13Z
22
Toolchain versions
33
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.73 (ac676d5e437525d15df5fd46bc2c208ec6d376a3)
44
Building...

wasm/richards/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ emcc -o build/richards.js \
1515
-s WASM=1 -O2 -s TOTAL_MEMORY=83886080 \
1616
-g1 --emit-symbol-map \
1717
-s MODULARIZE=1 \
18-
-s EXPORT_NAME=setupModule -s EXPORTED_FUNCTIONS=_setup,_getHoldcount,_scheduleIter,_getQpktcount \
18+
-s EXPORT_NAME=setupModule -s EXPORTED_FUNCTIONS=_setup,_scheduleIter,_validate \
1919
richards.c | tee -a "$BUILD_LOG"
2020

2121
echo "Building done" | tee -a "$BUILD_LOG"

wasm/richards/build/richards.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,7 @@ var _scheduleIter = Module["_scheduleIter"] = () => (_scheduleIter = Module["_sc
539539

540540
var _setup = Module["_setup"] = () => (_setup = Module["_setup"] = wasmExports["setup"])();
541541

542-
var _getQpktcount = Module["_getQpktcount"] = () => (_getQpktcount = Module["_getQpktcount"] = wasmExports["getQpktcount"])();
543-
544-
var _getHoldcount = Module["_getHoldcount"] = () => (_getHoldcount = Module["_getHoldcount"] = wasmExports["getHoldcount"])();
542+
var _validate = Module["_validate"] = () => (_validate = Module["_validate"] = wasmExports["validate"])();
545543

546544
var __emscripten_stack_restore = a0 => (__emscripten_stack_restore = wasmExports["_emscripten_stack_restore"])(a0);
547545

wasm/richards/build/richards.js.symbols

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
5:handlerfn
77
6:devfn
88
7:setup
9-
8:getQpktcount
10-
9:getHoldcount
11-
10:emscripten_builtin_malloc
12-
11:sbrk
13-
12:_emscripten_stack_restore
14-
13:_emscripten_stack_alloc
15-
14:emscripten_stack_get_current
9+
8:validate
10+
9:emscripten_builtin_malloc
11+
10:sbrk
12+
11:_emscripten_stack_restore
13+
12:_emscripten_stack_alloc
14+
13:emscripten_stack_get_current

wasm/richards/build/richards.wasm

-11 Bytes
Binary file not shown.

wasm/richards/richards.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// $ emcc -o richards.html -O2 -s TOTAL_MEMORY=83886080 -g1 -s "EXPORTED_FUNCTIONS=[_setup, _getHoldcount, _scheduleIter, _getQpktcount, _main]" ./richards.c
1+
// $ emcc -o richards.html -O2 -s TOTAL_MEMORY=83886080 -g1 -s "EXPORTED_FUNCTIONS=[_setup, _scheduleIter, _validate]" ./richards.c
22

33
#include <emscripten.h>
44

@@ -370,20 +370,7 @@ void setup()
370370
layout = 0;
371371
}
372372

373-
int getQpktcount()
373+
int validate()
374374
{
375-
return qpktcount;
375+
return qpktcount == Qpktcountval && holdcount == Holdcountval;
376376
}
377-
378-
int getHoldcount()
379-
{
380-
return holdcount;
381-
}
382-
383-
int main()
384-
{
385-
EM_ASM( runRichards() );
386-
387-
return 0;
388-
}
389-

0 commit comments

Comments
 (0)