How to use Matlab Engine by multiple processes with Visual Studio + Fortran + MPI

2 views (last 30 days)
Hello,
summary: MPI multiple processes created by the same actual core may access the data in the same matlab engine session, although each process opens its own session with a unique engine identifier. Why and how to fix it?
I have set up matlab engine and MPICH in Visual Studio 2010 with an Intel Fortran compiler.
The matlab engine works fine in the parallel code when debugging with "$(TargetPath)" in the commend line (basically it runs like a serial code, although it is MPI parallel code), you would see the matlab workspace and figures drawn by the code. Each process will open and close its own matlab engine, by engOpen, engClose.
However, I got 2 problems:
(1) if debugging with "D:\Program Files\MPICH2\bin\mpiexec.exe" in the command line with "-n 1 $(TargetPath)" as the command argument, the matlab engine still works, but as a background program, doesn't pop out the matlab workspace and any figures I intend to draw.
(2) if debugging with "-n 2 $(TargetPath)" (or more processes on my dual-core pc), when the multiple processes were actually created by one core, the get-t-variable engine function would get data from another process's engine session; when they are created by different cores, it is right; when a if-condition was used to let only one(any process) to work the engine, it is right. I checked, that these multiple processes have unique engine identifier.

Answers (0)

Categories

Find more on Fortran with MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!