We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6197322 commit 9ac780bCopy full SHA for 9ac780b
cmake/templates/index.html.in
@@ -12,7 +12,7 @@
12
if (typeof Module !== 'undefined') {
13
Module.onRuntimeInitialized = function() {
14
// Optionally, pass arguments to main in an array.
15
- Module._main([]);
+ Module.ccall('main', 'number', [], [], { async: true });
16
};
17
} else {
18
console.error('Module is undefined. Check that your generated JS file is loaded properly.');
examples/hello_world/run.cpp
@@ -38,12 +38,14 @@ int main(int argc, char **argv) {
38
Tensor output = createTensor(ctx, Shape{N}, kf32);
39
std::promise<void> promise;
40
std::future<void> future = promise.get_future();
41
- Kernel op = createKernel(ctx, {kGelu, 256, kf32},
+ std::future<Kernel> kernelFuture = createKernel(ctx, {kGelu, 256, kf32},
42
Bindings{input, output},
43
{cdiv(N, 256), 1, 1});
44
- dispatchKernel(ctx, op, promise);
45
- wait(ctx, future);
46
- toCPU(ctx, output, outputArr.data(), sizeof(outputArr));
+ Kernel op = waitForFuture(ctx.instance, kernelFuture);
+ std::future<void> dispatchFuture = dispatchKernel(ctx, op);
+ waitForFuture(ctx.instance, dispatchFuture);
47
+ std::future<void> cpuFuture = toCPU(ctx, output, outputArr.data(), sizeof(outputArr));
48
+ waitForFuture(ctx.instance, cpuFuture);
49
for (int i = 0; i < 12; ++i) {
50
printf(" gelu(%.2f) = %.2f\n", inputArr[i], outputArr[i]);
51
}
0 commit comments