Mercurial > hg > octave-lojdl
changeset 12510:a1b2da4967ac
Add nproc, nproc_conf utility functions for determining number of available processors.
author | Iain Murray <iain@iainmurray.net> |
---|---|
date | Wed, 16 Mar 2011 15:00:09 -0700 |
parents | e742720c5e71 |
children | 85e87b865f71 |
files | doc/ChangeLog doc/interpreter/system.txi src/ChangeLog src/DLD-FUNCTIONS/module-files src/DLD-FUNCTIONS/nprocs.cc |
diffstat | 5 files changed, 92 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2010-03-16 Rik <octave@nomad.inbox5.com> + + * interpreter/system.txi: Add nproc and nproc_conf functions to + documentation. + 2010-03-03 Rik <octave@nomad.inbox5.com> * interpreter/matrix.txi: Deprecate is_duplicate_entry.
--- a/doc/interpreter/system.txi +++ b/doc/interpreter/system.txi @@ -470,6 +470,10 @@ @DOCSTRING(uname) +@DOCSTRING(nprocs) + +@DOCSTRING(nprocs_conf) + @DOCSTRING(ispc) @DOCSTRING(isunix)
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2011-03-16 Iain Murray <iain@iainmurray.net> + + * DLD-FUNCTIONS/nprocs.cc: New file. + * DLD-FUNCTIONS/module-files: Add nprocs.cc. + Expose nprocs and nprocs_conf from gnulib. + 2010-03-15 Marco Caliari <marco.caliari@univr.it> * graphics.cc: Simplify calculation of number of tick labels. Fixes
--- a/src/DLD-FUNCTIONS/module-files +++ b/src/DLD-FUNCTIONS/module-files @@ -55,6 +55,7 @@ max.cc md5sum.cc mgorth.cc +nprocs.cc onCleanup.cc pinv.cc qr.cc
new file mode 100644 --- /dev/null +++ b/src/DLD-FUNCTIONS/nprocs.cc @@ -0,0 +1,76 @@ +/* + +Copyright (C) 2011 Iain Murray + + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +<http://www.gnu.org/licenses/>. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "defun-dld.h" +#include "sys/sysinfo.h" + +DEFUN_DLD (nprocs, args, nargout, + "-*- texinfo -*-\n\ +@deftypefn {Loadable Function} {} nprocs ()\n\ +Return the number of available processors.\n\ +@seealso{nprocs_conf}\n\ +@end deftypefn") +{ + octave_value retval; + + int nargin = args.length (); + + if (nargin != 0 || (nargout != 0 && nargout != 1)) + { + print_usage (); + return retval; + } + + retval = get_nprocs (); + + return retval; +} + +DEFUN_DLD (nprocs_conf, args, nargout, + "-*- texinfo -*-\n\ +@deftypefn {Loadable Function} {} nprocs_conf ()\n\ +Return the number of number of processors the operating system has\n\ +configured. This number may be less than the total available as reported by\n\ +@code{nprocs}.\n\ +@seealso{nprocs}\n\ +@end deftypefn") +{ + octave_value retval; + + int nargin = args.length (); + + if (nargin != 0 || (nargout != 0 && nargout != 1)) + { + print_usage (); + return retval; + } + + retval = get_nprocs_conf (); + + return retval; +} +