nproc.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* Detect the number of processors.
  2. Copyright (C) 2009-2017 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, see <http://www.gnu.org/licenses/>. */
  13. /* Written by Glen Lenker and Bruno Haible. */
  14. /* Allow the use in C++ code. */
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. /* A "processor" in this context means a thread execution unit, that is either
  19. - an execution core in a (possibly multi-core) chip, in a (possibly multi-
  20. chip) module, in a single computer, or
  21. - a thread execution unit inside a core
  22. (hyper-threading, see <http://en.wikipedia.org/wiki/Hyper-threading>).
  23. Which of the two definitions is used, is unspecified. */
  24. enum nproc_query
  25. {
  26. NPROC_ALL, /* total number of processors */
  27. NPROC_CURRENT, /* processors available to the current process */
  28. NPROC_CURRENT_OVERRIDABLE /* likewise, but overridable through the
  29. OMP_NUM_THREADS environment variable */
  30. };
  31. /* Return the total number of processors. The result is guaranteed to
  32. be at least 1. */
  33. extern unsigned long int num_processors (enum nproc_query query);
  34. #ifdef __cplusplus
  35. }
  36. #endif /* C++ */