필터 지우기
필터 지우기

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 CenterFile Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by