1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
# Plugins for offload execution, configure.ac fragment. -*- mode: autoconf -*-
#
# Copyright (C) 2014-2022 Free Software Foundation, Inc.
#
# Contributed by Mentor Embedded.
#
# This file is part of the GNU Offloading and Multi Processing Library
# (libgomp).
#
# Libgomp is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# Under Section 7 of GPL version 3, you are granted additional
# permissions described in the GCC Runtime Library Exception, version
# 3.1, as published by the Free Software Foundation.
#
# You should have received a copy of the GNU General Public License and
# a copy of the GCC Runtime Library Exception along with this program;
# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
# <http://www.gnu.org/licenses/>.
plugin_support=yes
AC_CHECK_LIB(dl, dlsym, , [plugin_support=no])
if test x"$plugin_support" = xyes; then
AC_DEFINE(PLUGIN_SUPPORT, 1,
[Define if all infrastructure, needed for plugins, is supported.])
elif test "x${enable_offload_targets-no}" != xno; then
AC_MSG_ERROR([Can't support offloading without support for plugins])
fi
AC_CHECK_HEADERS_ONCE(unistd.h)
AC_CHECK_FUNCS_ONCE(secure_getenv __secure_getenv getuid geteuid getgid getegid)
# Look for the CUDA driver package.
CUDA_DRIVER_INCLUDE=
CUDA_DRIVER_LIB=
AC_SUBST(CUDA_DRIVER_INCLUDE)
AC_SUBST(CUDA_DRIVER_LIB)
CUDA_DRIVER_CPPFLAGS=
CUDA_DRIVER_LDFLAGS=
AC_ARG_WITH(cuda-driver,
[AS_HELP_STRING([--with-cuda-driver=PATH],
[specify prefix directory for installed CUDA driver package.
Equivalent to --with-cuda-driver-include=PATH/include
plus --with-cuda-driver-lib=PATH/lib])])
AC_ARG_WITH(cuda-driver-include,
[AS_HELP_STRING([--with-cuda-driver-include=PATH],
[specify directory for installed CUDA driver include files])])
AC_ARG_WITH(cuda-driver-lib,
[AS_HELP_STRING([--with-cuda-driver-lib=PATH],
[specify directory for the installed CUDA driver library])])
case "x$with_cuda_driver" in
x) ;;
xno)
CUDA_DRIVER_INCLUDE=no
CUDA_DRIVER_LIB=no
;;
*) CUDA_DRIVER_INCLUDE=$with_cuda_driver/include
CUDA_DRIVER_LIB=$with_cuda_driver/lib
;;
esac
if test "x$with_cuda_driver_include" != x; then
CUDA_DRIVER_INCLUDE=$with_cuda_driver_include
fi
if test "x$with_cuda_driver_lib" != x; then
CUDA_DRIVER_LIB=$with_cuda_driver_lib
fi
if test "x$CUDA_DRIVER_INCLUDE" != x \
&& test "x$CUDA_DRIVER_INCLUDE" != xno; then
CUDA_DRIVER_CPPFLAGS=-I$CUDA_DRIVER_INCLUDE
fi
if test "x$CUDA_DRIVER_LIB" != x \
&& test "x$CUDA_DRIVER_LIB" != xno; then
CUDA_DRIVER_LDFLAGS=-L$CUDA_DRIVER_LIB
fi
PLUGIN_NVPTX=0
PLUGIN_NVPTX_CPPFLAGS=
PLUGIN_NVPTX_LDFLAGS=
PLUGIN_NVPTX_LIBS=
PLUGIN_NVPTX_DYNAMIC=0
AC_SUBST(PLUGIN_NVPTX_CPPFLAGS)
AC_SUBST(PLUGIN_NVPTX_LDFLAGS)
AC_SUBST(PLUGIN_NVPTX_LIBS)
PLUGIN_GCN=0
PLUGIN_GCN_LIBS=
AC_SUBST(PLUGIN_GCN_LIBS)
# Parse '--enable-offload-targets', figure out the corresponding libgomp
# plugins, and configure to find the corresponding offload compilers.
# 'offload_plugins' and 'offload_targets' will be populated in the same order.
offload_plugins=
offload_targets=
AC_SUBST(offload_plugins)
AC_SUBST(offload_targets)
offload_additional_options=
offload_additional_lib_paths=
AC_SUBST(offload_additional_options)
AC_SUBST(offload_additional_lib_paths)
if test x"$enable_offload_targets" != x; then
for tgt in `echo $enable_offload_targets | sed -e 's#,# #g'`; do
tgt_dir=`echo $tgt | grep '=' | sed 's/.*=//'`
tgt=`echo $tgt | sed 's/=.*//'`
tgt_plugin=
case $tgt in
*-intelmic-* | *-intelmicemul-*)
tgt_plugin=intelmic
;;
nvptx*)
case "${target}" in
aarch64*-*-* | powerpc64le-*-* | x86_64-*-*)
case "$ac_cv_sizeof_void_p" in
4)
# PR libgomp/65099: Currently, we only support offloading in
# 64-bit configurations.
PLUGIN_NVPTX=0
;;
*)
tgt_plugin=nvptx
PLUGIN_NVPTX=$tgt
if test "x$CUDA_DRIVER_LIB" != xno \
&& test "x$CUDA_DRIVER_LIB" != xno; then
PLUGIN_NVPTX_CPPFLAGS=$CUDA_DRIVER_CPPFLAGS
PLUGIN_NVPTX_LDFLAGS=$CUDA_DRIVER_LDFLAGS
PLUGIN_NVPTX_LIBS='-lcuda'
PLUGIN_NVPTX_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$PLUGIN_NVPTX_CPPFLAGS $CPPFLAGS"
PLUGIN_NVPTX_save_LDFLAGS=$LDFLAGS
LDFLAGS="$PLUGIN_NVPTX_LDFLAGS $LDFLAGS"
PLUGIN_NVPTX_save_LIBS=$LIBS
LIBS="$PLUGIN_NVPTX_LIBS $LIBS"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[#include "cuda.h"],
[CUresult r = cuCtxPushCurrent (NULL);])],
[PLUGIN_NVPTX=1])
CPPFLAGS=$PLUGIN_NVPTX_save_CPPFLAGS
LDFLAGS=$PLUGIN_NVPTX_save_LDFLAGS
LIBS=$PLUGIN_NVPTX_save_LIBS
fi
case $PLUGIN_NVPTX in
nvptx*)
if (test "x$CUDA_DRIVER_INCLUDE" = x \
|| test "x$CUDA_DRIVER_INCLUDE" = xno) \
&& (test "x$CUDA_DRIVER_LIB" = x \
|| test "x$CUDA_DRIVER_LIB" = xno); then
PLUGIN_NVPTX=1
PLUGIN_NVPTX_LIBS='-ldl'
PLUGIN_NVPTX_DYNAMIC=1
else
PLUGIN_NVPTX=0
AC_MSG_ERROR([CUDA driver package required for nvptx support])
fi
;;
esac
;;
esac
;;
*-*-*)
# Target architecture not supported.
PLUGIN_NVPTX=0
;;
esac
;;
amdgcn*)
case "${target}" in
x86_64-*-*)
case "$ac_cv_sizeof_void_p" in
4)
PLUGIN_GCN=0
;;
*)
tgt_plugin=gcn
PLUGIN_GCN=$tgt
PLUGIN_GCN_LIBS="-ldl"
PLUGIN_GCN=1
;;
esac
;;
*-*-*)
PLUGIN_GCN=0
;;
esac
;;
*)
AC_MSG_ERROR([unknown offload target specified])
;;
esac
if test x"$tgt_plugin" = x; then
# Not configuring libgomp for this offload target if we're not building
# the corresponding offload plugin.
continue
elif test x"$offload_plugins" = x; then
offload_plugins=$tgt_plugin
offload_targets=$tgt
else
offload_plugins=$offload_plugins,$tgt_plugin
offload_targets=$offload_targets,$tgt
fi
# Configure additional search paths.
if test x"$tgt_dir" != x; then
offload_additional_options="$offload_additional_options -B$tgt_dir/\$(libexecdir:\$(exec_prefix)/%=%)/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
else
offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"
fi
done
fi
AC_DEFINE_UNQUOTED(OFFLOAD_PLUGINS, "$offload_plugins",
[Define to offload plugins, separated by commas.])
AM_CONDITIONAL([PLUGIN_NVPTX], [test $PLUGIN_NVPTX = 1])
AM_CONDITIONAL([PLUGIN_NVPTX_DYNAMIC], [test $PLUGIN_NVPTX_DYNAMIC = 1])
AM_CONDITIONAL([PLUGIN_GCN], [test $PLUGIN_GCN = 1])
|