Skip to content
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
13 changes: 5 additions & 8 deletions wasm/build.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash
# Build quant.cpp WASM demo
# pthreads for parallel matmul + SIMD + ASYNCIFY for UI streaming
# SIMD + ASYNCIFY for streaming (no pthreads — conflicts with ASYNCIFY sleep)
set -e

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"

echo "=== Building quant.cpp WASM (pthreads + SIMD) ==="
echo "=== Building quant.cpp WASM (SIMD + ASYNCIFY) ==="

if ! command -v emcc &>/dev/null; then
echo "Error: emcc not found. Install Emscripten SDK."
Expand All @@ -22,24 +22,21 @@ emcc "$SCRIPT_DIR/quant_wasm.c" \
-msimd128 \
-mrelaxed-simd \
-flto \
-pthread \
-s WASM=1 \
-s INITIAL_MEMORY=256MB \
-s MAXIMUM_MEMORY=4GB \
-s ALLOW_MEMORY_GROWTH=1 \
-s MAXIMUM_MEMORY=4GB \
-s INITIAL_MEMORY=256MB \
-s EXPORTED_FUNCTIONS='["_main","_wasm_load_model","_wasm_generate","_wasm_generate_async","_wasm_model_info","_wasm_is_ready","_malloc","_free"]' \
-s EXPORTED_RUNTIME_METHODS='["UTF8ToString","allocateUTF8","FS"]' \
-s FORCE_FILESYSTEM=1 \
-s MODULARIZE=0 \
-s ENVIRONMENT='web,worker' \
-s ENVIRONMENT=web \
-s NO_EXIT_RUNTIME=1 \
-s ASSERTIONS=0 \
-s STACK_SIZE=1MB \
-s ASYNCIFY \
-s 'ASYNCIFY_IMPORTS=["emscripten_sleep"]' \
-s ASYNCIFY_STACK_SIZE=65536 \
-s PTHREAD_POOL_SIZE=4 \
-s PTHREAD_POOL_SIZE_STRICT=0 \
-lm \
-DNDEBUG \
-D__EMSCRIPTEN__ \
Expand Down
2 changes: 1 addition & 1 deletion wasm/quant.js

Large diffs are not rendered by default.

Binary file modified wasm/quant.wasm
Binary file not shown.
Loading