affinity.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /* Copyright (C) 2006-2022 Free Software Foundation, Inc.
  2. Contributed by Jakub Jelinek <jakub@redhat.com>.
  3. This file is part of the GNU Offloading and Multi Processing Library
  4. (libgomp).
  5. Libgomp is free software; you can redistribute it and/or modify it
  6. under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3, or (at your option)
  8. any later version.
  9. Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. more details.
  13. Under Section 7 of GPL version 3, you are granted additional
  14. permissions described in the GCC Runtime Library Exception, version
  15. 3.1, as published by the Free Software Foundation.
  16. You should have received a copy of the GNU General Public License and
  17. a copy of the GCC Runtime Library Exception along with this program;
  18. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. <http://www.gnu.org/licenses/>. */
  20. /* This is a generic stub implementation of a CPU affinity setting. */
  21. #include "libgomp.h"
  22. #include <string.h>
  23. #include <stdio.h>
  24. void
  25. gomp_init_affinity (void)
  26. {
  27. }
  28. #ifdef LIBGOMP_USE_PTHREADS
  29. void
  30. gomp_init_thread_affinity (pthread_attr_t *attr, unsigned int place)
  31. {
  32. (void) attr;
  33. (void) place;
  34. }
  35. #endif
  36. void **
  37. gomp_affinity_alloc (unsigned long count, bool quiet)
  38. {
  39. (void) count;
  40. if (!quiet)
  41. gomp_error ("Affinity not supported on this configuration");
  42. return NULL;
  43. }
  44. void
  45. gomp_affinity_init_place (void *p)
  46. {
  47. (void) p;
  48. }
  49. bool
  50. gomp_affinity_add_cpus (void *p, unsigned long num,
  51. unsigned long len, long stride, bool quiet)
  52. {
  53. (void) p;
  54. (void) num;
  55. (void) len;
  56. (void) stride;
  57. (void) quiet;
  58. return false;
  59. }
  60. bool
  61. gomp_affinity_remove_cpu (void *p, unsigned long num)
  62. {
  63. (void) p;
  64. (void) num;
  65. return false;
  66. }
  67. bool
  68. gomp_affinity_copy_place (void *p, void *q, long stride)
  69. {
  70. (void) p;
  71. (void) q;
  72. (void) stride;
  73. return false;
  74. }
  75. bool
  76. gomp_affinity_same_place (void *p, void *q)
  77. {
  78. (void) p;
  79. (void) q;
  80. return false;
  81. }
  82. bool
  83. gomp_affinity_finalize_place_list (bool quiet)
  84. {
  85. (void) quiet;
  86. return false;
  87. }
  88. bool
  89. gomp_affinity_init_level (int level, unsigned long count, bool quiet)
  90. {
  91. (void) level;
  92. (void) count;
  93. (void) quiet;
  94. if (!quiet)
  95. gomp_error ("Affinity not supported on this configuration");
  96. return NULL;
  97. }
  98. void
  99. gomp_affinity_print_place (void *p)
  100. {
  101. (void) p;
  102. }
  103. int
  104. omp_get_place_num_procs (int place_num)
  105. {
  106. (void) place_num;
  107. return 0;
  108. }
  109. void
  110. omp_get_place_proc_ids (int place_num, int *ids)
  111. {
  112. (void) place_num;
  113. (void) ids;
  114. }
  115. void
  116. gomp_get_place_proc_ids_8 (int place_num, int64_t *ids)
  117. {
  118. (void) place_num;
  119. (void) ids;
  120. }
  121. void
  122. gomp_display_affinity_place (char *buffer, size_t size, size_t *ret,
  123. int place)
  124. {
  125. char buf[sizeof (long) * 3 + 4];
  126. if (gomp_available_cpus > 1)
  127. sprintf (buf, "0-%lu", gomp_available_cpus - 1);
  128. else
  129. strcpy (buf, "0");
  130. gomp_display_string (buffer, size, ret, buf, strlen (buf));
  131. }
  132. ialias(omp_get_place_num_procs)
  133. ialias(omp_get_place_proc_ids)