Thread Subject: single-threaded compiled matlab

Subject: single-threaded compiled matlab

From: Steve Rennie

Date: 25 Sep, 2009 15:48:00

Message: 1 of 4

Is it possible to make compiled matlab for version 7.8 (2009a) or later single-threaded?

The maxNumCompThreads function apparently is no longer supported, and compiling inside matlab with the -singleCompThread specified, not surprisingly, does not work.

Thanks for your help.

Steve

Subject: single-threaded compiled matlab

From: Shaf

Date: 28 Sep, 2009 15:32:02

Message: 2 of 4

"Steve Rennie" <srennie89@hotmail.com> wrote in message <h9iong$b9g$1@fred.mathworks.com>...
> Is it possible to make compiled matlab for version 7.8 (2009a) or later single-threaded?
>
> The maxNumCompThreads function apparently is no longer supported, and compiling inside matlab with the -singleCompThread specified, not surprisingly, does not work.
>
> Thanks for your help.
>
> Steve

Hi Steve,

Are you building a standalone or a shared library? For shared libraries you can pass "-singleCompThread" to mclInitializeApplication as an option. In the case of standalone you can compile with

mcc -R -singleCompThread -mv foo.m

====================
function foo
maxNumCompThreads
====================

If you run the compiled exe you will see 1 being printed.

Thanks,
Shaf

Subject: single-threaded compiled matlab

From: Nora

Date: 1 Feb, 2012 10:58:09

Message: 3 of 4

Hi,

I have similar problems. I want to compile a matlab function to stand-alone program with mcc. What I do is to start matlab as

matlab -singleCompThread

Then on the command line I execute

mcc -m -v -R singleCompThread -R nojvm -R nodesktop -R nosplash myFunction.m

Everything compiles, but when I run myFunction, I still see that it uses more than 100% processor (more than one processor).
I also added the lines

LASTN = maxNumCompThreads(1);
disp(['currently allowed comp threads are: ',num2str(maxNumCompThreads)]);

to the begin of myFunction. The number displayed is indeed 1, but processor use goes up to above 600% again.
Please let me know if I did something wrong, or you have further ideas to try out. I would like to run my code on a cluster, thus it is really important to have it single threaded.
I use Matlab 2011b, 64 bit, unix operating system

Thank you



"Shaf " <shafquat.rahman@mathworks.com> wrote in message <h9qkti$14m$1@fred.mathworks.com>...
> "Steve Rennie" <srennie89@hotmail.com> wrote in message <h9iong$b9g$1@fred.mathworks.com>...
> > Is it possible to make compiled matlab for version 7.8 (2009a) or later single-threaded?
> >
> > The maxNumCompThreads function apparently is no longer supported, and compiling inside matlab with the -singleCompThread specified, not surprisingly, does not work.
> >
> > Thanks for your help.
> >
> > Steve
>
> Hi Steve,
>
> Are you building a standalone or a shared library? For shared libraries you can pass "-singleCompThread" to mclInitializeApplication as an option. In the case of standalone you can compile with
>
> mcc -R -singleCompThread -mv foo.m
>
> ====================
> function foo
> maxNumCompThreads
> ====================
>
> If you run the compiled exe you will see 1 being printed.
>
> Thanks,
> Shaf

Subject: single-threaded compiled matlab

From: Nora

Date: 1 Feb, 2012 14:24:10

Message: 4 of 4

I solved my problem! I post it, so maybe it will help others.
The correct syntax is
mcc -m -v -R -singleCompThread myFunction.m

(note the - in front of the singleCompThread!)
Unfortunately matlab doesn't give a warning, so it's not so easy to find out the error.

Nora

"Nora" wrote in message <jgb5s1$68j$1@newscl01ah.mathworks.com>...
> Hi,
>
> I have similar problems. I want to compile a matlab function to stand-alone program with mcc. What I do is to start matlab as
>
> matlab -singleCompThread
>
> Then on the command line I execute
>
> mcc -m -v -R singleCompThread -R nojvm -R nodesktop -R nosplash myFunction.m
>
> Everything compiles, but when I run myFunction, I still see that it uses more than 100% processor (more than one processor).
> I also added the lines
>
> LASTN = maxNumCompThreads(1);
> disp(['currently allowed comp threads are: ',num2str(maxNumCompThreads)]);
>
> to the begin of myFunction. The number displayed is indeed 1, but processor use goes up to above 600% again.
> Please let me know if I did something wrong, or you have further ideas to try out. I would like to run my code on a cluster, thus it is really important to have it single threaded.
> I use Matlab 2011b, 64 bit, unix operating system
>
> Thank you
>
>
>
> "Shaf " <shafquat.rahman@mathworks.com> wrote in message <h9qkti$14m$1@fred.mathworks.com>...
> > "Steve Rennie" <srennie89@hotmail.com> wrote in message <h9iong$b9g$1@fred.mathworks.com>...
> > > Is it possible to make compiled matlab for version 7.8 (2009a) or later single-threaded?
> > >
> > > The maxNumCompThreads function apparently is no longer supported, and compiling inside matlab with the -singleCompThread specified, not surprisingly, does not work.
> > >
> > > Thanks for your help.
> > >
> > > Steve
> >
> > Hi Steve,
> >
> > Are you building a standalone or a shared library? For shared libraries you can pass "-singleCompThread" to mclInitializeApplication as an option. In the case of standalone you can compile with
> >
> > mcc -R -singleCompThread -mv foo.m
> >
> > ====================
> > function foo
> > maxNumCompThreads
> > ====================
> >
> > If you run the compiled exe you will see 1 being printed.
> >
> > Thanks,
> > Shaf

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
mcc Nora 1 Feb, 2012 05:59:18
singlecompthread Nora 1 Feb, 2012 05:59:18
no multithreading Nora 1 Feb, 2012 05:59:18
single thread Nora 1 Feb, 2012 05:59:18
rssFeed for this Thread

Contact us at files@mathworks.com