# HG changeset patch # User Iain Murray # Date 1300364544 0 # Node ID c685a404e806ed600d0b932f780722df49c75571 # Parent 85e87b865f71cdc2487679670aa77f5c0f26373f Removed nprocs and nprocs_conf. Added nproc, which _actually_ uses gnulib. diff -r 85e87b865f71 -r c685a404e806 ChangeLog --- a/ChangeLog Mon Mar 14 23:36:20 2011 -0600 +++ b/ChangeLog Thu Mar 17 12:22:24 2011 +0000 @@ -1,3 +1,7 @@ +2011-03-17 Iain Murray + + * bootstrap.conf (gnulib_modules): Include nproc in the list. + 2011-03-08 Rik * mk-opts.pl: Recode using more modern Perl syntax. diff -r 85e87b865f71 -r c685a404e806 bootstrap.conf --- a/bootstrap.conf Mon Mar 14 23:36:20 2011 -0600 +++ b/bootstrap.conf Thu Mar 17 12:22:24 2011 +0000 @@ -36,6 +36,7 @@ mkstemp mktime nanosleep + nproc pathmax progname readlink diff -r 85e87b865f71 -r c685a404e806 doc/ChangeLog --- a/doc/ChangeLog Mon Mar 14 23:36:20 2011 -0600 +++ b/doc/ChangeLog Thu Mar 17 12:22:24 2011 +0000 @@ -1,3 +1,8 @@ +2011-03-17 Iain Murray + + * interpreter/system.txi: Remove nprocs and nprocs_conf functions + from documentation and replace with nproc. + 2010-03-16 Rik * interpreter/system.txi: Add nproc and nproc_conf functions to diff -r 85e87b865f71 -r c685a404e806 doc/interpreter/system.txi --- a/doc/interpreter/system.txi Mon Mar 14 23:36:20 2011 -0600 +++ b/doc/interpreter/system.txi Thu Mar 17 12:22:24 2011 +0000 @@ -470,9 +470,7 @@ @DOCSTRING(uname) address@hidden(nprocs) - address@hidden(nprocs_conf) address@hidden(nproc) @DOCSTRING(ispc) diff -r 85e87b865f71 -r c685a404e806 src/ChangeLog --- a/src/ChangeLog Mon Mar 14 23:36:20 2011 -0600 +++ b/src/ChangeLog Thu Mar 17 12:22:24 2011 +0000 @@ -1,3 +1,7 @@ +2011-03-17 Iain Murray + + * DLD-FUNCTIONS/nprocs.cc: remove nprocs and nprocs_conf, new function nproc + 2011-03-16 Iain Murray * DLD-FUNCTIONS/nprocs.cc: New file. diff -r 85e87b865f71 -r c685a404e806 src/DLD-FUNCTIONS/nprocs.cc --- a/src/DLD-FUNCTIONS/nprocs.cc Mon Mar 14 23:36:20 2011 -0600 +++ b/src/DLD-FUNCTIONS/nprocs.cc Thu Mar 17 12:22:24 2011 +0000 @@ -26,51 +26,61 @@ #endif #include "defun-dld.h" -#include "sys/sysinfo.h" +#include "nproc.h" -DEFUN_DLD (nprocs, args, nargout, +DEFUN_DLD (nproc, args, nargout, "-*- texinfo -*-\n\ address@hidden {Loadable Function} {} nprocs ()\n\ -Return the number of available processors.\n\ address@hidden address@hidden {Loadable Function} {} nproc ()\n\ address@hidden {Loadable Function} {} nproc (@var{query})\n\ +Return the current number of available processors.\n\ +\n\ +If called with the optional argument @var{query}, modify how processors\n\ +are counted as follows:\n\ address@hidden @code\n\ address@hidden all\n\ +total number of processors.\n\ +\n\ address@hidden current\n\ +processors available to the current process.\n\ +\n\ address@hidden overridable\n\ +likewise, but overridable through the OMP_NUM_THREADS environment variable.\n\ address@hidden table\n\ @end deftypefn") { octave_value retval; int nargin = args.length (); - if (nargin != 0 || (nargout != 0 && nargout != 1)) + if ((nargin != 0 && nargin != 1) || (nargout != 0 && nargout != 1)) { print_usage (); return retval; } - retval = get_nprocs (); + nproc_query query = NPROC_CURRENT; + if (nargin == 1) + { + std::string arg = args(0).string_value(); + + std::transform (arg.begin (), arg.end (), + arg.begin (), tolower); + + if (arg == "all") + query = NPROC_ALL; + else if (arg == "current") + query = NPROC_CURRENT; + else if (arg == "overridable") + query = NPROC_CURRENT_OVERRIDABLE; + else + { + error ("nproc: invalid value for 'query'"); + return retval; + } + } + + retval = num_processors (query); return retval; } -DEFUN_DLD (nprocs_conf, args, nargout, - "-*- texinfo -*-\n\ address@hidden {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\ address@hidden address@hidden address@hidden 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; -} -