configfrag.ac revision 1.1.1.8
1# Plugins for offload execution, configure.ac fragment. -*- mode: autoconf -*- 2# 3# Copyright (C) 2014-2020 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 29plugin_support=yes 30AC_CHECK_LIB(dl, dlsym, , [plugin_support=no]) 31if test x"$plugin_support" = xyes; then 32 AC_DEFINE(PLUGIN_SUPPORT, 1, 33 [Define if all infrastructure, needed for plugins, is supported.]) 34elif test "x${enable_offload_targets-no}" != xno; then 35 AC_MSG_ERROR([Can't support offloading without support for plugins]) 36fi 37AC_CHECK_HEADERS_ONCE(unistd.h) 38AC_CHECK_FUNCS_ONCE(secure_getenv __secure_getenv getuid geteuid getgid getegid) 39 40 41# Look for the CUDA driver package. 42CUDA_DRIVER_INCLUDE= 43CUDA_DRIVER_LIB= 44AC_SUBST(CUDA_DRIVER_INCLUDE) 45AC_SUBST(CUDA_DRIVER_LIB) 46CUDA_DRIVER_CPPFLAGS= 47CUDA_DRIVER_LDFLAGS= 48AC_ARG_WITH(cuda-driver, 49 [AS_HELP_STRING([--with-cuda-driver=PATH], 50 [specify prefix directory for installed CUDA driver package. 51 Equivalent to --with-cuda-driver-include=PATH/include 52 plus --with-cuda-driver-lib=PATH/lib])]) 53AC_ARG_WITH(cuda-driver-include, 54 [AS_HELP_STRING([--with-cuda-driver-include=PATH], 55 [specify directory for installed CUDA driver include files])]) 56AC_ARG_WITH(cuda-driver-lib, 57 [AS_HELP_STRING([--with-cuda-driver-lib=PATH], 58 [specify directory for the installed CUDA driver library])]) 59case "x$with_cuda_driver" in 60 x) ;; 61 xno) 62 CUDA_DRIVER_INCLUDE=no 63 CUDA_DRIVER_LIB=no 64 ;; 65 *) CUDA_DRIVER_INCLUDE=$with_cuda_driver/include 66 CUDA_DRIVER_LIB=$with_cuda_driver/lib 67 ;; 68esac 69if test "x$with_cuda_driver_include" != x; then 70 CUDA_DRIVER_INCLUDE=$with_cuda_driver_include 71fi 72if test "x$with_cuda_driver_lib" != x; then 73 CUDA_DRIVER_LIB=$with_cuda_driver_lib 74fi 75if test "x$CUDA_DRIVER_INCLUDE" != x \ 76 && test "x$CUDA_DRIVER_INCLUDE" != xno; then 77 CUDA_DRIVER_CPPFLAGS=-I$CUDA_DRIVER_INCLUDE 78fi 79if test "x$CUDA_DRIVER_LIB" != x \ 80 && test "x$CUDA_DRIVER_LIB" != xno; then 81 CUDA_DRIVER_LDFLAGS=-L$CUDA_DRIVER_LIB 82fi 83 84PLUGIN_NVPTX=0 85PLUGIN_NVPTX_CPPFLAGS= 86PLUGIN_NVPTX_LDFLAGS= 87PLUGIN_NVPTX_LIBS= 88PLUGIN_NVPTX_DYNAMIC=0 89AC_SUBST(PLUGIN_NVPTX) 90AC_SUBST(PLUGIN_NVPTX_CPPFLAGS) 91AC_SUBST(PLUGIN_NVPTX_LDFLAGS) 92AC_SUBST(PLUGIN_NVPTX_LIBS) 93 94# Look for HSA run-time, its includes and libraries 95 96HSA_RUNTIME_INCLUDE= 97HSA_RUNTIME_LIB= 98AC_SUBST(HSA_RUNTIME_INCLUDE) 99AC_SUBST(HSA_RUNTIME_LIB) 100HSA_RUNTIME_CPPFLAGS= 101HSA_RUNTIME_LDFLAGS= 102 103AC_ARG_WITH(hsa-runtime, 104 [AS_HELP_STRING([--with-hsa-runtime=PATH], 105 [specify prefix directory for installed HSA run-time package. 106 Equivalent to --with-hsa-runtime-include=PATH/include 107 plus --with-hsa-runtime-lib=PATH/lib])]) 108AC_ARG_WITH(hsa-runtime-include, 109 [AS_HELP_STRING([--with-hsa-runtime-include=PATH], 110 [specify directory for installed HSA run-time include files])]) 111AC_ARG_WITH(hsa-runtime-lib, 112 [AS_HELP_STRING([--with-hsa-runtime-lib=PATH], 113 [specify directory for the installed HSA run-time library])]) 114if test "x$with_hsa_runtime" != x; then 115 HSA_RUNTIME_INCLUDE=$with_hsa_runtime/include 116 HSA_RUNTIME_LIB=$with_hsa_runtime/lib 117fi 118if test "x$with_hsa_runtime_include" != x; then 119 HSA_RUNTIME_INCLUDE=$with_hsa_runtime_include 120fi 121if test "x$with_hsa_runtime_lib" != x; then 122 HSA_RUNTIME_LIB=$with_hsa_runtime_lib 123fi 124if test "x$HSA_RUNTIME_INCLUDE" != x; then 125 HSA_RUNTIME_CPPFLAGS=-I$HSA_RUNTIME_INCLUDE 126fi 127if test "x$HSA_RUNTIME_LIB" != x; then 128 HSA_RUNTIME_LDFLAGS=-L$HSA_RUNTIME_LIB 129fi 130 131PLUGIN_HSA=0 132PLUGIN_HSA_CPPFLAGS= 133PLUGIN_HSA_LDFLAGS= 134PLUGIN_HSA_LIBS= 135AC_SUBST(PLUGIN_HSA) 136AC_SUBST(PLUGIN_HSA_CPPFLAGS) 137AC_SUBST(PLUGIN_HSA_LDFLAGS) 138AC_SUBST(PLUGIN_HSA_LIBS) 139 140PLUGIN_GCN=0 141PLUGIN_GCN_CPPFLAGS= 142PLUGIN_GCN_LDFLAGS= 143PLUGIN_GCN_LIBS= 144AC_SUBST(PLUGIN_GCN) 145AC_SUBST(PLUGIN_GCN_CPPFLAGS) 146AC_SUBST(PLUGIN_GCN_LDFLAGS) 147AC_SUBST(PLUGIN_GCN_LIBS) 148 149# Parse '--enable-offload-targets', figure out the corresponding libgomp 150# plugins, and configure to find the corresponding offload compilers. 151# 'offload_plugins' and 'offload_targets' will be populated in the same order. 152offload_plugins= 153offload_targets= 154AC_SUBST(offload_plugins) 155AC_SUBST(offload_targets) 156offload_additional_options= 157offload_additional_lib_paths= 158AC_SUBST(offload_additional_options) 159AC_SUBST(offload_additional_lib_paths) 160if test x"$enable_offload_targets" != x; then 161 for tgt in `echo $enable_offload_targets | sed -e 's#,# #g'`; do 162 tgt_dir=`echo $tgt | grep '=' | sed 's/.*=//'` 163 tgt=`echo $tgt | sed 's/=.*//'` 164 tgt_plugin= 165 case $tgt in 166 *-intelmic-* | *-intelmicemul-*) 167 tgt_plugin=intelmic 168 ;; 169 nvptx*) 170 case "${target}" in 171 aarch64*-*-* | powerpc64le-*-* | x86_64-*-*) 172 case " ${CC} ${CFLAGS} " in 173 *" -m32 "* | *" -mx32 "*) 174 # PR libgomp/65099: Currently, we only support offloading in 175 # 64-bit configurations. 176 PLUGIN_NVPTX=0 177 ;; 178 *) 179 tgt_plugin=nvptx 180 PLUGIN_NVPTX=$tgt 181 if test "x$CUDA_DRIVER_LIB" != xno \ 182 && test "x$CUDA_DRIVER_LIB" != xno; then 183 PLUGIN_NVPTX_CPPFLAGS=$CUDA_DRIVER_CPPFLAGS 184 PLUGIN_NVPTX_LDFLAGS=$CUDA_DRIVER_LDFLAGS 185 PLUGIN_NVPTX_LIBS='-lcuda' 186 187 PLUGIN_NVPTX_save_CPPFLAGS=$CPPFLAGS 188 CPPFLAGS="$PLUGIN_NVPTX_CPPFLAGS $CPPFLAGS" 189 PLUGIN_NVPTX_save_LDFLAGS=$LDFLAGS 190 LDFLAGS="$PLUGIN_NVPTX_LDFLAGS $LDFLAGS" 191 PLUGIN_NVPTX_save_LIBS=$LIBS 192 LIBS="$PLUGIN_NVPTX_LIBS $LIBS" 193 AC_LINK_IFELSE( 194 [AC_LANG_PROGRAM( 195 [#include "cuda.h"], 196 [CUresult r = cuCtxPushCurrent (NULL);])], 197 [PLUGIN_NVPTX=1]) 198 CPPFLAGS=$PLUGIN_NVPTX_save_CPPFLAGS 199 LDFLAGS=$PLUGIN_NVPTX_save_LDFLAGS 200 LIBS=$PLUGIN_NVPTX_save_LIBS 201 fi 202 case $PLUGIN_NVPTX in 203 nvptx*) 204 if (test "x$CUDA_DRIVER_INCLUDE" = x \ 205 || test "x$CUDA_DRIVER_INCLUDE" = xno) \ 206 && (test "x$CUDA_DRIVER_LIB" = x \ 207 || test "x$CUDA_DRIVER_LIB" = xno); then 208 PLUGIN_NVPTX=1 209 PLUGIN_NVPTX_CPPFLAGS='-I$(srcdir)/plugin/cuda' 210 PLUGIN_NVPTX_LIBS='-ldl' 211 PLUGIN_NVPTX_DYNAMIC=1 212 else 213 PLUGIN_NVPTX=0 214 AC_MSG_ERROR([CUDA driver package required for nvptx support]) 215 fi 216 ;; 217 esac 218 ;; 219 esac 220 ;; 221 *-*-*) 222 # Target architecture not supported. 223 PLUGIN_NVPTX=0 224 ;; 225 esac 226 ;; 227 hsa*) 228 case "${target}" in 229 x86_64-*-*) 230 case " ${CC} ${CFLAGS} " in 231 *" -m32 "*|*" -mx32 "*) 232 PLUGIN_HSA=0 233 ;; 234 *) 235 tgt_plugin=hsa 236 PLUGIN_HSA=$tgt 237 PLUGIN_HSA_CPPFLAGS=$HSA_RUNTIME_CPPFLAGS 238 PLUGIN_HSA_LDFLAGS="$HSA_RUNTIME_LDFLAGS" 239 PLUGIN_HSA_LIBS="-ldl" 240 241 PLUGIN_HSA_save_CPPFLAGS=$CPPFLAGS 242 CPPFLAGS="$PLUGIN_HSA_CPPFLAGS $CPPFLAGS" 243 PLUGIN_HSA_save_LDFLAGS=$LDFLAGS 244 LDFLAGS="$PLUGIN_HSA_LDFLAGS $LDFLAGS" 245 PLUGIN_HSA_save_LIBS=$LIBS 246 LIBS="$PLUGIN_HSA_LIBS $LIBS" 247 248 PLUGIN_HSA=1 249 CPPFLAGS=$PLUGIN_HSA_save_CPPFLAGS 250 LDFLAGS=$PLUGIN_HSA_save_LDFLAGS 251 LIBS=$PLUGIN_HSA_save_LIBS 252 case $PLUGIN_HSA in 253 hsa*) 254 HSA_PLUGIN=0 255 AC_MSG_ERROR([HSA run-time package required for HSA support]) 256 ;; 257 esac 258 ;; 259 esac 260 ;; 261 *-*-*) 262 PLUGIN_HSA=0 263 ;; 264 esac 265 ;; 266 267 amdgcn*) 268 case "${target}" in 269 x86_64-*-*) 270 case " ${CC} ${CFLAGS} " in 271 *" -m32 "*|*" -mx32 "*) 272 PLUGIN_GCN=0 273 ;; 274 *) 275 tgt_plugin=gcn 276 PLUGIN_GCN=$tgt 277 PLUGIN_GCN_CPPFLAGS=$HSA_RUNTIME_CPPFLAGS 278 PLUGIN_GCN_LDFLAGS="$HSA_RUNTIME_LDFLAGS" 279 PLUGIN_GCN_LIBS="-ldl" 280 PLUGIN_GCN=1 281 ;; 282 esac 283 ;; 284 *-*-*) 285 PLUGIN_GCN=0 286 ;; 287 esac 288 ;; 289 *) 290 AC_MSG_ERROR([unknown offload target specified]) 291 ;; 292 esac 293 if test x"$tgt_plugin" = x; then 294 # Not configuring libgomp for this offload target if we're not building 295 # the corresponding offload plugin. 296 continue 297 elif test x"$offload_plugins" = x; then 298 offload_plugins=$tgt_plugin 299 offload_targets=$tgt 300 else 301 offload_plugins=$offload_plugins,$tgt_plugin 302 offload_targets=$offload_targets,$tgt 303 fi 304 # Configure additional search paths. 305 if test "$tgt_plugin" = hsa; then 306 # Offloading compilation is all handled by the target compiler. 307 : 308 elif test x"$tgt_dir" != x; then 309 offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin" 310 offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32" 311 else 312 offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)" 313 offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir" 314 fi 315 done 316fi 317AC_DEFINE_UNQUOTED(OFFLOAD_PLUGINS, "$offload_plugins", 318 [Define to offload plugins, separated by commas.]) 319AM_CONDITIONAL([PLUGIN_NVPTX], [test $PLUGIN_NVPTX = 1]) 320AC_DEFINE_UNQUOTED([PLUGIN_NVPTX], [$PLUGIN_NVPTX], 321 [Define to 1 if the NVIDIA plugin is built, 0 if not.]) 322AC_DEFINE_UNQUOTED([PLUGIN_NVPTX_DYNAMIC], [$PLUGIN_NVPTX_DYNAMIC], 323 [Define to 1 if the NVIDIA plugin should dlopen libcuda.so.1, 0 if it should be linked against it.]) 324AM_CONDITIONAL([PLUGIN_HSA], [test $PLUGIN_HSA = 1]) 325AC_DEFINE_UNQUOTED([PLUGIN_HSA], [$PLUGIN_HSA], 326 [Define to 1 if the HSA plugin is built, 0 if not.]) 327AM_CONDITIONAL([PLUGIN_GCN], [test $PLUGIN_GCN = 1]) 328AC_DEFINE_UNQUOTED([PLUGIN_GCN], [$PLUGIN_GCN], 329 [Define to 1 if the GCN plugin is built, 0 if not.]) 330