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

Make workload size for richards-wasm a runtime input #45

Merged
merged 1 commit into from
Feb 10, 2025
Merged
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
5 changes: 3 additions & 2 deletions wasm/richards/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class Benchmark {
await setupModule(Module);

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

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

validate() {
if (!Module._validate())
if (Module._getQpktcount() !== 465212 || Module._getHoldcount() !== 186084)
throw new Error("Bad richards result!");
}
}
2 changes: 1 addition & 1 deletion wasm/richards/build.log
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Built on 2025-01-29T18:38:57Z
Built on 2025-02-10T17:28:11Z
Toolchain versions
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.73 (ac676d5e437525d15df5fd46bc2c208ec6d376a3)
Building...
Expand Down
2 changes: 1 addition & 1 deletion wasm/richards/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ emcc -o build/richards.js \
-s WASM=1 -O2 -s TOTAL_MEMORY=83886080 \
-g1 --emit-symbol-map \
-s MODULARIZE=1 \
-s EXPORT_NAME=setupModule -s EXPORTED_FUNCTIONS=_setup,_scheduleIter,_validate \
-s EXPORT_NAME=setupModule -s EXPORTED_FUNCTIONS=_setup,_scheduleIter,_getQpktcount,_getHoldcount \
richards.c | tee -a "$BUILD_LOG"

echo "Building done" | tee -a "$BUILD_LOG"
6 changes: 4 additions & 2 deletions wasm/richards/build/richards.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,11 @@ var ___wasm_call_ctors = () => (___wasm_call_ctors = wasmExports["__wasm_call_ct

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

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

var _validate = Module["_validate"] = () => (_validate = Module["_validate"] = wasmExports["validate"])();
var _getQpktcount = Module["_getQpktcount"] = () => (_getQpktcount = Module["_getQpktcount"] = wasmExports["getQpktcount"])();

var _getHoldcount = Module["_getHoldcount"] = () => (_getHoldcount = Module["_getHoldcount"] = wasmExports["getHoldcount"])();

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

Expand Down
13 changes: 7 additions & 6 deletions wasm/richards/build/richards.js.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
5:handlerfn
6:devfn
7:setup
8:validate
9:emscripten_builtin_malloc
10:sbrk
11:_emscripten_stack_restore
12:_emscripten_stack_alloc
13:emscripten_stack_get_current
8:getQpktcount
9:getHoldcount
10:emscripten_builtin_malloc
11:sbrk
12:_emscripten_stack_restore
13:_emscripten_stack_alloc
14:emscripten_stack_get_current
Binary file modified wasm/richards/build/richards.wasm
Binary file not shown.
21 changes: 10 additions & 11 deletions wasm/richards/richards.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// $ emcc -o richards.html -O2 -s TOTAL_MEMORY=83886080 -g1 -s "EXPORTED_FUNCTIONS=[_setup, _scheduleIter, _validate]" ./richards.c
// $ emcc -o richards.html -O2 -s TOTAL_MEMORY=83886080 -g1 -s "EXPORTED_FUNCTIONS=[_setup, _scheduleIter, _getQpktcount, _getHoldcount]" ./richards.c

#include <emscripten.h>

Expand All @@ -15,12 +15,6 @@
#include <stdio.h>
#include <stdlib.h>

#if 1
#define Count 200000
#define Qpktcountval 465212
#define Holdcountval 186084
#endif

#define TRUE 1
#define FALSE 0
#define MAXINT 32767
Expand Down Expand Up @@ -335,11 +329,11 @@ void append(struct packet *pkt, struct packet *ptr)
ptr->p_link = pkt;
}

void setup()
void setup(int count)
{
struct packet *wkq = 0;

createtask(I_IDLE, 0, wkq, S_RUN, idlefn, 1, Count);
createtask(I_IDLE, 0, wkq, S_RUN, idlefn, 1, count);

wkq = pkt(0, 0, K_WORK);
wkq = pkt(wkq, 0, K_WORK);
Expand Down Expand Up @@ -370,7 +364,12 @@ void setup()
layout = 0;
}

int validate()
int getQpktcount()
{
return qpktcount;
}

int getHoldcount()
{
return qpktcount == Qpktcountval && holdcount == Holdcountval;
return holdcount;
}