[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Read the number of cpus on Linux
From: |
John W. Eaton |
Subject: |
Re: Read the number of cpus on Linux |
Date: |
Wed, 21 Jul 2010 08:47:42 -0400 |
On 21-Jul-2010, Francesco Potortì wrote:
| >>>If you have GNU coreutils 8.1 or later, you can do
| >>> [err,numprocs] = system("nproc")
| >>
| >> Isn't this less efficient, systemwise?
| >
| >Are you planning to check millions of times in a for loop if the
| >number of cores in your system has changed?
|
| No, but in general having a function less heavy on the system is a plus,
| because you never know how it will be used in the future.
|
| Probably it is not important in this case, because it should be called
| at most once per invocation of parcellfun, so the overhead should be
| negligible.
I see an nproc module in gnulib that appears to be portable to current
systems of interest:
http://www.gnu.org/software/gnulib/MODULES.html#module=nproc
So, it should be fairly easy to use this to write a function to do
what you want, at least for the development version of Octave which
already uses gnulib.
Would someone like to contribute a function for this purpose?
jwe