acinclude.m4 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. # StarPU --- Runtime system for heterogeneous multicore architectures.
  2. #
  3. # Copyright (C) 2012-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. #
  5. # StarPU is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU Lesser General Public License as published by
  7. # the Free Software Foundation; either version 2.1 of the License, or (at
  8. # your option) any later version.
  9. #
  10. # StarPU is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. #
  14. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. #
  16. # Check whether the target supports __sync_val_compare_and_swap.
  17. AC_DEFUN([STARPU_CHECK_SYNC_VAL_COMPARE_AND_SWAP], [
  18. AC_CACHE_CHECK([whether the target supports __sync_val_compare_and_swap],
  19. ac_cv_have_sync_val_compare_and_swap, [
  20. AC_LINK_IFELSE([AC_LANG_PROGRAM([int foo, bar;],
  21. [bar = __sync_val_compare_and_swap(&foo, 0, 1);])],
  22. [ac_cv_have_sync_val_compare_and_swap=yes],
  23. [ac_cv_have_sync_val_compare_and_swap=no])])
  24. if test $ac_cv_have_sync_val_compare_and_swap = yes; then
  25. AC_DEFINE(STARPU_HAVE_SYNC_VAL_COMPARE_AND_SWAP, 1,
  26. [Define to 1 if the target supports __sync_val_compare_and_swap])
  27. fi])
  28. # Check whether the target supports __sync_bool_compare_and_swap.
  29. AC_DEFUN([STARPU_CHECK_SYNC_BOOL_COMPARE_AND_SWAP], [
  30. AC_CACHE_CHECK([whether the target supports __sync_bool_compare_and_swap],
  31. ac_cv_have_sync_bool_compare_and_swap, [
  32. AC_LINK_IFELSE([AC_LANG_PROGRAM([int foo, bar;],
  33. [bar = __sync_bool_compare_and_swap(&foo, 0, 1);])],
  34. [ac_cv_have_sync_bool_compare_and_swap=yes],
  35. [ac_cv_have_sync_bool_compare_and_swap=no])])
  36. if test $ac_cv_have_sync_bool_compare_and_swap = yes; then
  37. AC_DEFINE(STARPU_HAVE_SYNC_BOOL_COMPARE_AND_SWAP, 1,
  38. [Define to 1 if the target supports __sync_bool_compare_and_swap])
  39. fi])
  40. # Check whether the target supports __sync_fetch_and_add.
  41. AC_DEFUN([STARPU_CHECK_SYNC_FETCH_AND_ADD], [
  42. AC_CACHE_CHECK([whether the target supports __sync_fetch_and_add],
  43. ac_cv_have_sync_fetch_and_add, [
  44. AC_LINK_IFELSE([AC_LANG_PROGRAM([int foo, bar;],
  45. [bar = __sync_fetch_and_add(&foo, 1);])],
  46. [ac_cv_have_sync_fetch_and_add=yes],
  47. [ac_cv_have_sync_fetch_and_add=no])])
  48. if test $ac_cv_have_sync_fetch_and_add = yes; then
  49. AC_DEFINE(STARPU_HAVE_SYNC_FETCH_AND_ADD, 1,
  50. [Define to 1 if the target supports __sync_fetch_and_add])
  51. fi])
  52. # Check whether the target supports __sync_fetch_and_or.
  53. AC_DEFUN([STARPU_CHECK_SYNC_FETCH_AND_OR], [
  54. AC_CACHE_CHECK([whether the target supports __sync_fetch_and_or],
  55. ac_cv_have_sync_fetch_and_or, [
  56. AC_LINK_IFELSE([AC_LANG_PROGRAM([int foo, bar;],
  57. [bar = __sync_fetch_and_or(&foo, 1);])],
  58. [ac_cv_have_sync_fetch_and_or=yes],
  59. [ac_cv_have_sync_fetch_and_or=no])])
  60. if test $ac_cv_have_sync_fetch_and_or = yes; then
  61. AC_DEFINE(STARPU_HAVE_SYNC_FETCH_AND_OR, 1,
  62. [Define to 1 if the target supports __sync_fetch_and_or])
  63. fi])
  64. # Check whether the target supports __sync_lock_test_and_set.
  65. AC_DEFUN([STARPU_CHECK_SYNC_LOCK_TEST_AND_SET], [
  66. AC_CACHE_CHECK([whether the target supports __sync_lock_test_and_set],
  67. ac_cv_have_sync_lock_test_and_set, [
  68. AC_LINK_IFELSE([AC_LANG_PROGRAM([int foo, bar;],
  69. [bar = __sync_lock_test_and_set(&foo, 1);])],
  70. [ac_cv_have_sync_lock_test_and_set=yes],
  71. [ac_cv_have_sync_lock_test_and_set=no])])
  72. if test $ac_cv_have_sync_lock_test_and_set = yes; then
  73. AC_DEFINE(STARPU_HAVE_SYNC_LOCK_TEST_AND_SET, 1,
  74. [Define to 1 if the target supports __sync_lock_test_and_set])
  75. fi])
  76. # Check whether the target supports __atomic_compare_exchange_n.
  77. AC_DEFUN([STARPU_CHECK_ATOMIC_COMPARE_EXCHANGE_N], [
  78. AC_CACHE_CHECK([whether the target supports __atomic_compare_exchange_n],
  79. ac_cv_have_atomic_compare_exchange_n, [
  80. AC_LINK_IFELSE([AC_LANG_PROGRAM([int foo, bar, baz;],
  81. [baz = __atomic_compare_exchange_n(&foo, &bar, 1, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);])],
  82. [ac_cv_have_atomic_compare_exchange_n=yes],
  83. [ac_cv_have_atomic_compare_exchange_n=no])])
  84. if test $ac_cv_have_atomic_compare_exchange_n = yes; then
  85. AC_DEFINE(STARPU_HAVE_ATOMIC_COMPARE_EXCHANGE_N, 1,
  86. [Define to 1 if the target supports __atomic_compare_exchange_n])
  87. fi])
  88. # Check whether the target supports __atomic_exchange_n.
  89. AC_DEFUN([STARPU_CHECK_ATOMIC_EXCHANGE_N], [
  90. AC_CACHE_CHECK([whether the target supports __atomic_exchange_n],
  91. ac_cv_have_atomic_exchange_n, [
  92. AC_LINK_IFELSE([AC_LANG_PROGRAM([int foo, bar;],
  93. [bar = __atomic_exchange_n(&foo, 1, __ATOMIC_SEQ_CST);])],
  94. [ac_cv_have_atomic_exchange_n=yes],
  95. [ac_cv_have_atomic_exchange_n=no])])
  96. if test $ac_cv_have_atomic_exchange_n = yes; then
  97. AC_DEFINE(STARPU_HAVE_ATOMIC_EXCHANGE_N, 1,
  98. [Define to 1 if the target supports __atomic_exchange_n])
  99. fi])
  100. # Check whether the target supports __atomic_fetch_add.
  101. AC_DEFUN([STARPU_CHECK_ATOMIC_FETCH_ADD], [
  102. AC_CACHE_CHECK([whether the target supports __atomic_fetch_add],
  103. ac_cv_have_atomic_fetch_add, [
  104. AC_LINK_IFELSE([AC_LANG_PROGRAM([int foo, bar;],
  105. [bar = __atomic_fetch_add(&foo, 1, __ATOMIC_SEQ_CST);])],
  106. [ac_cv_have_atomic_fetch_add=yes],
  107. [ac_cv_have_atomic_fetch_add=no])])
  108. if test $ac_cv_have_atomic_fetch_add = yes; then
  109. AC_DEFINE(STARPU_HAVE_ATOMIC_FETCH_ADD, 1,
  110. [Define to 1 if the target supports __atomic_fetch_add])
  111. fi])
  112. # Check whether the target supports __atomic_fetch_or.
  113. AC_DEFUN([STARPU_CHECK_ATOMIC_FETCH_OR], [
  114. AC_CACHE_CHECK([whether the target supports __atomic_fetch_or],
  115. ac_cv_have_atomic_fetch_or, [
  116. AC_LINK_IFELSE([AC_LANG_PROGRAM([int foo, bar;],
  117. [bar = __atomic_fetch_or(&foo, 1, __ATOMIC_SEQ_CST);])],
  118. [ac_cv_have_atomic_fetch_or=yes],
  119. [ac_cv_have_atomic_fetch_or=no])])
  120. if test $ac_cv_have_atomic_fetch_or = yes; then
  121. AC_DEFINE(STARPU_HAVE_ATOMIC_FETCH_OR, 1,
  122. [Define to 1 if the target supports __atomic_fetch_or])
  123. fi])
  124. # Check whether the target supports __atomic_test_and_set.
  125. AC_DEFUN([STARPU_CHECK_ATOMIC_TEST_AND_SET], [
  126. AC_CACHE_CHECK([whether the target supports __atomic_test_and_set],
  127. ac_cv_have_atomic_test_and_set, [
  128. AC_LINK_IFELSE([AC_LANG_PROGRAM([int foo, bar;],
  129. [bar = __atomic_test_and_set(&foo, __ATOMIC_SEQ_CST);])],
  130. [ac_cv_have_atomic_test_and_set=yes],
  131. [ac_cv_have_atomic_test_and_set=no])])
  132. if test $ac_cv_have_atomic_test_and_set = yes; then
  133. AC_DEFINE(STARPU_HAVE_ATOMIC_TEST_AND_SET, 1,
  134. [Define to 1 if the target supports __atomic_test_and_set])
  135. fi])
  136. # Check whether the target supports __sync_synchronize.
  137. AC_DEFUN([STARPU_CHECK_SYNC_SYNCHRONIZE], [
  138. AC_CACHE_CHECK([whether the target supports __sync_synchronize],
  139. ac_cv_have_sync_synchronize, [
  140. AC_LINK_IFELSE([AC_LANG_PROGRAM(,
  141. [__sync_synchronize();])],
  142. [ac_cv_have_sync_synchronize=yes],
  143. [ac_cv_have_sync_synchronize=no])])
  144. if test $ac_cv_have_sync_synchronize = yes; then
  145. AC_DEFINE(STARPU_HAVE_SYNC_SYNCHRONIZE, 1,
  146. [Define to 1 if the target supports __sync_synchronize])
  147. fi])