configfrag.ac 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. # Plugins for offload execution, configure.ac fragment. -*- mode: autoconf -*-
  2. #
  3. # Copyright (C) 2014-2015 Free Software Foundation, Inc.
  4. #
  5. # Contributed by Mentor Embedded.
  6. #
  7. # This file is part of the GNU Offloading and Multi Processing Library
  8. # (libgomp).
  9. #
  10. # Libgomp is free software; you can redistribute it and/or modify it
  11. # under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; either version 3, or (at your option)
  13. # any later version.
  14. #
  15. # Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
  16. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  17. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  18. # more details.
  19. #
  20. # Under Section 7 of GPL version 3, you are granted additional
  21. # permissions described in the GCC Runtime Library Exception, version
  22. # 3.1, as published by the Free Software Foundation.
  23. #
  24. # You should have received a copy of the GNU General Public License and
  25. # a copy of the GCC Runtime Library Exception along with this program;
  26. # see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  27. # <http://www.gnu.org/licenses/>.
  28. offload_targets=
  29. AC_SUBST(offload_targets)
  30. plugin_support=yes
  31. AC_CHECK_LIB(dl, dlsym, , [plugin_support=no])
  32. if test x"$plugin_support" = xyes; then
  33. AC_DEFINE(PLUGIN_SUPPORT, 1,
  34. [Define if all infrastructure, needed for plugins, is supported.])
  35. offload_targets=host_nonshm
  36. elif test "x${enable_offload_targets-no}" != xno; then
  37. AC_MSG_ERROR([Can't support offloading without support for plugins])
  38. fi
  39. # Look for the CUDA driver package.
  40. CUDA_DRIVER_INCLUDE=
  41. CUDA_DRIVER_LIB=
  42. AC_SUBST(CUDA_DRIVER_INCLUDE)
  43. AC_SUBST(CUDA_DRIVER_LIB)
  44. CUDA_DRIVER_CPPFLAGS=
  45. CUDA_DRIVER_LDFLAGS=
  46. AC_ARG_WITH(cuda-driver,
  47. [AS_HELP_STRING([--with-cuda-driver=PATH],
  48. [specify prefix directory for installed CUDA driver package.
  49. Equivalent to --with-cuda-driver-include=PATH/include
  50. plus --with-cuda-driver-lib=PATH/lib])])
  51. AC_ARG_WITH(cuda-driver-include,
  52. [AS_HELP_STRING([--with-cuda-driver-include=PATH],
  53. [specify directory for installed CUDA driver include files])])
  54. AC_ARG_WITH(cuda-driver-lib,
  55. [AS_HELP_STRING([--with-cuda-driver-lib=PATH],
  56. [specify directory for the installed CUDA driver library])])
  57. if test "x$with_cuda_driver" != x; then
  58. CUDA_DRIVER_INCLUDE=$with_cuda_driver/include
  59. CUDA_DRIVER_LIB=$with_cuda_driver/lib
  60. fi
  61. if test "x$with_cuda_driver_include" != x; then
  62. CUDA_DRIVER_INCLUDE=$with_cuda_driver_include
  63. fi
  64. if test "x$with_cuda_driver_lib" != x; then
  65. CUDA_DRIVER_LIB=$with_cuda_driver_lib
  66. fi
  67. if test "x$CUDA_DRIVER_INCLUDE" != x; then
  68. CUDA_DRIVER_CPPFLAGS=-I$CUDA_DRIVER_INCLUDE
  69. fi
  70. if test "x$CUDA_DRIVER_LIB" != x; then
  71. CUDA_DRIVER_LDFLAGS=-L$CUDA_DRIVER_LIB
  72. fi
  73. PLUGIN_NVPTX=0
  74. PLUGIN_NVPTX_CPPFLAGS=
  75. PLUGIN_NVPTX_LDFLAGS=
  76. PLUGIN_NVPTX_LIBS=
  77. AC_SUBST(PLUGIN_NVPTX)
  78. AC_SUBST(PLUGIN_NVPTX_CPPFLAGS)
  79. AC_SUBST(PLUGIN_NVPTX_LDFLAGS)
  80. AC_SUBST(PLUGIN_NVPTX_LIBS)
  81. # Get offload targets and path to install tree of offloading compiler.
  82. offload_additional_options=
  83. offload_additional_lib_paths=
  84. AC_SUBST(offload_additional_options)
  85. AC_SUBST(offload_additional_lib_paths)
  86. if test x"$enable_offload_targets" != x; then
  87. for tgt in `echo $enable_offload_targets | sed -e 's#,# #g'`; do
  88. tgt_dir=`echo $tgt | grep '=' | sed 's/.*=//'`
  89. tgt=`echo $tgt | sed 's/=.*//'`
  90. case $tgt in
  91. *-intelmic-* | *-intelmicemul-*)
  92. tgt_name=intelmic
  93. ;;
  94. nvptx*)
  95. tgt_name=nvptx
  96. PLUGIN_NVPTX=$tgt
  97. PLUGIN_NVPTX_CPPFLAGS=$CUDA_DRIVER_CPPFLAGS
  98. PLUGIN_NVPTX_LDFLAGS=$CUDA_DRIVER_LDFLAGS
  99. PLUGIN_NVPTX_LIBS='-lcuda'
  100. PLUGIN_NVPTX_save_CPPFLAGS=$CPPFLAGS
  101. CPPFLAGS="$PLUGIN_NVPTX_CPPFLAGS $CPPFLAGS"
  102. PLUGIN_NVPTX_save_LDFLAGS=$LDFLAGS
  103. LDFLAGS="$PLUGIN_NVPTX_LDFLAGS $LDFLAGS"
  104. PLUGIN_NVPTX_save_LIBS=$LIBS
  105. LIBS="$PLUGIN_NVPTX_LIBS $LIBS"
  106. AC_LINK_IFELSE(
  107. [AC_LANG_PROGRAM(
  108. [#include "cuda.h"],
  109. [CUresult r = cuCtxPushCurrent (NULL);])],
  110. [PLUGIN_NVPTX=1])
  111. CPPFLAGS=$PLUGIN_NVPTX_save_CPPFLAGS
  112. LDFLAGS=$PLUGIN_NVPTX_save_LDFLAGS
  113. LIBS=$PLUGIN_NVPTX_save_LIBS
  114. case $PLUGIN_NVPTX in
  115. nvptx*)
  116. PLUGIN_NVPTX=0
  117. AC_MSG_ERROR([CUDA driver package required for nvptx support])
  118. ;;
  119. esac
  120. ;;
  121. *)
  122. AC_MSG_ERROR([unknown offload target specified])
  123. ;;
  124. esac
  125. if test x"$offload_targets" = x; then
  126. offload_targets=$tgt_name
  127. else
  128. offload_targets=$offload_targets,$tgt_name
  129. fi
  130. if test x"$tgt_dir" != x; then
  131. offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
  132. offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
  133. else
  134. offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
  135. offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"
  136. fi
  137. done
  138. fi
  139. AC_DEFINE_UNQUOTED(OFFLOAD_TARGETS, "$offload_targets",
  140. [Define to hold the list of target names suitable for offloading.])
  141. AM_CONDITIONAL([PLUGIN_NVPTX], [test $PLUGIN_NVPTX = 1])
  142. AC_DEFINE_UNQUOTED([PLUGIN_NVPTX], [$PLUGIN_NVPTX],
  143. [Define to 1 if the NVIDIA plugin is built, 0 if not.])