Kernel executables seem to be relatively small wrappers around "dynamic link library" that contains all the functionality of the kernel.

Is it possible to load the kernel (as a dynamic link library) and interact with it via LibraryLink/WSTP?

The idea is to avoid IPC overhead.

  • $\begingroup$ 1. You can do the reverse: load a dynamic library into the kernel. 2. There is a small part of the kernel that can be loaded as a dynamic library. It's used when creating standalone Compiled exetuables. I have next to no experience with this because the functionality that's available is quite limited. $\endgroup$
    – Szabolcs
    Commented Dec 4, 2021 at 17:59
  • $\begingroup$ The end of this guide has an example for generating standalone executables: reference.wolfram.com/language/CCodeGenerator/tutorial/… $\endgroup$
    – Szabolcs
    Commented Dec 4, 2021 at 18:01
  • $\begingroup$ I understand your point but this is the well-known problem: EVERY system wants to be THE executable :) WRI itself loads java rt as a dll into JLink. Sometimes you have to behave like someones shared library or leave :) $\endgroup$ Commented Dec 4, 2021 at 19:10
  • $\begingroup$ I'm not arguing with your point, I know the pain. I think Mathematica does relatively well in that it explicitly supports being controlled from another system using MathLink. I am not aware of any solution that gives access to the full power of Mathematica does avoid IPC $\endgroup$
    – Szabolcs
    Commented Dec 4, 2021 at 19:43
  • 1
    $\begingroup$ Don't use "TCPIP". Use "SharedMemory". If you benchmark this, let me know, I'm curious. But it should be much faster. There are other tricks to getting good performance with MathLink too, e.g. there are multiple formats for sending/receiving a list. Numeric lists have fast dedicated functions. Unfortunately, some of the facilities that are needed to make this work are not documented ... see here on how we figured out how to detect if we can safely receive a packed array ... mathematica.stackexchange.com/q/180706/12 $\endgroup$
    – Szabolcs
    Commented Dec 4, 2021 at 21:38


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.