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

Change plugin-wasm to include outputVarIds in the generated module #481

Closed
chrispcampbell opened this issue May 9, 2024 · 1 comment · Fixed by #482 or #476
Closed

Change plugin-wasm to include outputVarIds in the generated module #481

chrispcampbell opened this issue May 9, 2024 · 1 comment · Fixed by #482 or #476

Comments

@chrispcampbell
Copy link
Contributor

Currently we have a roundabout way of initializing a WasmModel, where you have to pass the array of OutputVarId to initWasmModelAndBuffers. This adds to complexity in plugin-worker, where it has some special code to inject the outputVarIds into the generated worker.

If we instead change plugin-wasm to include the outputVarIds inside the generated wasm-model.js file (created by Emscripten), we can simplify the process of initializing a WasmModel.

Emscripten has a --pre-js argument that allows for injecting arbitrary code into the generated module, which we can use for this purpose.

This will be a simple change to plugin-wasm only for now; the generated module will continue to be compatible with the existing initialization process, but doing this change first will allow for further simplification in an upcoming PR.

@chrispcampbell
Copy link
Contributor Author

chrispcampbell commented May 9, 2024

With this change, plugin-wasm now generates a processed_outputs.js file into sde-prep/build that looks like this:

Module["outputVarIds"] = ["_y", "_z"];

Using emcc --pre-js build/processed-outputs.js will cause that file to be folded into the generated wasm-model.js file:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment