c++ shared library startup options

3 ビュー (過去 30 日間)
kjetil87
kjetil87 2013 年 8 月 19 日
Hi everyone. I have a question regarding compilation of c++ shared libraries and multithreading.
When creating a standalone executable i know that it is possible to specify startup option (i mostly use deploytool)
-singleCompThread
to make sure that each MCR can only have one active computational thread.
As for C++ shared libraries i am not quite sure how this works. If i do not specify anything do the dll enable multiple threads?
and if so, how can i make sure that the shared library only uses one thread?
The project calling the c++ library is going to start several instances at once, and from testing with a standalone executable (and a .bat file) i have found out that the most effective way was to enable hyperthreading on my PC but only allow a single computational thread inside the matlab executable and run 8 instances at once ( i have 4 physical cores that turns into "8" when hyperthreaded ).
I have been searching the web for quite some time now and i cant find any examples that uses -singlecompthread for c++. The closest i got was the function
mclInitializeApplication
is this where -singleCompThread should be specified?
Any tips or clarifications would be highly appreciated as i am not very familiar with C++.
Thx in advance!

回答 (1 件)

Kaustubha Govind
Kaustubha Govind 2013 年 8 月 19 日
It looks like specifying the -singleCompThread option during compilation should also work.
For example:
>> mcc -R -singleCompThread -mv foo.m
  3 件のコメント
Kaustubha Govind
Kaustubha Govind 2013 年 8 月 20 日
Ah! Sorry that didn't work. I'm not sure what else to recommend here. If you don't receive any other replies on this forum, you may want to contact MathWorks Tech Support.
kjetil87
kjetil87 2013 年 8 月 20 日
編集済み: kjetil87 2013 年 8 月 20 日
Update: I have now created a C++ program to call my test library. It seems that
mclInitializeApplication
recognizes the command.
const char *opts[]={"-singleCompThread"};
mclInitializeApplication(opts, 1);
I tried giving a bogus character line instead of singleCompThread and then i got an error. I am still struggling to see the difference in core activity whether i specify this command or not but i guess it would have thrown an error if it didnt do anything.
Still im quite puzzled by all of this, because in the mathworks documentation of this function -singleCompThread is not listed as an option (but e.g -nojvm is, so thats why i assumed it should be given here). If anyone comes across any good information about this subject i would love to hear it ! :)

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

カテゴリ

Help Center および File ExchangeParallel Computing Fundamentals についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by