Skip to content

Commit 1c4d857

Browse files
committed
chore(wasm-par-mq): add js fmt
1 parent 7e1a6ed commit 1c4d857

File tree

9 files changed

+331
-257
lines changed

9 files changed

+331
-257
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ fmt_js: check_nvm_installed
294294
nvm install $(NODE_VERSION) && \
295295
nvm use $(NODE_VERSION) && \
296296
$(MAKE) -C tfhe/web_wasm_parallel_tests fmt && \
297-
$(MAKE) -C tfhe/js_on_wasm_tests fmt
297+
$(MAKE) -C tfhe/js_on_wasm_tests fmt && \
298+
$(MAKE) -C utils/wasm-par-mq fmt
298299

299300
.PHONY: semgrep_lint_setup_venv # Create venv and install Python dependencies for GPU lint checks
300301
semgrep_lint_setup_venv:
@@ -344,7 +345,8 @@ check_fmt_js: check_nvm_installed
344345
nvm install $(NODE_VERSION) && \
345346
nvm use $(NODE_VERSION) && \
346347
$(MAKE) -C tfhe/web_wasm_parallel_tests check_fmt && \
347-
$(MAKE) -C tfhe/js_on_wasm_tests check_fmt
348+
$(MAKE) -C tfhe/js_on_wasm_tests check_fmt && \
349+
$(MAKE) -C utils/wasm-par-mq check_fmt
348350

349351
.PHONY: check_fmt_toml # Check TOML files format
350352
check_fmt_toml: install_taplo

utils/wasm-par-mq/Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.PHONY: fmt # Format Javascript code
2+
fmt:
3+
npm install
4+
npm run format
5+
6+
.PHONY: check_fmt # Check Javascript code format
7+
check_fmt:
8+
npm install
9+
npm run check-format

