Using parfor and external program via network

5 visualizaciones (últimos 30 días)
J B
J B el 24 de Feb. de 2021
Respondida: Raymond Norris el 24 de Feb. de 2021
I'm using a simulation program (it's called "Gecko Circuits") to carry out a large number of simulations in loop. The program is running on java and is accessed via a network port. The steps I have to carry out are the following:
javaaddpath 'Some\path\on\the\machine\GeckoCIRCUITS.jar';
import('gecko.GeckoRemote.*');
startGui(PortNumber); % After this line, the GUI of the program opens
openFile([SimFolder, SimFile, '.ipes']); % This loads the simulation file
for j=1:100
for k=1:1000
connectToGecko(PortNumber); % Functions from the gecko package
setParameter(Some, Arguments);
runSimulation();
% Read back results and store them
res(j,k) = ...
end
end
This is working fine so far, however, it takes too long to carry out all the calculations in the loop. Therefore, I'd like parallel this (and run it locally on a server which provides suitable resources). To achieve this, I tried this:
javaaddpath 'Some\path\on\the\machine\GeckoCIRCUITS.jar';
import('gecko.GeckoRemote.*');
jMax = 100
GeckoAddr = 43035 + (0:1:(jMax-1));
for j=1:jMax
startGui(GeckoAddr(j));
openFile([SimFolder, SimFile, '.ipes']);
end
for j=1:100
parfor k=1:1000
gecko.GeckoRemote.connectToGecko(GeckoAddr(j));
gecko.GeckoRemote.setParameter(Some, Arguments);
gecko.GeckoRemote.runSimulation();
% Read back results and store them
res(j,k) = ...
end
end
The parfor loop causes a lot of troubles now. First I had a long time to find out, that the inside the parfor loops, the functions of the gecko package are not known anymore (the "import('gecko.GeckoRemote')" statement was apparently without effect inside the parfor loop). For this reason I had to put "gecko.GeckoRemote." in front of all the instructions. This is not really an issue, I just don't get the reason behind it.
The much bigger problem seems to be, that the different instances of the parfor loop mess up each other because while one instance is accessing Gecko at one port, another instance connects to another port, disconnecting the former instance of Gecko and mixing up data and commands of different simulations.
Unfortunately I don't no a lot neither about java nor about network ports. Is there any way how I can avoid this and make Matlab access several Gecko instances in parallel without them interfering?

Respuestas (1)

Raymond Norris
Raymond Norris el 24 de Feb. de 2021
The problem is that GeckoCIRCUITS must not allow for multiple running instances. I glanced through their doc, but don't see any mention of it. However, when I read through GeckMAGNETICS, it states
Note that only one connection is allowed at a time.
It's a bit of a reach, but I'm guessing the same applys to GeckoGIRCUITS.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by