c++ shared library startup options

9 views (last 30 days)
kjetil87
kjetil87 on 19 Aug 2013
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!

Answers (1)

Kaustubha Govind
Kaustubha Govind on 19 Aug 2013
It looks like specifying the -singleCompThread option during compilation should also work.
For example:
>> mcc -R -singleCompThread -mv foo.m
  3 Comments
Kaustubha Govind
Kaustubha Govind on 20 Aug 2013
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 on 20 Aug 2013
Edited: kjetil87 on 20 Aug 2013
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 ! :)

Sign in to comment.

Categories

Find more on C Shared Library Integration 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!