Is it possible for a C program to communicate (via WSTP) with both a Mathematica kernel running on its machine, and a remote one?
For context: I use a local Mathematica kernel which talks to a remote C process (via WSTP) which runs all the heavy computation. These computations involve modifying big data sets which live entirely in the memory of the remote C process. I now need to perform some calculations in Mathematica on these data sets; sending the data back and forth between the remote C process and my local Mathematica kernel is untenably slow. It would be much better if instead, I could send the Mathematica expressions themselves to the remote C process, which would evaluate them on its data by passing the data and expression to a local Mathematica kernel.
This way, the big data sets don't need to be shared across a network; they would only be passed between the C program and the local (to it) kernel. The (small) result of the analysis would then be sent back to my (remote) kernel.
Is that at all possible using WSTP? It's not obvious to me how the C code can communicate with multiple kernels of any kind, since there's only one MathLink instance in the global namespace (as stdlink
).
mprep
and template files, where argument translation and return is handled mostly automatically for you. $\endgroup$