utils/wasm-par-mq/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ register_fn!(double, u32, u32);
3333
```
3434

3535
Current limitations (may be lifted in the future):
36+
3637
- Closures are not supported
3738
- Only functions with exactly one parameter are supported
3839

3940
### 2. Run parallel operations
41+
4042
At the call site, wrap the function in the `par_fn!` macro to retrieve its registry ID:
4143

4244
```rust
@@ -69,10 +71,10 @@ pub async fn init_parallel(
6971
```
7072

7173
```javascript
72-
import init, { init_parallel } from './pkg/your_crate.js';
74+
import init, { init_parallel } from "./pkg/your_crate.js";
7375

7476
await init();
75-
await init_parallel(4, './pkg/your_crate_bg.wasm', './pkg/your_crate.js');
77+
await init_parallel(4, "./pkg/your_crate_bg.wasm", "./pkg/your_crate.js");
7678
```
7779

7880
## Sync Executor
@@ -228,11 +230,11 @@ pub async fn init_parallel_sync(
228230
```
229231

230232
```javascript
231-
import init, { init_parallel_sync } from './pkg/your_crate.js';
233+
import init, { init_parallel_sync } from "./pkg/your_crate.js";
232234

233235
await init();
234236
// The coordinator_url must point to the coordinator.js deployed above.
235-
await init_parallel_sync(4, '/coordinator.js');
237+
await init_parallel_sync(4, "/coordinator.js");
236238
```
237239

238240
## API
Lines changed: 109 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,125 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
3-
<head>
4-
<meta charset="utf-8">
3+
<head>
4+
<meta charset="utf-8" />
55
<title>wasm-par-mq - MSM Benchmark</title>
66
<style>
7-
body {
8-
font-family: system-ui, sans-serif;
9-
max-width: 800px;
10-
margin: 50px auto;
11-
padding: 20px;
12-
}
13-
h1 { color: #333; }
14-
.test-section {
15-
background: #f5f5f5;
16-
padding: 20px;
17-
margin: 20px 0;
18-
border-radius: 8px;
19-
}
20-
button {
21-
background: #007bff;
22-
color: white;
23-
border: none;
24-
padding: 10px 20px;
25-
border-radius: 4px;
26-
cursor: pointer;
27-
margin: 5px;
28-
}
29-
button:hover { background: #0056b3; }
30-
button:disabled { background: #ccc; }
31-
label {
32-
margin-right: 20px;
33-
}
34-
select {
35-
padding: 5px 10px;
36-
border-radius: 4px;
37-
border: 1px solid #ccc;
38-
}
39-
.result {
40-
background: #e8f5e9;
41-
padding: 10px;
42-
margin-top: 10px;
43-
border-radius: 4px;
44-
font-family: monospace;
45-
white-space: pre-wrap;
46-
}
47-
.error {
48-
background: #ffebee;
49-
color: #c62828;
50-
}
51-
#status {
52-
padding: 10px;
53-
margin: 10px 0;
54-
border-radius: 4px;
55-
}
56-
.status-loading { background: #fff3e0; }
57-
.status-ready { background: #e8f5e9; }
58-
.status-error { background: #ffebee; }
7+
body {
8+
font-family: system-ui, sans-serif;
9+
max-width: 800px;
10+
margin: 50px auto;
11+
padding: 20px;
12+
}
13+
h1 {
14+
color: #333;
15+
}
16+
.test-section {
17+
background: #f5f5f5;
18+
padding: 20px;
19+
margin: 20px 0;
20+
border-radius: 8px;
21+
}
22+
button {
23+
background: #007bff;
24+
color: white;
25+
border: none;
26+
padding: 10px 20px;
27+
border-radius: 4px;
28+
cursor: pointer;
29+
margin: 5px;
30+
}
31+
button:hover {
32+
background: #0056b3;
33+
}
34+
button:disabled {
35+
background: #ccc;
36+
}
37+
label {
38+
margin-right: 20px;
39+
}
40+
select {
41+
padding: 5px 10px;
42+
border-radius: 4px;
43+
border: 1px solid #ccc;
44+
}
45+
.result {
46+
background: #e8f5e9;
47+
padding: 10px;
48+
margin-top: 10px;
49+
border-radius: 4px;
50+
font-family: monospace;
51+
white-space: pre-wrap;
52+
}
53+
.error {
54+
background: #ffebee;
55+
color: #c62828;
56+
}
57+
#status {
58+
padding: 10px;
59+
margin: 10px 0;
60+
border-radius: 4px;
61+
}
62+
.status-loading {
63+
background: #fff3e0;
64+
}
65+
.status-ready {
66+
background: #e8f5e9;
67+
}
68+
.status-error {
69+
background: #ffebee;
70+
}
5971
</style>
60-
</head>
61-
<body>
72+
</head>
73+
<body>
6274
<h1>wasm-par-mq - MSM Benchmark</h1>
6375

6476
<div id="status" class="status-loading">Loading WASM...</div>
6577

6678
<div class="test-section">
67-
<h2>Configuration</h2>
68-
<label>
69-
Number of workers:
70-
<select id="worker-count">
71-
<option value="1">1 worker</option>
72-
<option value="2">2 workers</option>
73-
<option value="4" selected>4 workers</option>
74-
<option value="8">8 workers</option>
75-
<option value="16">16 workers</option>
76-
</select>
77-
</label>
78-
<label>
79-
Mode:
80-
<select id="pool-mode">
81-
<option value="async" selected>Async</option>
82-
<option value="sync">Sync Executor</option>
83-
</select>
84-
</label>
85-
<span id="pool-status"></span>
79+
<h2>Configuration</h2>
80+
<label>
81+
Number of workers:
82+
<select id="worker-count">
83+
<option value="1">1 worker</option>
84+
<option value="2">2 workers</option>
85+
<option value="4" selected>4 workers</option>
86+
<option value="8">8 workers</option>
87+
<option value="16">16 workers</option>
88+
</select>
89+
</label>
90+
<label>
91+
Mode:
92+
<select id="pool-mode">
93+
<option value="async" selected>Async</option>
94+
<option value="sync">Sync Executor</option>
95+
</select>
96+
</label>
97+
<span id="pool-status"></span>
8698
</div>
8799

88100
<div class="test-section">
89-
<h2>Multi-Scalar Multiplication (MSM)</h2>
90-
<p>Compute MSM on a set of points and scalars</p>
91-
<label>
92-
Number of elements:
93-
<select id="msm-len">
94-
<option value="1000">1,000</option>
95-
<option value="5000">5,000</option>
96-
<option value="10000" selected>10,000</option>
97-
<option value="50000">50,000</option>
98-
<option value="100000">100,000</option>
99-
</select>
100-
</label>
101-
<br><br>
102-
<button id="btn-msm-parallel" disabled>Run Parallel (workers)</button>
103-
<button id="btn-msm-sync" disabled>Run Sync Executor</button>
104-
<button id="btn-msm-sequential" disabled>Run Sequential (main thread)</button>
105-
<button id="btn-msm-compare" disabled>Compare Results</button>
106-
<div id="result-msm" class="result" hidden></div>
101+
<h2>Multi-Scalar Multiplication (MSM)</h2>
102+
<p>Compute MSM on a set of points and scalars</p>
103+
<label>
104+
Number of elements:
105+
<select id="msm-len">
106+
<option value="1000">1,000</option>
107+
<option value="5000">5,000</option>
108+
<option value="10000" selected>10,000</option>
109+
<option value="50000">50,000</option>
110+
<option value="100000">100,000</option>
111+
</select>
112+
</label>
113+
<br /><br />
114+
<button id="btn-msm-parallel" disabled>Run Parallel (workers)</button>
115+
<button id="btn-msm-sync" disabled>Run Sync Executor</button>
116+
<button id="btn-msm-sequential" disabled>
117+
Run Sequential (main thread)
118+
</button>
119+
<button id="btn-msm-compare" disabled>Compare Results</button>
120+
<div id="result-msm" class="result" hidden></div>
107121
</div>
108122

109-
</body>
110123
<script src="./index.js"></script>
124+
</body>
111125
</html>

0 commit comments

Comments
 (0)