How to run multiple instances of MCR

20 ビュー (過去 30 日間)
Mickey
Mickey 2012 年 10 月 16 日
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!??

採用された回答

Friedrich
Friedrich 2012 年 10 月 16 日
編集済み: Friedrich 2012 年 10 月 16 日
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 件のコメント
Mickey
Mickey 2012 年 10 月 16 日
Thanks you on fast replay, i think that i will go on with rewritting some of matlab methods to C++ :)

サインインしてコメントする。

その他の回答 (1 件)

owr
owr 2012 年 10 月 16 日
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.

カテゴリ

Help Center および File ExchangeInstallation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by