2

I'm trying to run a MATLAB script using parfor which runs a simulink model in parallel by sim function, and this simulink model contains a MATLAB Function Block.

The function defined in this block calls a python function using "py." mechanism.

Unfortunately, the run sometimes seems stuck in the middle, when I fed a large number of simulations. The debugging output stops to show up. I suspect a deadlock somewhere.

So, my questions are

  • Can we run a simulink model which contains python functions in parallel?
  • In what way MATLAB calls the python interpreter? One for each MATLAB worker or One for the entire MATLAB?

I use MATLAB R2017b on Mac.

Addition of March 22, 2018: I contacted to the support and they responded that calling a python function from a MATLAB function block in a simulink model is not supported and anything can happens. Still I'm interested in how MATLAB interacts with (a) python interpreter(s). Is there a single python interpreter which interacts with the whole MATLAB or are there multiple python instances for all MATLAB workers?

Addition of April 22, 2018: Updating MATLAB 2018a seems fix the problem

  • 1
    Good question indeed. What I know is that it is incredibly hard (if at all possible) to have several python sub-interpreters working in parallel due to the Global Interpreter Lock (https://wiki.python.org/moin/GlobalInterpreterLock). Depending of the amont of effort to port the python code to matlab script, it may be the easier and quickest way to solve your issue. – sandwood Apr 19 '18 at 08:51
  • 1
    I suggest you put a schema to help understanding the architecture of your problem – sandwood Apr 19 '18 at 08:57

0 Answers0