Skip to content

Revisit interface between JS runtime package and generated C model #302

@chrispcampbell

Description

@chrispcampbell

One of the things I'd like to address before we have a "1.0" of SDE is the exported API of the C model. I'm not planning to make these changes right away, but wanted to create this issue to start documenting/discussing.

Originally there was one primary entrypoint in the C API that worked with string data (this one used setInputs in the generated model):

char* run_model(const char* inputs);

Later I added an alternate entrypoint that takes pointers to pre-allocated double buffers to have more optimal communication between the JS-level runtime code and the wasm model (this one used a new setInputsFromBuffers in the generated model):

void runModelWithBuffers(double* inputs, double* outputs);

Besides the awkward naming of the new ones (to avoid conflicting with the old), it would be preferable to have only one way of doing things, both to simplify the implementation and to make the API less confusing.

I think we could probably reimplement the old string-based API as a higher-level thing that's written to use a lower-level one (more like runModelWithBuffers).

There may be other changes we could make to the C API (in model.c) and in the generated C code that is related to the above; we can note them in comments in this issue and then maybe figure out a plan for this once we have time to think things through.

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions