Skip to content

Commit 4471fa6

Browse files
committed
Make workload size for richards-wasm a runtime input
1 parent 0260caf commit 4471fa6

File tree

7 files changed

+26
-23
lines changed

7 files changed

+26
-23
lines changed

wasm/richards/benchmark.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ class Benchmark {
99
await setupModule(Module);
1010

1111
// Set-up the problem (fill the work queue) on each run.
12-
Module._setup();
12+
const taskCount = 200_000;
13+
Module._setup(taskCount);
1314

1415
// Repeatedly call into Wasm to stress test JS-to-Wasm call performance.
1516
// I (dlehmann) suppose this wrapper was added (originally in JetStream 2)
@@ -21,7 +22,7 @@ class Benchmark {
2122
}
2223

2324
validate() {
24-
if (!Module._validate())
25+
if (Module._getQpktcount() !== 465212 || Module._getHoldcount() !== 186084)
2526
throw new Error("Bad richards result!");
2627
}
2728
}

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-29T18:38:57Z
1+
Built on 2025-02-10T17:28:11Z
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,_scheduleIter,_validate \
18+
-s EXPORT_NAME=setupModule -s EXPORTED_FUNCTIONS=_setup,_scheduleIter,_getQpktcount,_getHoldcount \
1919
richards.c | tee -a "$BUILD_LOG"
2020

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

wasm/richards/build/richards.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,11 @@ var ___wasm_call_ctors = () => (___wasm_call_ctors = wasmExports["__wasm_call_ct
537537

538538
var _scheduleIter = Module["_scheduleIter"] = () => (_scheduleIter = Module["_scheduleIter"] = wasmExports["scheduleIter"])();
539539

540-
var _setup = Module["_setup"] = () => (_setup = Module["_setup"] = wasmExports["setup"])();
540+
var _setup = Module["_setup"] = a0 => (_setup = Module["_setup"] = wasmExports["setup"])(a0);
541541

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

544546
var __emscripten_stack_restore = a0 => (__emscripten_stack_restore = wasmExports["_emscripten_stack_restore"])(a0);
545547

wasm/richards/build/richards.js.symbols

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
5:handlerfn
77
6:devfn
88
7:setup
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
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

wasm/richards/build/richards.wasm

12 Bytes
Binary file not shown.

wasm/richards/richards.c

Lines changed: 10 additions & 11 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, _scheduleIter, _validate]" ./richards.c
1+
// $ emcc -o richards.html -O2 -s TOTAL_MEMORY=83886080 -g1 -s "EXPORTED_FUNCTIONS=[_setup, _scheduleIter, _getQpktcount, _getHoldcount]" ./richards.c
22

33
#include <emscripten.h>
44

@@ -15,12 +15,6 @@
1515
#include <stdio.h>
1616
#include <stdlib.h>
1717

18-
#if 1
19-
#define Count 200000
20-
#define Qpktcountval 465212
21-
#define Holdcountval 186084
22-
#endif
23-
2418
#define TRUE 1
2519
#define FALSE 0
2620
#define MAXINT 32767
@@ -335,11 +329,11 @@ void append(struct packet *pkt, struct packet *ptr)
335329
ptr->p_link = pkt;
336330
}
337331

338-
void setup()
332+
void setup(int count)
339333
{
340334
struct packet *wkq = 0;
341335

342-
createtask(I_IDLE, 0, wkq, S_RUN, idlefn, 1, Count);
336+
createtask(I_IDLE, 0, wkq, S_RUN, idlefn, 1, count);
343337

344338
wkq = pkt(0, 0, K_WORK);
345339
wkq = pkt(wkq, 0, K_WORK);
@@ -370,7 +364,12 @@ void setup()
370364
layout = 0;
371365
}
372366

373-
int validate()
367+
int getQpktcount()
368+
{
369+
return qpktcount;
370+
}
371+
372+
int getHoldcount()
374373
{
375-
return qpktcount == Qpktcountval && holdcount == Holdcountval;
374+
return holdcount;
376375
}

0 commit comments

Comments
 (0)