Hi! On Wed, 13 Jan 2016 18:39:26 +0100, Martin Jambor <mjam...@suse.cz> wrote: > this patch contains changes to the configuration mechanism and offload > bits, so that users can build compilers with HSA support. > > It is a re-post of > https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00714.html, which, has > already been approved by Jakub after a few changes > (https://gcc.gnu.org/ml/gcc-patches/2015-12/msg01284.html).
On top of that, I applied four patches "as obvious": > --- a/libgomp/plugin/configfrag.ac > +++ b/libgomp/plugin/configfrag.ac > @@ -81,6 +81,62 @@ AC_SUBST(PLUGIN_NVPTX_CPPFLAGS) > AC_SUBST(PLUGIN_NVPTX_LDFLAGS) > AC_SUBST(PLUGIN_NVPTX_LIBS) > > +# Look for HSA run-time, its includes and libraries > + > +HSA_RUNTIME_INCLUDE= > +HSA_RUNTIME_LIB= > +AC_SUBST(HSA_RUNTIME_INCLUDE) > +AC_SUBST(HSA_RUNTIME_LIB) > +HSA_RUNTIME_CPPFLAGS= > +HSA_RUNTIME_LDFLAGS= > + > +AC_ARG_WITH(hsa-runtime, > + [AS_HELP_STRING([--with-hsa-runtime=PATH], > + [specify prefix directory for installed HSA run-time package. > + Equivalent to --with-hsa-runtime-include=PATH/include > + plus --with-hsa-runtime-lib=PATH/lib])]) > +AC_ARG_WITH(hsa-runtime-include, > + [AS_HELP_STRING([--with-hsa-runtime-include=PATH], > + [specify directory for installed HSA run-time include files])]) > +AC_ARG_WITH(hsa-runtime-lib, > + [AS_HELP_STRING([--with-hsa-runtime-lib=PATH], > + [specify directory for the installed HSA run-time library])]) > +if test "x$with_hsa_runtime" != x; then > + HSA_RUNTIME_INCLUDE=$with_hsa_runtime/include > + HSA_RUNTIME_LIB=$with_hsa_runtime/lib > +fi > +if test "x$with_hsa_runtime_include" != x; then > + HSA_RUNTIME_INCLUDE=$with_hsa_runtime_include > +fi > +if test "x$with_hsa_runtime_lib" != x; then > + HSA_RUNTIME_LIB=$with_hsa_runtime_lib > +fi > +if test "x$HSA_RUNTIME_INCLUDE" != x; then > + HSA_RUNTIME_CPPFLAGS=-I$HSA_RUNTIME_INCLUDE > +fi > +if test "x$HSA_RUNTIME_LIB" != x; then > + HSA_RUNTIME_LDFLAGS=-L$HSA_RUNTIME_LIB > +fi > + > +AC_ARG_WITH(hsa-kmt-lib, > + [AS_HELP_STRING([--with-hsa-kmt-lib=PATH], > + [specify directory for installed HSA KMT library.])]) > +if test "x$with_hsa_kmt_lib" != x; then > + HSA_RUNTIME_LDFLAGS="$HSA_RUNTIME_LDFLAGS -L$with_hsa_kmt_lib" > + HSA_RUNTIME_LIB= > +fi > + > +PLUGIN_HSA=0 > +PLUGIN_HSA_CPPFLAGS= > +PLUGIN_HSA_LDFLAGS= > +PLUGIN_HSA_LIBS= > +AC_SUBST(PLUGIN_HSA) > +AC_SUBST(PLUGIN_HSA_CPPFLAGS) > +AC_SUBST(PLUGIN_HSA_LDFLAGS) > +AC_SUBST(PLUGIN_HSA_LIBS) > + > + > + > # Get offload targets and path to install tree of offloading compiler. > offload_additional_options= > offload_additional_lib_paths= > @@ -122,6 +178,49 @@ if test x"$enable_offload_targets" != x; then > ;; > esac > ;; > + hsa*) > + case "${target}" in > + x86_64-*-*) > + case " ${CC} ${CFLAGS} " in > + *" -m32 "*) > + PLUGIN_HSA=0 > + ;; > + *) > + tgt_name=hsa > + PLUGIN_HSA=$tgt > + PLUGIN_HSA_CPPFLAGS=$HSA_RUNTIME_CPPFLAGS > + PLUGIN_HSA_LDFLAGS=$HSA_RUNTIME_LDFLAGS > + PLUGIN_HSA_LIBS="-lhsa-runtime64 -lhsakmt" > + > + PLUGIN_HSA_save_CPPFLAGS=$CPPFLAGS > + CPPFLAGS="$PLUGIN_HSA_CPPFLAGS $CPPFLAGS" > + PLUGIN_HSA_save_LDFLAGS=$LDFLAGS > + LDFLAGS="$PLUGIN_HSA_LDFLAGS $LDFLAGS" > + PLUGIN_HSA_save_LIBS=$LIBS > + LIBS="$PLUGIN_HSA_LIBS $LIBS" > + > + AC_LINK_IFELSE( > + [AC_LANG_PROGRAM( > + [#include "hsa.h"], > + [hsa_status_t status = hsa_init ()])], > + [PLUGIN_HSA=1]) > + CPPFLAGS=$PLUGIN_HSA_save_CPPFLAGS > + LDFLAGS=$PLUGIN_HSA_save_LDFLAGS > + LIBS=$PLUGIN_HSA_save_LIBS > + case $PLUGIN_HSA in > + hsa*) > + HSA_PLUGIN=0 > + AC_MSG_ERROR([HSA run-time package required for HSA > support]) > + ;; > + esac > + ;; > + esac > + ;; > + *-*-*) > + PLUGIN_HSA=0 > + ;; > + esac > + ;; > *) > AC_MSG_ERROR([unknown offload target specified]) > ;; For the cases where PLUGIN_HSA is set to "0", we also shouldn't configure libgomp for hsa offloading: loading the plugin will expectedly fail if we don't build it; committed in r233070: commit bf57e97e03d046a6109d976bc098e197f220d1b9 Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Tue Feb 2 12:48:04 2016 +0000 libgomp: Don't configure for offloading target if we don't build the corresponding plugin libgomp/ * plugin/configfrag.ac: Don't configure for offloading target if we don't build the corresponding plugin. * configure: Regenerate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233070 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgomp/ChangeLog | 6 ++++++ libgomp/configure | 7 ++++++- libgomp/plugin/configfrag.ac | 7 ++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git libgomp/ChangeLog libgomp/ChangeLog index c94fa27..610074c 100644 --- libgomp/ChangeLog +++ libgomp/ChangeLog @@ -1,3 +1,9 @@ +2016-02-02 Thomas Schwinge <tho...@codesourcery.com> + + * plugin/configfrag.ac: Don't configure for offloading target if + we don't build the corresponding plugin. + * configure: Regenerate. + 2016-02-01 Nathan Sidwell <nat...@codesourcery.com> * testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c: New. diff --git libgomp/configure libgomp/configure index 1410bc7..d34a350 100755 --- libgomp/configure +++ libgomp/configure @@ -15323,6 +15323,7 @@ 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_name= case $tgt in *-intelmic-* | *-intelmicemul-*) tgt_name=intelmic @@ -15424,7 +15425,11 @@ rm -f core conftest.err conftest.$ac_objext \ as_fn_error "unknown offload target specified" "$LINENO" 5 ;; esac - if test x"$offload_targets" = x; then + if test x"$tgt_name" = x; then + # Don't configure libgomp for this offloading target if we don't build + # the corresponding plugin. + continue + elif test x"$offload_targets" = x; then offload_targets=$tgt_name else offload_targets=$offload_targets,$tgt_name diff --git libgomp/plugin/configfrag.ac libgomp/plugin/configfrag.ac index 2a9d9f9..01815d4 100644 --- libgomp/plugin/configfrag.ac +++ libgomp/plugin/configfrag.ac @@ -146,6 +146,7 @@ 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_name= case $tgt in *-intelmic-* | *-intelmicemul-*) tgt_name=intelmic @@ -225,7 +226,11 @@ if test x"$enable_offload_targets" != x; then AC_MSG_ERROR([unknown offload target specified]) ;; esac - if test x"$offload_targets" = x; then + if test x"$tgt_name" = x; then + # Don't configure libgomp for this offloading target if we don't build + # the corresponding plugin. + continue + elif test x"$offload_targets" = x; then offload_targets=$tgt_name else offload_targets=$offload_targets,$tgt_name No separate offloading compiler will be searched/invoked for hsa offloading; committed in r233071: commit 071822e70273f6df33adee3ac278c229caeabf0a Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Tue Feb 2 12:48:21 2016 +0000 libgomp: For hsa offloading, compilation is all handled by the target compiler libgomp/ * plugin/configfrag.ac (offload_additional_options) (offload_additional_lib_paths): Don't amend for hsa offloading. * configure: Regenerate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233071 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgomp/ChangeLog | 4 ++++ libgomp/configure | 5 ++++- libgomp/plugin/configfrag.ac | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git libgomp/ChangeLog libgomp/ChangeLog index 610074c..6cae4d7 100644 --- libgomp/ChangeLog +++ libgomp/ChangeLog @@ -1,5 +1,9 @@ 2016-02-02 Thomas Schwinge <tho...@codesourcery.com> + * plugin/configfrag.ac (offload_additional_options) + (offload_additional_lib_paths): Don't amend for hsa offloading. + * configure: Regenerate. + * plugin/configfrag.ac: Don't configure for offloading target if we don't build the corresponding plugin. * configure: Regenerate. diff --git libgomp/configure libgomp/configure index d34a350..f643bf8 100755 --- libgomp/configure +++ libgomp/configure @@ -15434,7 +15434,10 @@ rm -f core conftest.err conftest.$ac_objext \ else offload_targets=$offload_targets,$tgt_name fi - if test x"$tgt_dir" != x; then + if test "$tgt_name" = hsa; then + # Offloading compilation is all handled by the target compiler. + : + elif test x"$tgt_dir" != x; then offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/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 diff --git libgomp/plugin/configfrag.ac libgomp/plugin/configfrag.ac index 01815d4..b9209cb 100644 --- libgomp/plugin/configfrag.ac +++ libgomp/plugin/configfrag.ac @@ -235,7 +235,10 @@ if test x"$enable_offload_targets" != x; then else offload_targets=$offload_targets,$tgt_name fi - if test x"$tgt_dir" != x; then + if test "$tgt_name" = hsa; then + # Offloading compilation is all handled by the target compiler. + : + elif test x"$tgt_dir" != x; then offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/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 The hsa libgomp plugin needs to find the libraries it's been linked against; committed in r233072: commit f1deafd651ec9c8bb8196ab32a637a13d279461f Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Tue Feb 2 12:48:31 2016 +0000 libgomp: Use HSA_RUNTIME_LIB, HSA_KMT_LIB in the testsuite libgomp/ * plugin/configfrag.ac (HSA_KMT_LIB, HSA_KMT_LDFLAGS): New variables. * testsuite/libgomp-test-support.exp.in (hsa_runtime_lib) (hsa_kmt_lib): Set variables. * testsuite/lib/libgomp.exp (libgomp_init): Use them to amend always_ld_library_path. * Makefile.in: Regenerate. * configure: Likewise. * testsuite/Makefile.in: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233072 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgomp/ChangeLog | 10 ++++++++++ libgomp/Makefile.in | 1 + libgomp/configure | 16 +++++++++++----- libgomp/plugin/configfrag.ac | 11 ++++++++--- libgomp/testsuite/Makefile.in | 1 + libgomp/testsuite/lib/libgomp.exp | 10 +++++++++- libgomp/testsuite/libgomp-test-support.exp.in | 2 ++ 7 files changed, 42 insertions(+), 9 deletions(-) diff --git libgomp/ChangeLog libgomp/ChangeLog index 6cae4d7..806e23d 100644 --- libgomp/ChangeLog +++ libgomp/ChangeLog @@ -1,5 +1,15 @@ 2016-02-02 Thomas Schwinge <tho...@codesourcery.com> + * plugin/configfrag.ac (HSA_KMT_LIB, HSA_KMT_LDFLAGS): New + variables. + * testsuite/libgomp-test-support.exp.in (hsa_runtime_lib) + (hsa_kmt_lib): Set variables. + * testsuite/lib/libgomp.exp (libgomp_init): Use them to amend + always_ld_library_path. + * Makefile.in: Regenerate. + * configure: Likewise. + * testsuite/Makefile.in: Likewise. + * plugin/configfrag.ac (offload_additional_options) (offload_additional_lib_paths): Don't amend for hsa offloading. * configure: Regenerate. diff --git libgomp/Makefile.in libgomp/Makefile.in index bbfac4e..88c8517 100644 --- libgomp/Makefile.in +++ libgomp/Makefile.in @@ -268,6 +268,7 @@ FC = @FC@ FCFLAGS = @FCFLAGS@ FGREP = @FGREP@ GREP = @GREP@ +HSA_KMT_LIB = @HSA_KMT_LIB@ HSA_RUNTIME_INCLUDE = @HSA_RUNTIME_INCLUDE@ HSA_RUNTIME_LIB = @HSA_RUNTIME_LIB@ INSTALL = @INSTALL@ diff --git libgomp/configure libgomp/configure index f643bf8..8d03eb6 100755 --- libgomp/configure +++ libgomp/configure @@ -637,6 +637,7 @@ PLUGIN_HSA_LIBS PLUGIN_HSA_LDFLAGS PLUGIN_HSA_CPPFLAGS PLUGIN_HSA +HSA_KMT_LIB HSA_RUNTIME_LIB HSA_RUNTIME_INCLUDE PLUGIN_NVPTX_LIBS @@ -11144,7 +11145,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11147 "configure" +#line 11148 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11250,7 +11251,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11253 "configure" +#line 11254 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -15292,6 +15293,9 @@ if test "x$HSA_RUNTIME_LIB" != x; then HSA_RUNTIME_LDFLAGS=-L$HSA_RUNTIME_LIB fi +HSA_KMT_LIB= + +HSA_KMT_LDFLAGS= # Check whether --with-hsa-kmt-lib was given. if test "${with_hsa_kmt_lib+set}" = set; then : @@ -15299,8 +15303,10 @@ if test "${with_hsa_kmt_lib+set}" = set; then : fi if test "x$with_hsa_kmt_lib" != x; then - HSA_RUNTIME_LDFLAGS="$HSA_RUNTIME_LDFLAGS -L$with_hsa_kmt_lib" - HSA_RUNTIME_LIB= + HSA_KMT_LIB=$with_hsa_kmt_lib +fi +if test "x$HSA_KMT_LIB" != x; then + HSA_KMT_LDFLAGS=-L$HSA_KMT_LIB fi PLUGIN_HSA=0 @@ -15378,7 +15384,7 @@ rm -f core conftest.err conftest.$ac_objext \ tgt_name=hsa PLUGIN_HSA=$tgt PLUGIN_HSA_CPPFLAGS=$HSA_RUNTIME_CPPFLAGS - PLUGIN_HSA_LDFLAGS=$HSA_RUNTIME_LDFLAGS + PLUGIN_HSA_LDFLAGS="$HSA_RUNTIME_LDFLAGS $HSA_KMT_LDFLAGS" PLUGIN_HSA_LIBS="-lhsa-runtime64 -lhsakmt" PLUGIN_HSA_save_CPPFLAGS=$CPPFLAGS diff --git libgomp/plugin/configfrag.ac libgomp/plugin/configfrag.ac index b9209cb..88b4156 100644 --- libgomp/plugin/configfrag.ac +++ libgomp/plugin/configfrag.ac @@ -118,12 +118,17 @@ if test "x$HSA_RUNTIME_LIB" != x; then HSA_RUNTIME_LDFLAGS=-L$HSA_RUNTIME_LIB fi +HSA_KMT_LIB= +AC_SUBST(HSA_KMT_LIB) +HSA_KMT_LDFLAGS= AC_ARG_WITH(hsa-kmt-lib, [AS_HELP_STRING([--with-hsa-kmt-lib=PATH], [specify directory for installed HSA KMT library.])]) if test "x$with_hsa_kmt_lib" != x; then - HSA_RUNTIME_LDFLAGS="$HSA_RUNTIME_LDFLAGS -L$with_hsa_kmt_lib" - HSA_RUNTIME_LIB= + HSA_KMT_LIB=$with_hsa_kmt_lib +fi +if test "x$HSA_KMT_LIB" != x; then + HSA_KMT_LDFLAGS=-L$HSA_KMT_LIB fi PLUGIN_HSA=0 @@ -190,7 +195,7 @@ if test x"$enable_offload_targets" != x; then tgt_name=hsa PLUGIN_HSA=$tgt PLUGIN_HSA_CPPFLAGS=$HSA_RUNTIME_CPPFLAGS - PLUGIN_HSA_LDFLAGS=$HSA_RUNTIME_LDFLAGS + PLUGIN_HSA_LDFLAGS="$HSA_RUNTIME_LDFLAGS $HSA_KMT_LDFLAGS" PLUGIN_HSA_LIBS="-lhsa-runtime64 -lhsakmt" PLUGIN_HSA_save_CPPFLAGS=$CPPFLAGS diff --git libgomp/testsuite/Makefile.in libgomp/testsuite/Makefile.in index 1fae9e8..4dbb406 100644 --- libgomp/testsuite/Makefile.in +++ libgomp/testsuite/Makefile.in @@ -111,6 +111,7 @@ FC = @FC@ FCFLAGS = @FCFLAGS@ FGREP = @FGREP@ GREP = @GREP@ +HSA_KMT_LIB = @HSA_KMT_LIB@ HSA_RUNTIME_INCLUDE = @HSA_RUNTIME_INCLUDE@ HSA_RUNTIME_LIB = @HSA_RUNTIME_LIB@ INSTALL = @INSTALL@ diff --git libgomp/testsuite/lib/libgomp.exp libgomp/testsuite/lib/libgomp.exp index 6dc1e8e..bb9b15f 100644 --- libgomp/testsuite/lib/libgomp.exp +++ libgomp/testsuite/lib/libgomp.exp @@ -184,7 +184,7 @@ proc libgomp_init { args } { } lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.." - # For build-tree testing, also consider the CUDA paths used for builing. + # For build-tree testing, also consider the library paths used for builing. # For installed testing, we assume all that to be provided in the sysroot. if { $blddir != "" } { global cuda_driver_include @@ -200,6 +200,14 @@ proc libgomp_init { args } { lappend ALWAYS_CFLAGS "additional_flags=-L$cuda_driver_lib" append always_ld_library_path ":$cuda_driver_lib" } + global hsa_runtime_lib + global hsa_kmt_lib + if { $hsa_runtime_lib != "" } { + append always_ld_library_path ":$hsa_runtime_lib" + } + if { $hsa_kmt_lib != "" } { + append always_ld_library_path ":$hsa_kmt_lib" + } } # We use atomic operations in the testcases to validate results. diff --git libgomp/testsuite/libgomp-test-support.exp.in libgomp/testsuite/libgomp-test-support.exp.in index 764bec0..5a724fb 100644 --- libgomp/testsuite/libgomp-test-support.exp.in +++ libgomp/testsuite/libgomp-test-support.exp.in @@ -1,4 +1,6 @@ set cuda_driver_include "@CUDA_DRIVER_INCLUDE@" set cuda_driver_lib "@CUDA_DRIVER_LIB@" +set hsa_runtime_lib "@HSA_RUNTIME_LIB@" +set hsa_kmt_lib "@HSA_KMT_LIB@" set offload_targets "@offload_targets@" Skip (unsupported) hsa offloading for OpenACC test cases; committed in r233073: commit 6637013a46441d9808a681526d249bfad10877fe Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Tue Feb 2 12:48:41 2016 +0000 libgomp: Skip hsa offloading for OpenACC test cases libgomp/ * testsuite/lib/libgomp.exp: Skip hsa offloading for OpenACC test cases. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233073 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgomp/ChangeLog | 3 +++ libgomp/testsuite/lib/libgomp.exp | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git libgomp/ChangeLog libgomp/ChangeLog index 806e23d..6c9bf6a 100644 --- libgomp/ChangeLog +++ libgomp/ChangeLog @@ -1,5 +1,8 @@ 2016-02-02 Thomas Schwinge <tho...@codesourcery.com> + * testsuite/lib/libgomp.exp: Skip hsa offloading for OpenACC test + cases. + * plugin/configfrag.ac (HSA_KMT_LIB, HSA_KMT_LDFLAGS): New variables. * testsuite/libgomp-test-support.exp.in (hsa_runtime_lib) diff --git libgomp/testsuite/lib/libgomp.exp libgomp/testsuite/lib/libgomp.exp index bb9b15f..a4c9d83 100644 --- libgomp/testsuite/lib/libgomp.exp +++ libgomp/testsuite/lib/libgomp.exp @@ -42,15 +42,17 @@ load_file libgomp-test-support.exp set offload_targets_s [split $offload_targets ","] set offload_targets_s_openacc {} foreach offload_target_openacc $offload_targets_s { + # Translate to OpenACC names, or skip if not yet supported. switch $offload_target_openacc { intelmic { - # Skip; will all FAIL because of missing - # GOMP_OFFLOAD_CAP_OPENACC_200. continue } nvptx { set offload_target_openacc "nvidia" } + hsa { + continue + } } lappend offload_targets_s_openacc "$offload_target_openacc" } Grüße Thomas
signature.asc
Description: PGP signature