Run multiple simulations in parallel using XML-RPC

Hello,

after some trouble, I can now use the XML-RPC interface to open and run PLECS-simulations from an external tool. But it seems, I can only run one simulation at once: set one parameter, run, wait for the result, modify parameter again, run again, wait for result, …Is is possible, to start multiple simulations on a multicore-system in parallel? I’d need to start PLECS with command line parameters like -multipleinstance -rpcport 1081 -nogui

Is this possible?

1 Like

Hello,Unfortunately this is not possible currently.

EDITED: Parallel simulation is now available natively in PLECS Standalone. Look at the “PLECS: Buck Converter with Parameter Sweep” demo model.Thank you,Kris

Well, I think, one could work around this by using a different user for each process. But this would cost too much extra-effort for my project.

So I would like to see such a feature soon :slight_smile:

One more idea: The float-to-string/string-to-float conversions and the XML parsing of the XML-RPC response costs a significant percentage of CPU-time. For transfering large result data arrays, a memory mapped buffer (shm_open+mmap for Linux, OpenFileMapping+MapViewOfFile for Windows) would be nice. The XML-RPC could then deliver the name and size of this file.

what happen if you run multiple file with different filename can be run in parallel?

hi I wrote a workarund in python to do that you can find on my github https://github.com/tinix84/pyplecs

*please delete this comment, I moved it to the the other sub-topic: https://forum.plexim.com/874/run-multiple-simulations-in-parallel-using-xml-rpc?show=1786#a1786
thx

I’ve hat some other projects to work on during Corona… Now I’m back :wink:

Well, I read through the Buck Converter with Parameter Sweep. The Command to run the simulation looks like

plecs('simulate', simStructs, @(index, data) callback(index, data))

where simStructs is not just one set of parameters to be modified but an array of such structs. Then there is a third parameter, I guess a pointer to a callback function. But how is this call done in XML-RPC?

I tried to clone the .plecs file with updated name-attribute. But when starting this in parallel, I get the error

Error: thread 1 Simulation error: method execution error:
       The server is busy executing the blocking command "simulate('test_0')".

test_0 is the file, generated by thread 0, which is running without problems.@tinivella What’s the trick in your python-script?

I dont know if PLECS changed the server structure,

simply my Python script handle the program pointer to interact the Plecs GUI with python instead of using the XML server.

For this I use pyautogui and os.path to duplicate the simulation files.

if you need we can do a teams session

Interesting. Yes, you can find me on https://mitjastachowiak.de/?/sonstiges/kontakt.html

Hope some of my contact ways work for you :wink: