Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: Number of CPUs on machine

Subject: Number of CPUs on machine

From: EUSTACE

Date: 14 Aug, 2007 15:35:08

Message: 1 of 6

Hi,
I am wondering if there is a Matlab command to determine the
number of CPUs on a machine. I am writing a program for
parallel execution and there are some parameters which
depend on the number of CPUs available.

Thanks in advance.
Bobane

Subject: Number of CPUs on machine

From: Yair Altman

Date: 14 Aug, 2007 17:27:48

Message: 2 of 6

"EUSTACE " <bobane73@hotmail.com> wrote in message
<f9si3c$cck$1@fred.mathworks.com>...
> Hi,
> I am wondering if there is a Matlab command to determine the
> number of CPUs on a machine. I am writing a program for
> parallel execution and there are some parameters which
> depend on the number of CPUs available.
>
> Thanks in advance.
> Bobane
>

feature('numCores');
Note: feature is undocumented/unsupported
Also note that you need to turn Matlab's multithreading on
(Preferences/General/Multithreading)

Yair Altman
http://ymasoftware.com

Subject: Number of CPUs on machine

From: Tim Davis

Date: 14 Aug, 2007 17:50:45

Message: 3 of 6

If you use sparse x=A\b, expect multithreading to slow your
code down (see the latest Cleve's Corner). The problem is a
bug in the multithreaded BLAS.

Subject: Number of CPUs on machine

From: John Vendt

Date: 14 Aug, 2007 19:05:00

Message: 4 of 6

> > I am wondering if there is a Matlab command to determine the
> > number of CPUs on a machine. I am writing a program for
> > parallel execution and there are some parameters which
> > depend on the number of CPUs available.
> >
> > Thanks in advance.
> > Bobane
> >
>
> feature('numCores');

Well, he seems to be asking about the number of CPUs
available. If multithreading is enabled, the answer to this
question would be given by

getNumberOfComputationalThreads

on R2007a.

Or, if you're using an older Matlab version on a *nix
system, try

getenv OMP_NUM_THREADS

Joachim

Subject: Number of CPUs on machine

From: Bobane

Date: 15 Aug, 2007 09:56:39

Message: 5 of 6

"John Vendt" <a@B.dot.com> wrote in message
<f9sucs$6gd$1@fred.mathworks.com>...
> > > I am wondering if there is a Matlab command to
determine the
> > > number of CPUs on a machine. I am writing a program for
> > > parallel execution and there are some parameters which
> > > depend on the number of CPUs available.
> > >
> > > Thanks in advance.
> > > Bobane
> > >
> >
> > feature('numCores');
>
> Well, he seems to be asking about the number of CPUs
> available. If multithreading is enabled, the answer to this
> question would be given by
>
> getNumberOfComputationalThreads
>
> on R2007a.
>
> Or, if you're using an older Matlab version on a *nix
> system, try
>
> getenv OMP_NUM_THREADS
>
> Joachim

Hi guys,
Thanks guys for your suggestions. Yes, I just wanted to know
how many processors were available without the
multithreading (am using R2006b on Windows XP), and working
from Joachim's suggestion, I have found the solution I wanted:
    getenv('NUMBER_OF_PROCESSORS')

Thanks again.

Bobane

Subject: Number of CPUs on machine

From: us

Date: 15 Aug, 2007 18:31:10

Message: 6 of 6

EUSTACE:
<SNIP housekeeping his/her cpus...

> command to determine the number of CPUs on a machine...

another one of the many solutions

     import java.lang.*;
     r=Runtime.getRuntime;
     ncpu=r.availableProcessors
% -also- see
     methods(r)
% for other informations you can get from <r>...

us

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
java us 15 Aug, 2007 14:34:24
code us 15 Aug, 2007 14:34:24
no_of_processors Bobane 15 Aug, 2007 06:00:26
multicore Tim Davis 14 Aug, 2007 13:49:14
undocumented Yair Altman 14 Aug, 2007 13:30:21
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics