nproc.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Detect the number of processors.
  2. Copyright (C) 2009-2012 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation; either version 2, or (at your option)
  6. any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program; if not, write to the Free Software Foundation,
  13. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
  14. /* Written by Glen Lenker and Bruno Haible. */
  15. /* Allow the use in C++ code. */
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /* A "processor" in this context means a thread execution unit, that is either
  20. - an execution core in a (possibly multi-core) chip, in a (possibly multi-
  21. chip) module, in a single computer, or
  22. - a thread execution unit inside a core
  23. (hyper-threading, see <http://en.wikipedia.org/wiki/Hyper-threading>).
  24. Which of the two definitions is used, is unspecified. */
  25. enum nproc_query
  26. {
  27. NPROC_ALL, /* total number of processors */
  28. NPROC_CURRENT, /* processors available to the current process */
  29. NPROC_CURRENT_OVERRIDABLE /* likewise, but overridable through the
  30. OMP_NUM_THREADS environment variable */
  31. };
  32. /* Return the total number of processors. The result is guaranteed to
  33. be at least 1. */
  34. extern unsigned long int num_processors (enum nproc_query query);
  35. #ifdef __cplusplus
  36. }
  37. #endif /* C++ */