MATLAB Answers

How to run multiple instances of MCR

31 views (last 30 days)
Mickey
Mickey on 16 Oct 2012
I have problem to solve how to run something parallel without using a parallel toolbox. (i'am using C# for my application)
I don't need some fast parallel operations ,i just want to run one simple function while other long process is running, and not to wait while this long process is over.
Mine one tought was to create two separate assemblies, and to call functions in from them..is it that possible and do i need to create separate wrappers for that assemblies, and how can i do that if it is possible!??

Accepted Answer

Friedrich
Friedrich on 16 Oct 2012
Edited: Friedrich on 16 Oct 2012
Hi,
no that is not possible. The MCR is process "bound" which means only MCR per process is allowed and in addition the MCR makes use of thread locking, so only one thread is allowed to access the MCR at a time.
If you need more MCR's consider .NET remoting:
Basically you set up small "server" processes which run the MCR and to which you talk to. Thats the only way to get more MCR's "into" your C# application.
However in R2012b there is a new toolbox called Matlab Production Server:
This thing is pretty awesome and makes it pretty easy to call compiled functions from different threads. But I guess buying Parallel Computing Toolbox should be cheaper than buying that beauty ;)
  1 Comment
Mickey
Mickey on 16 Oct 2012
Thanks you on fast replay, i think that i will go on with rewritting some of matlab methods to C++ :)

Sign in to comment.

More Answers (1)

owr
owr on 16 Oct 2012
I built something in the past as a test that was able to do this - if I recall it wasnt too difficult (and Im not very proficient in C#).
As Friedrich mentioned, the issue is that the MCR is process bound. So you need your C# application to launch/manage multiple processes.
The way I set it up is each MATLAB task had its own C# exe wrapped around it, I called these "worker1", "worker2" etc. Then I had a master C# application that could create processes independently and attach the workers to these processes.
Take a look on MSDN at the "Process" command in C#. Like I mentioned, I am quite inexperienced in C# but was able to get it all working in about a day, some time ago.
Hope this helps.

Products

Community Treasure Hunt

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

Start Hunting!

Translated by