configfrag.ac revision 1.1.1.1.2.1 1 1.1 mrg # Plugins for offload execution, configure.ac fragment. -*- mode: autoconf -*-
2 1.1 mrg #
3 1.1.1.1.2.1 pgoyette # Copyright (C) 2014-2016 Free Software Foundation, Inc.
4 1.1 mrg #
5 1.1 mrg # Contributed by Mentor Embedded.
6 1.1 mrg #
7 1.1 mrg # This file is part of the GNU Offloading and Multi Processing Library
8 1.1 mrg # (libgomp).
9 1.1 mrg #
10 1.1 mrg # Libgomp is free software; you can redistribute it and/or modify it
11 1.1 mrg # under the terms of the GNU General Public License as published by
12 1.1 mrg # the Free Software Foundation; either version 3, or (at your option)
13 1.1 mrg # any later version.
14 1.1 mrg #
15 1.1 mrg # Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
16 1.1 mrg # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 1.1 mrg # FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 1.1 mrg # more details.
19 1.1 mrg #
20 1.1 mrg # Under Section 7 of GPL version 3, you are granted additional
21 1.1 mrg # permissions described in the GCC Runtime Library Exception, version
22 1.1 mrg # 3.1, as published by the Free Software Foundation.
23 1.1 mrg #
24 1.1 mrg # You should have received a copy of the GNU General Public License and
25 1.1 mrg # a copy of the GCC Runtime Library Exception along with this program;
26 1.1 mrg # see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
27 1.1 mrg # <http://www.gnu.org/licenses/>.
28 1.1 mrg
29 1.1 mrg offload_targets=
30 1.1 mrg AC_SUBST(offload_targets)
31 1.1 mrg plugin_support=yes
32 1.1 mrg AC_CHECK_LIB(dl, dlsym, , [plugin_support=no])
33 1.1 mrg if test x"$plugin_support" = xyes; then
34 1.1 mrg AC_DEFINE(PLUGIN_SUPPORT, 1,
35 1.1 mrg [Define if all infrastructure, needed for plugins, is supported.])
36 1.1 mrg elif test "x${enable_offload_targets-no}" != xno; then
37 1.1 mrg AC_MSG_ERROR([Can't support offloading without support for plugins])
38 1.1 mrg fi
39 1.1 mrg
40 1.1 mrg # Look for the CUDA driver package.
41 1.1 mrg CUDA_DRIVER_INCLUDE=
42 1.1 mrg CUDA_DRIVER_LIB=
43 1.1 mrg AC_SUBST(CUDA_DRIVER_INCLUDE)
44 1.1 mrg AC_SUBST(CUDA_DRIVER_LIB)
45 1.1 mrg CUDA_DRIVER_CPPFLAGS=
46 1.1 mrg CUDA_DRIVER_LDFLAGS=
47 1.1 mrg AC_ARG_WITH(cuda-driver,
48 1.1 mrg [AS_HELP_STRING([--with-cuda-driver=PATH],
49 1.1 mrg [specify prefix directory for installed CUDA driver package.
50 1.1 mrg Equivalent to --with-cuda-driver-include=PATH/include
51 1.1 mrg plus --with-cuda-driver-lib=PATH/lib])])
52 1.1 mrg AC_ARG_WITH(cuda-driver-include,
53 1.1 mrg [AS_HELP_STRING([--with-cuda-driver-include=PATH],
54 1.1 mrg [specify directory for installed CUDA driver include files])])
55 1.1 mrg AC_ARG_WITH(cuda-driver-lib,
56 1.1 mrg [AS_HELP_STRING([--with-cuda-driver-lib=PATH],
57 1.1 mrg [specify directory for the installed CUDA driver library])])
58 1.1 mrg if test "x$with_cuda_driver" != x; then
59 1.1 mrg CUDA_DRIVER_INCLUDE=$with_cuda_driver/include
60 1.1 mrg CUDA_DRIVER_LIB=$with_cuda_driver/lib
61 1.1 mrg fi
62 1.1 mrg if test "x$with_cuda_driver_include" != x; then
63 1.1 mrg CUDA_DRIVER_INCLUDE=$with_cuda_driver_include
64 1.1 mrg fi
65 1.1 mrg if test "x$with_cuda_driver_lib" != x; then
66 1.1 mrg CUDA_DRIVER_LIB=$with_cuda_driver_lib
67 1.1 mrg fi
68 1.1 mrg if test "x$CUDA_DRIVER_INCLUDE" != x; then
69 1.1 mrg CUDA_DRIVER_CPPFLAGS=-I$CUDA_DRIVER_INCLUDE
70 1.1 mrg fi
71 1.1 mrg if test "x$CUDA_DRIVER_LIB" != x; then
72 1.1 mrg CUDA_DRIVER_LDFLAGS=-L$CUDA_DRIVER_LIB
73 1.1 mrg fi
74 1.1 mrg
75 1.1 mrg PLUGIN_NVPTX=0
76 1.1 mrg PLUGIN_NVPTX_CPPFLAGS=
77 1.1 mrg PLUGIN_NVPTX_LDFLAGS=
78 1.1 mrg PLUGIN_NVPTX_LIBS=
79 1.1 mrg AC_SUBST(PLUGIN_NVPTX)
80 1.1 mrg AC_SUBST(PLUGIN_NVPTX_CPPFLAGS)
81 1.1 mrg AC_SUBST(PLUGIN_NVPTX_LDFLAGS)
82 1.1 mrg AC_SUBST(PLUGIN_NVPTX_LIBS)
83 1.1 mrg
84 1.1.1.1.2.1 pgoyette # Look for HSA run-time, its includes and libraries
85 1.1.1.1.2.1 pgoyette
86 1.1.1.1.2.1 pgoyette HSA_RUNTIME_INCLUDE=
87 1.1.1.1.2.1 pgoyette HSA_RUNTIME_LIB=
88 1.1.1.1.2.1 pgoyette AC_SUBST(HSA_RUNTIME_INCLUDE)
89 1.1.1.1.2.1 pgoyette AC_SUBST(HSA_RUNTIME_LIB)
90 1.1.1.1.2.1 pgoyette HSA_RUNTIME_CPPFLAGS=
91 1.1.1.1.2.1 pgoyette HSA_RUNTIME_LDFLAGS=
92 1.1.1.1.2.1 pgoyette
93 1.1.1.1.2.1 pgoyette AC_ARG_WITH(hsa-runtime,
94 1.1.1.1.2.1 pgoyette [AS_HELP_STRING([--with-hsa-runtime=PATH],
95 1.1.1.1.2.1 pgoyette [specify prefix directory for installed HSA run-time package.
96 1.1.1.1.2.1 pgoyette Equivalent to --with-hsa-runtime-include=PATH/include
97 1.1.1.1.2.1 pgoyette plus --with-hsa-runtime-lib=PATH/lib])])
98 1.1.1.1.2.1 pgoyette AC_ARG_WITH(hsa-runtime-include,
99 1.1.1.1.2.1 pgoyette [AS_HELP_STRING([--with-hsa-runtime-include=PATH],
100 1.1.1.1.2.1 pgoyette [specify directory for installed HSA run-time include files])])
101 1.1.1.1.2.1 pgoyette AC_ARG_WITH(hsa-runtime-lib,
102 1.1.1.1.2.1 pgoyette [AS_HELP_STRING([--with-hsa-runtime-lib=PATH],
103 1.1.1.1.2.1 pgoyette [specify directory for the installed HSA run-time library])])
104 1.1.1.1.2.1 pgoyette if test "x$with_hsa_runtime" != x; then
105 1.1.1.1.2.1 pgoyette HSA_RUNTIME_INCLUDE=$with_hsa_runtime/include
106 1.1.1.1.2.1 pgoyette HSA_RUNTIME_LIB=$with_hsa_runtime/lib
107 1.1.1.1.2.1 pgoyette fi
108 1.1.1.1.2.1 pgoyette if test "x$with_hsa_runtime_include" != x; then
109 1.1.1.1.2.1 pgoyette HSA_RUNTIME_INCLUDE=$with_hsa_runtime_include
110 1.1.1.1.2.1 pgoyette fi
111 1.1.1.1.2.1 pgoyette if test "x$with_hsa_runtime_lib" != x; then
112 1.1.1.1.2.1 pgoyette HSA_RUNTIME_LIB=$with_hsa_runtime_lib
113 1.1.1.1.2.1 pgoyette fi
114 1.1.1.1.2.1 pgoyette if test "x$HSA_RUNTIME_INCLUDE" != x; then
115 1.1.1.1.2.1 pgoyette HSA_RUNTIME_CPPFLAGS=-I$HSA_RUNTIME_INCLUDE
116 1.1.1.1.2.1 pgoyette fi
117 1.1.1.1.2.1 pgoyette if test "x$HSA_RUNTIME_LIB" != x; then
118 1.1.1.1.2.1 pgoyette HSA_RUNTIME_LDFLAGS=-L$HSA_RUNTIME_LIB
119 1.1.1.1.2.1 pgoyette fi
120 1.1.1.1.2.1 pgoyette
121 1.1.1.1.2.1 pgoyette HSA_KMT_LIB=
122 1.1.1.1.2.1 pgoyette AC_SUBST(HSA_KMT_LIB)
123 1.1.1.1.2.1 pgoyette HSA_KMT_LDFLAGS=
124 1.1.1.1.2.1 pgoyette AC_ARG_WITH(hsa-kmt-lib,
125 1.1.1.1.2.1 pgoyette [AS_HELP_STRING([--with-hsa-kmt-lib=PATH],
126 1.1.1.1.2.1 pgoyette [specify directory for installed HSA KMT library.])])
127 1.1.1.1.2.1 pgoyette if test "x$with_hsa_kmt_lib" != x; then
128 1.1.1.1.2.1 pgoyette HSA_KMT_LIB=$with_hsa_kmt_lib
129 1.1.1.1.2.1 pgoyette fi
130 1.1.1.1.2.1 pgoyette if test "x$HSA_KMT_LIB" != x; then
131 1.1.1.1.2.1 pgoyette HSA_KMT_LDFLAGS=-L$HSA_KMT_LIB
132 1.1.1.1.2.1 pgoyette fi
133 1.1.1.1.2.1 pgoyette
134 1.1.1.1.2.1 pgoyette PLUGIN_HSA=0
135 1.1.1.1.2.1 pgoyette PLUGIN_HSA_CPPFLAGS=
136 1.1.1.1.2.1 pgoyette PLUGIN_HSA_LDFLAGS=
137 1.1.1.1.2.1 pgoyette PLUGIN_HSA_LIBS=
138 1.1.1.1.2.1 pgoyette AC_SUBST(PLUGIN_HSA)
139 1.1.1.1.2.1 pgoyette AC_SUBST(PLUGIN_HSA_CPPFLAGS)
140 1.1.1.1.2.1 pgoyette AC_SUBST(PLUGIN_HSA_LDFLAGS)
141 1.1.1.1.2.1 pgoyette AC_SUBST(PLUGIN_HSA_LIBS)
142 1.1.1.1.2.1 pgoyette
143 1.1.1.1.2.1 pgoyette
144 1.1.1.1.2.1 pgoyette
145 1.1 mrg # Get offload targets and path to install tree of offloading compiler.
146 1.1 mrg offload_additional_options=
147 1.1 mrg offload_additional_lib_paths=
148 1.1 mrg AC_SUBST(offload_additional_options)
149 1.1 mrg AC_SUBST(offload_additional_lib_paths)
150 1.1 mrg if test x"$enable_offload_targets" != x; then
151 1.1 mrg for tgt in `echo $enable_offload_targets | sed -e 's#,# #g'`; do
152 1.1 mrg tgt_dir=`echo $tgt | grep '=' | sed 's/.*=//'`
153 1.1 mrg tgt=`echo $tgt | sed 's/=.*//'`
154 1.1.1.1.2.1 pgoyette tgt_name=
155 1.1 mrg case $tgt in
156 1.1 mrg *-intelmic-* | *-intelmicemul-*)
157 1.1 mrg tgt_name=intelmic
158 1.1 mrg ;;
159 1.1 mrg nvptx*)
160 1.1 mrg tgt_name=nvptx
161 1.1 mrg PLUGIN_NVPTX=$tgt
162 1.1 mrg PLUGIN_NVPTX_CPPFLAGS=$CUDA_DRIVER_CPPFLAGS
163 1.1 mrg PLUGIN_NVPTX_LDFLAGS=$CUDA_DRIVER_LDFLAGS
164 1.1 mrg PLUGIN_NVPTX_LIBS='-lcuda'
165 1.1 mrg
166 1.1 mrg PLUGIN_NVPTX_save_CPPFLAGS=$CPPFLAGS
167 1.1 mrg CPPFLAGS="$PLUGIN_NVPTX_CPPFLAGS $CPPFLAGS"
168 1.1 mrg PLUGIN_NVPTX_save_LDFLAGS=$LDFLAGS
169 1.1 mrg LDFLAGS="$PLUGIN_NVPTX_LDFLAGS $LDFLAGS"
170 1.1 mrg PLUGIN_NVPTX_save_LIBS=$LIBS
171 1.1 mrg LIBS="$PLUGIN_NVPTX_LIBS $LIBS"
172 1.1 mrg AC_LINK_IFELSE(
173 1.1 mrg [AC_LANG_PROGRAM(
174 1.1 mrg [#include "cuda.h"],
175 1.1 mrg [CUresult r = cuCtxPushCurrent (NULL);])],
176 1.1 mrg [PLUGIN_NVPTX=1])
177 1.1 mrg CPPFLAGS=$PLUGIN_NVPTX_save_CPPFLAGS
178 1.1 mrg LDFLAGS=$PLUGIN_NVPTX_save_LDFLAGS
179 1.1 mrg LIBS=$PLUGIN_NVPTX_save_LIBS
180 1.1 mrg case $PLUGIN_NVPTX in
181 1.1 mrg nvptx*)
182 1.1 mrg PLUGIN_NVPTX=0
183 1.1 mrg AC_MSG_ERROR([CUDA driver package required for nvptx support])
184 1.1 mrg ;;
185 1.1 mrg esac
186 1.1 mrg ;;
187 1.1.1.1.2.1 pgoyette hsa*)
188 1.1.1.1.2.1 pgoyette case "${target}" in
189 1.1.1.1.2.1 pgoyette x86_64-*-*)
190 1.1.1.1.2.1 pgoyette case " ${CC} ${CFLAGS} " in
191 1.1.1.1.2.1 pgoyette *" -m32 "*)
192 1.1.1.1.2.1 pgoyette PLUGIN_HSA=0
193 1.1.1.1.2.1 pgoyette ;;
194 1.1.1.1.2.1 pgoyette *)
195 1.1.1.1.2.1 pgoyette tgt_name=hsa
196 1.1.1.1.2.1 pgoyette PLUGIN_HSA=$tgt
197 1.1.1.1.2.1 pgoyette PLUGIN_HSA_CPPFLAGS=$HSA_RUNTIME_CPPFLAGS
198 1.1.1.1.2.1 pgoyette PLUGIN_HSA_LDFLAGS="$HSA_RUNTIME_LDFLAGS $HSA_KMT_LDFLAGS"
199 1.1.1.1.2.1 pgoyette PLUGIN_HSA_LIBS="-lhsa-runtime64 -lhsakmt"
200 1.1.1.1.2.1 pgoyette
201 1.1.1.1.2.1 pgoyette PLUGIN_HSA_save_CPPFLAGS=$CPPFLAGS
202 1.1.1.1.2.1 pgoyette CPPFLAGS="$PLUGIN_HSA_CPPFLAGS $CPPFLAGS"
203 1.1.1.1.2.1 pgoyette PLUGIN_HSA_save_LDFLAGS=$LDFLAGS
204 1.1.1.1.2.1 pgoyette LDFLAGS="$PLUGIN_HSA_LDFLAGS $LDFLAGS"
205 1.1.1.1.2.1 pgoyette PLUGIN_HSA_save_LIBS=$LIBS
206 1.1.1.1.2.1 pgoyette LIBS="$PLUGIN_HSA_LIBS $LIBS"
207 1.1.1.1.2.1 pgoyette
208 1.1.1.1.2.1 pgoyette AC_LINK_IFELSE(
209 1.1.1.1.2.1 pgoyette [AC_LANG_PROGRAM(
210 1.1.1.1.2.1 pgoyette [#include "hsa.h"],
211 1.1.1.1.2.1 pgoyette [hsa_status_t status = hsa_init ()])],
212 1.1.1.1.2.1 pgoyette [PLUGIN_HSA=1])
213 1.1.1.1.2.1 pgoyette CPPFLAGS=$PLUGIN_HSA_save_CPPFLAGS
214 1.1.1.1.2.1 pgoyette LDFLAGS=$PLUGIN_HSA_save_LDFLAGS
215 1.1.1.1.2.1 pgoyette LIBS=$PLUGIN_HSA_save_LIBS
216 1.1.1.1.2.1 pgoyette case $PLUGIN_HSA in
217 1.1.1.1.2.1 pgoyette hsa*)
218 1.1.1.1.2.1 pgoyette HSA_PLUGIN=0
219 1.1.1.1.2.1 pgoyette AC_MSG_ERROR([HSA run-time package required for HSA support])
220 1.1.1.1.2.1 pgoyette ;;
221 1.1.1.1.2.1 pgoyette esac
222 1.1.1.1.2.1 pgoyette ;;
223 1.1.1.1.2.1 pgoyette esac
224 1.1.1.1.2.1 pgoyette ;;
225 1.1.1.1.2.1 pgoyette *-*-*)
226 1.1.1.1.2.1 pgoyette PLUGIN_HSA=0
227 1.1.1.1.2.1 pgoyette ;;
228 1.1.1.1.2.1 pgoyette esac
229 1.1.1.1.2.1 pgoyette ;;
230 1.1 mrg *)
231 1.1 mrg AC_MSG_ERROR([unknown offload target specified])
232 1.1 mrg ;;
233 1.1 mrg esac
234 1.1.1.1.2.1 pgoyette if test x"$tgt_name" = x; then
235 1.1.1.1.2.1 pgoyette # Don't configure libgomp for this offloading target if we don't build
236 1.1.1.1.2.1 pgoyette # the corresponding plugin.
237 1.1.1.1.2.1 pgoyette continue
238 1.1.1.1.2.1 pgoyette elif test x"$offload_targets" = x; then
239 1.1 mrg offload_targets=$tgt_name
240 1.1 mrg else
241 1.1 mrg offload_targets=$offload_targets,$tgt_name
242 1.1 mrg fi
243 1.1.1.1.2.1 pgoyette if test "$tgt_name" = hsa; then
244 1.1.1.1.2.1 pgoyette # Offloading compilation is all handled by the target compiler.
245 1.1.1.1.2.1 pgoyette :
246 1.1.1.1.2.1 pgoyette elif test x"$tgt_dir" != x; then
247 1.1 mrg offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
248 1.1 mrg offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
249 1.1 mrg else
250 1.1 mrg offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
251 1.1 mrg offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"
252 1.1 mrg fi
253 1.1 mrg done
254 1.1 mrg fi
255 1.1 mrg AC_DEFINE_UNQUOTED(OFFLOAD_TARGETS, "$offload_targets",
256 1.1.1.1.2.1 pgoyette [Define to offload targets, separated by commas.])
257 1.1 mrg AM_CONDITIONAL([PLUGIN_NVPTX], [test $PLUGIN_NVPTX = 1])
258 1.1 mrg AC_DEFINE_UNQUOTED([PLUGIN_NVPTX], [$PLUGIN_NVPTX],
259 1.1 mrg [Define to 1 if the NVIDIA plugin is built, 0 if not.])
260 1.1.1.1.2.1 pgoyette AM_CONDITIONAL([PLUGIN_HSA], [test $PLUGIN_HSA = 1])
261 1.1.1.1.2.1 pgoyette AC_DEFINE_UNQUOTED([PLUGIN_HSA], [$PLUGIN_HSA],
262 1.1.1.1.2.1 pgoyette [Define to 1 if the HSA plugin is built, 0 if not.])
263