From: Thomas Schwinge <tho...@codesourcery.com> gcc/ * gcc.c (LINK_COMMAND_SPEC, GOMP_SELF_SPECS): For -fopenacc, link to libgomp and its dependencies. * config/arc/arc.h (LINK_COMMAND_SPEC): Likewise. * config/darwin.h (LINK_COMMAND_SPEC_A): Likewise. * config/i386/mingw32.h (GOMP_SELF_SPECS): Likewise. * config/ia64/hpux.h (LIB_SPEC): Likewise. * config/pa/pa-hpux11.h (LIB_SPEC): Likewise. * config/pa/pa64-hpux.h (LIB_SPEC): Likewise. * doc/invoke.texi (-fopenacc): Update. libgomp/ * libgomp.map (OACC_2.0): New symbol version. * libgomp.spec.in: Update comment. * configure.ac: Likewise. * configure: Regenerate. * Makefile.am (nodist_libsubinclude_HEADERS): Add openacc.h. (nodist_finclude_HEADERS): Add openacc_lib.h, openacc.f90, openacc.mod, and openacc_kinds.mod. (openacc_kinds.mod): New target. (%.mod): New target, generalized from omp_lib.mod. * Makefile.in: Regenerate. * openacc.f90: New file. * openacc.h: Likewise. * openacc_lib.h: Likewise. * testsuite/libgomp.oacc-c++/c++.exp: Likewise. * testsuite/libgomp.oacc-c/c.exp: Likewise. * testsuite/libgomp.oacc-c/lib-1.c: Likewise. * testsuite/libgomp.oacc-fortran/fortran.exp: Likewise. * testsuite/libgomp.oacc-fortran/lib-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/lib-2.f: Likewise. * testsuite/libgomp.oacc-fortran/lib-3.f: Likewise. --- gcc/config/arc/arc.h | 2 +- gcc/config/darwin.h | 2 +- gcc/config/i386/mingw32.h | 2 +- gcc/config/ia64/hpux.h | 2 +- gcc/config/pa/pa-hpux11.h | 2 +- gcc/config/pa/pa64-hpux.h | 12 ++-- gcc/doc/invoke.texi | 4 +- gcc/gcc.c | 7 ++- libgomp/Makefile.am | 9 ++- libgomp/Makefile.in | 10 +++- libgomp/configure | 2 +- libgomp/configure.ac | 2 +- libgomp/libgomp.map | 3 + libgomp/libgomp.spec.in | 2 +- libgomp/openacc.f90 | 37 ++++++++++++ libgomp/openacc.h | 45 ++++++++++++++ libgomp/openacc_lib.h | 26 ++++++++ libgomp/testsuite/libgomp.oacc-c++/c++.exp | 66 +++++++++++++++++++++ libgomp/testsuite/libgomp.oacc-c/c.exp | 36 +++++++++++ libgomp/testsuite/libgomp.oacc-c/lib-1.c | 7 +++ libgomp/testsuite/libgomp.oacc-fortran/fortran.exp | 69 ++++++++++++++++++++++ libgomp/testsuite/libgomp.oacc-fortran/lib-1.f90 | 3 + libgomp/testsuite/libgomp.oacc-fortran/lib-2.f | 3 + libgomp/testsuite/libgomp.oacc-fortran/lib-3.f | 3 + 24 files changed, 332 insertions(+), 24 deletions(-) create mode 100644 libgomp/openacc.f90 create mode 100644 libgomp/openacc.h create mode 100644 libgomp/openacc_lib.h create mode 100644 libgomp/testsuite/libgomp.oacc-c++/c++.exp create mode 100644 libgomp/testsuite/libgomp.oacc-c/c.exp create mode 100644 libgomp/testsuite/libgomp.oacc-c/lib-1.c create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/fortran.exp create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/lib-1.f90 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/lib-2.f create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/lib-3.f
diff --git gcc/config/arc/arc.h gcc/config/arc/arc.h index 637f7b6..14fc717 100644 --- gcc/config/arc/arc.h +++ gcc/config/arc/arc.h @@ -174,7 +174,7 @@ along with GCC; see the file COPYING3. If not see %(linker) %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\ %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\ %{static:} %{L*} %(mfwrap) %(link_libgcc) %o\ - %{fopenmp:%:include(libgomp.spec)%(link_gomp)} %(mflib)\ + %{fopenacc|fopenmp:%:include(libgomp.spec)%(link_gomp)} %(mflib)\ %{fprofile-arcs|fprofile-generate|coverage:-lgcov}\ %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\ %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}" diff --git gcc/config/darwin.h gcc/config/darwin.h index 596c9ef..735b6b9 100644 --- gcc/config/darwin.h +++ gcc/config/darwin.h @@ -176,7 +176,7 @@ extern GTY(()) int darwin_ms_struct; %{o*}%{!o:-o a.out} \ %{!nostdlib:%{!nostartfiles:%S}} \ %{L*} %(link_libgcc) %o %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} \ - %{fopenmp|ftree-parallelize-loops=*: \ + %{fopenacc|fopenmp|ftree-parallelize-loops=*: \ %{static|static-libgcc|static-libstdc++|static-libgfortran: libgomp.a%s; : -lgomp } } \ %{fgnu-tm: \ %{static|static-libgcc|static-libstdc++|static-libgfortran: libitm.a%s; : -litm } } \ diff --git gcc/config/i386/mingw32.h gcc/config/i386/mingw32.h index 1ac5544..6f5c3a4 100644 --- gcc/config/i386/mingw32.h +++ gcc/config/i386/mingw32.h @@ -198,7 +198,7 @@ do { \ /* mingw32 uses the -mthreads option to enable thread support. */ #undef GOMP_SELF_SPECS -#define GOMP_SELF_SPECS "%{fopenmp|ftree-parallelize-loops=*: " \ +#define GOMP_SELF_SPECS "%{fopenacc|fopenmp|ftree-parallelize-loops=*: " \ "-mthreads -pthread}" #undef GTM_SELF_SPECS #define GTM_SELF_SPECS "%{fgnu-tm:-mthreads -pthread}" diff --git gcc/config/ia64/hpux.h gcc/config/ia64/hpux.h index ca592e4..e0158ba 100644 --- gcc/config/ia64/hpux.h +++ gcc/config/ia64/hpux.h @@ -92,7 +92,7 @@ do { \ #undef LIB_SPEC #define LIB_SPEC \ "%{!shared: \ - %{mt|pthread:%{fopenmp:-lrt} -lpthread} \ + %{mt|pthread:%{fopenacc|fopenmp:-lrt} -lpthread} \ %{p:%{!mlp64:-L/usr/lib/hpux32/libp} \ %{mlp64:-L/usr/lib/hpux64/libp} -lprof} \ %{pg:%{!mlp64:-L/usr/lib/hpux32/libp} \ diff --git gcc/config/pa/pa-hpux11.h gcc/config/pa/pa-hpux11.h index c217398..0676d74 100644 --- gcc/config/pa/pa-hpux11.h +++ gcc/config/pa/pa-hpux11.h @@ -120,7 +120,7 @@ along with GCC; see the file COPYING3. If not see #undef LIB_SPEC #define LIB_SPEC \ "%{!shared:\ - %{fopenmp:%{static:-a archive_shared} -lrt %{static:-a archive}}\ + %{fopenacc|fopenmp:%{static:-a archive_shared} -lrt %{static:-a archive}}\ %{mt|pthread:-lpthread} -lc\ %{static:%{!nolibdld:-a archive_shared -ldld -a archive -lc}\ %{!mt:%{!pthread:-a shared -lc -a archive}}}}\ diff --git gcc/config/pa/pa64-hpux.h gcc/config/pa/pa64-hpux.h index a3e21d3..fdccf51 100644 --- gcc/config/pa/pa64-hpux.h +++ gcc/config/pa/pa64-hpux.h @@ -58,19 +58,19 @@ along with GCC; see the file COPYING3. If not see #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_GNU_LD) #define LIB_SPEC \ "%{!shared:\ - %{!p:%{!pg:%{fopenmp:%{static:-a shared} -lrt %{static:-a archive}}\ + %{!p:%{!pg:%{fopenacc|fopenmp:%{static:-a shared} -lrt %{static:-a archive}}\ %{mt|pthread:-lpthread} -lc\ %{static:%{!nolibdld:-a shared -ldld -a archive -lc}\ %{!mt:%{!pthread:-a shared -lc -a archive}}}}}\ %{p:%{!pg:%{static:%{!mhp-ld:-a shared}%{mhp-ld:-a archive_shared}}\ -lprof %{static:-a archive}\ - %{fopenmp:%{static:-a shared} -lrt %{static:-a archive}}\ + %{fopenacc|fopenmp:%{static:-a shared} -lrt %{static:-a archive}}\ %{mt|pthread:-lpthread} -lc\ %{static:%{!nolibdld:-a shared -ldld -a archive -lc}\ %{!mt:%{!pthread:-a shared -lc -a archive}}}}}\ %{pg:%{static:%{!mhp-ld:-a shared}%{mhp-ld:-a archive_shared}}\ -lgprof %{static:-a archive}\ - %{fopenmp:%{static:-a shared} -lrt %{static:-a archive}}\ + %{fopenacc|fopenmp:%{static:-a shared} -lrt %{static:-a archive}}\ %{mt|pthread:-lpthread} -lc\ %{static:%{!nolibdld:-a shared -ldld -a archive -lc}\ %{!mt:%{!pthread:-a shared -lc -a archive}}}}}\ @@ -78,19 +78,19 @@ along with GCC; see the file COPYING3. If not see #else #define LIB_SPEC \ "%{!shared:\ - %{!p:%{!pg:%{fopenmp:%{static:-a shared} -lrt %{static:-a archive}}\ + %{!p:%{!pg:%{fopenacc|fopenmp:%{static:-a shared} -lrt %{static:-a archive}}\ %{mt|pthread:-lpthread} -lc\ %{static:%{!nolibdld:-a shared -ldld -a archive -lc}\ %{!mt:%{!pthread:-a shared -lc -a archive}}}}}\ %{p:%{!pg:%{static:%{mgnu-ld:-a shared}%{!mgnu-ld:-a archive_shared}}\ -lprof %{static:-a archive}\ - %{fopenmp:%{static:-a shared} -lrt %{static:-a archive}}\ + %{fopenacc|fopenmp:%{static:-a shared} -lrt %{static:-a archive}}\ %{mt|pthread:-lpthread} -lc\ %{static:%{!nolibdld:-a shared -ldld -a archive -lc}\ %{!mt:%{!pthread:-a shared -lc -a archive}}}}}\ %{pg:%{static:%{mgnu-ld:-a shared}%{!mgnu-ld:-a archive_shared}}\ -lgprof %{static:-a archive}\ - %{fopenmp:%{static:-a shared} -lrt %{static:-a archive}}\ + %{fopenacc|fopenmp:%{static:-a shared} -lrt %{static:-a archive}}\ %{mt|pthread:-lpthread} -lc\ %{static:%{!nolibdld:-a shared -ldld -a archive -lc}\ %{!mt:%{!pthread:-a shared -lc -a archive}}}}}\ diff --git gcc/doc/invoke.texi gcc/doc/invoke.texi index e393139..af8973a 100644 --- gcc/doc/invoke.texi +++ gcc/doc/invoke.texi @@ -1838,7 +1838,9 @@ freestanding and hosted environments. Enable handling of OpenACC. When @option{-fopenacc} is specified, the compiler generates accelerated code according to the OpenACC Application -Programming Interface v2.0 @w{@uref{http://www.openacc.org/}}. +Programming Interface v2.0 @w{@uref{http://www.openacc.org/}}. This option +implies @option{-pthread}, and thus is only supported on targets that +have support for @option{-pthread}. @item -fopenmp @opindex fopenmp diff --git gcc/gcc.c gcc/gcc.c index 2298249..fdc0db5 100644 --- gcc/gcc.c +++ gcc/gcc.c @@ -765,7 +765,7 @@ proper position among the other output files. */ %X %{o*} %{e*} %{N} %{n} %{r}\ %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} " VTABLE_VERIFICATION_SPEC " \ %{static:} %{L*} %(mfwrap) %(link_libgcc) " SANITIZER_EARLY_SPEC " %o\ - %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}\ + %{fopenacc|fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}\ %{fgnu-tm:%:include(libitm.spec)%(link_itm)}\ %(mflib) " STACK_SPLIT_SPEC "\ %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " SANITIZER_SPEC " \ @@ -921,10 +921,11 @@ static const char *const multilib_defaults_raw[] = MULTILIB_DEFAULTS; #define DRIVER_SELF_SPECS "" #endif -/* Adding -fopenmp should imply pthreads. This is particularly important +/* Linking to libgomp implies pthreads. This is particularly important for targets that use different start files and suchlike. */ #ifndef GOMP_SELF_SPECS -#define GOMP_SELF_SPECS "%{fopenmp|ftree-parallelize-loops=*: -pthread}" +#define GOMP_SELF_SPECS "%{fopenacc|fopenmp|ftree-parallelize-loops=*: " \ + "-pthread}" #endif /* Likewise for -fgnu-tm. */ diff --git libgomp/Makefile.am libgomp/Makefile.am index 427415e..0b5c097 100644 --- libgomp/Makefile.am +++ libgomp/Makefile.am @@ -63,9 +63,10 @@ libgomp_la_SOURCES = alloc.c barrier.c critical.c env.c error.c iter.c \ time.c fortran.c affinity.c target.c nodist_noinst_HEADERS = libgomp_f.h -nodist_libsubinclude_HEADERS = omp.h +nodist_libsubinclude_HEADERS = omp.h openacc.h if USE_FORTRAN -nodist_finclude_HEADERS = omp_lib.h omp_lib.f90 omp_lib.mod omp_lib_kinds.mod +nodist_finclude_HEADERS = omp_lib.h omp_lib.f90 omp_lib.mod omp_lib_kinds.mod \ + openacc_lib.h openacc.f90 openacc.mod openacc_kinds.mod endif LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) @@ -75,7 +76,9 @@ LINK = $(LIBTOOL) --tag CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \ omp_lib_kinds.mod: omp_lib.mod : -omp_lib.mod: omp_lib.f90 +openacc_kinds.mod: openacc.mod + : +%.mod: %.f90 $(FC) $(FCFLAGS) -fsyntax-only $< fortran.lo: libgomp_f.h fortran.o: libgomp_f.h diff --git libgomp/Makefile.in libgomp/Makefile.in index 5cd666f..9ee1bec 100644 --- libgomp/Makefile.in +++ libgomp/Makefile.in @@ -320,8 +320,10 @@ libgomp_la_SOURCES = alloc.c barrier.c critical.c env.c error.c iter.c \ time.c fortran.c affinity.c target.c nodist_noinst_HEADERS = libgomp_f.h -nodist_libsubinclude_HEADERS = omp.h -@USE_FORTRAN_TRUE@nodist_finclude_HEADERS = omp_lib.h omp_lib.f90 omp_lib.mod omp_lib_kinds.mod +nodist_libsubinclude_HEADERS = omp.h openacc.h +@USE_FORTRAN_TRUE@nodist_finclude_HEADERS = omp_lib.h omp_lib.f90 omp_lib.mod omp_lib_kinds.mod \ +@USE_FORTRAN_TRUE@ openacc_lib.h openacc.f90 openacc.mod openacc_kinds.mod + LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) LINK = $(LIBTOOL) --tag CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \ $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LTLDFLAGS) -o $@ @@ -1085,7 +1087,9 @@ vpath % $(strip $(search_path)) omp_lib_kinds.mod: omp_lib.mod : -omp_lib.mod: omp_lib.f90 +openacc_kinds.mod: openacc.mod + : +%.mod: %.f90 $(FC) $(FCFLAGS) -fsyntax-only $< fortran.lo: libgomp_f.h fortran.o: libgomp_f.h diff --git libgomp/configure libgomp/configure index e754eff..704f22a 100755 --- libgomp/configure +++ libgomp/configure @@ -16217,7 +16217,7 @@ else fi # Set up the set of libraries that we need to link against for libgomp. -# Note that the GOMP_SELF_SPEC in gcc.c will force -pthread for -fopenmp, +# Note that the GOMP_SELF_SPEC in gcc.c may force -pthread, # which will force linkage against -lpthread (or equivalent for the system). # That's not 100% ideal, but about the best we can do easily. if test $enable_shared = yes; then diff --git libgomp/configure.ac libgomp/configure.ac index 67f28ed..da06426 100644 --- libgomp/configure.ac +++ libgomp/configure.ac @@ -283,7 +283,7 @@ else fi # Set up the set of libraries that we need to link against for libgomp. -# Note that the GOMP_SELF_SPEC in gcc.c will force -pthread for -fopenmp, +# Note that the GOMP_SELF_SPEC in gcc.c may force -pthread, # which will force linkage against -lpthread (or equivalent for the system). # That's not 100% ideal, but about the best we can do easily. if test $enable_shared = yes; then diff --git libgomp/libgomp.map libgomp/libgomp.map index b102fd8..4f87d00 100644 --- libgomp/libgomp.map +++ libgomp/libgomp.map @@ -227,3 +227,6 @@ GOMP_4.0 { GOMP_target_update; GOMP_teams; } GOMP_3.0; + +OACC_2.0 { +}; diff --git libgomp/libgomp.spec.in libgomp/libgomp.spec.in index b7319f3..5651603 100644 --- libgomp/libgomp.spec.in +++ libgomp/libgomp.spec.in @@ -1,3 +1,3 @@ # This spec file is read by gcc when linking. It is used to specify the -# standard libraries we need in order to link with -fopenmp. +# standard libraries we need in order to link with libgomp. *link_gomp: @link_gomp@ diff --git libgomp/openacc.f90 libgomp/openacc.f90 new file mode 100644 index 0000000..55b79c2 --- /dev/null +++ libgomp/openacc.f90 @@ -0,0 +1,37 @@ +! OpenACC Runtime Library Definitions. + +! Copyright (C) 2013 Free Software Foundation, Inc. + +! Contributed by Thomas Schwinge <tho...@codesourcery.com>. + +! This file is part of the GNU OpenMP 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/>. + +module openacc_kinds + implicit none + +end module openacc_kinds + +module openacc + use openacc_kinds + implicit none + +end module openacc diff --git libgomp/openacc.h libgomp/openacc.h new file mode 100644 index 0000000..a6f7ec94 --- /dev/null +++ libgomp/openacc.h @@ -0,0 +1,45 @@ +/* OpenACC Runtime Library Declarations + + Copyright (C) 2013 Free Software Foundation, Inc. + + Contributed by Thomas Schwinge <tho...@codesourcery.com>. + + This file is part of the GNU OpenMP 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/>. */ + +#ifndef _OPENACC_H +#define _OPENACC_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +# define __GOACC_NOTHROW throw () +#else +# define __GOACC_NOTHROW __attribute__ ((__nothrow__)) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _OPENACC_H */ diff --git libgomp/openacc_lib.h libgomp/openacc_lib.h new file mode 100644 index 0000000..b2cb679 --- /dev/null +++ libgomp/openacc_lib.h @@ -0,0 +1,26 @@ +! OpenACC Runtime Library Definitions. -*- mode: fortran -*- + +! Copyright (C) 2013 Free Software Foundation, Inc. + +! Contributed by Thomas Schwinge <tho...@codesourcery.com>. + +! This file is part of the GNU OpenMP 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/>. diff --git libgomp/testsuite/libgomp.oacc-c++/c++.exp libgomp/testsuite/libgomp.oacc-c++/c++.exp new file mode 100644 index 0000000..4c0a3e3 --- /dev/null +++ libgomp/testsuite/libgomp.oacc-c++/c++.exp @@ -0,0 +1,66 @@ +# This whole file adapted from libgomp.c++/c++.exp. + +load_lib libgomp-dg.exp +load_gcc_lib gcc-dg.exp + +global shlib_ext + +set shlib_ext [get_shlib_extension] +set lang_link_flags "-lstdc++" +set lang_test_file_found 0 +set lang_library_path "../libstdc++-v3/src/.libs" + +# Initialize dg. +dg-init + +# Turn on OpenACC. +lappend ALWAYS_CFLAGS "additional_flags=-fopenacc" + +set blddir [lookfor_file [get_multilibs] libgomp] + + +if { $blddir != "" } { + # Look for a static libstdc++ first. + if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] { + set lang_test_file "${lang_library_path}/libstdc++.a" + set lang_test_file_found 1 + # We may have a shared only build, so look for a shared libstdc++. + } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] { + set lang_test_file "${lang_library_path}/libstdc++.${shlib_ext}" + set lang_test_file_found 1 + } else { + puts "No libstdc++ library found, will not execute c++ tests" + } +} elseif { [info exists GXX_UNDER_TEST] } { + set lang_test_file_found 1 + # Needs to exist for libgomp.exp. + set lang_test_file "" +} else { + puts "GXX_UNDER_TEST not defined, will not execute c++ tests" +} + +if { $lang_test_file_found } { + # Gather a list of all tests. + set tests [lsort [glob -nocomplain $srcdir/$subdir/*.C]] + + if { $blddir != "" } { + set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}" + } else { + set ld_library_path "$always_ld_library_path" + } + append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST] + set_ld_library_path_env_vars + + set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags" + if { [file exists $flags_file] } { + set libstdcxx_includes [exec sh $flags_file --build-includes] + } else { + set libstdcxx_includes "" + } + + # Main loop. + dg-runtest $tests "" $libstdcxx_includes +} + +# All done. +dg-finish diff --git libgomp/testsuite/libgomp.oacc-c/c.exp libgomp/testsuite/libgomp.oacc-c/c.exp new file mode 100644 index 0000000..8307ecd --- /dev/null +++ libgomp/testsuite/libgomp.oacc-c/c.exp @@ -0,0 +1,36 @@ +# This whole file adapted from libgomp.c/c.exp. + +if [info exists lang_library_path] then { + unset lang_library_path + unset lang_link_flags +} +if [info exists lang_test_file] then { + unset lang_test_file +} + +load_lib libgomp-dg.exp +load_gcc_lib gcc-dg.exp + +# If a testcase doesn't have special options, use these. +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS "-O2" +} + +# Initialize dg. +dg-init + +# Turn on OpenACC. +lappend ALWAYS_CFLAGS "additional_flags=-fopenacc" + +# Gather a list of all tests. +set tests [lsort [find $srcdir/$subdir *.c]] + +set ld_library_path $always_ld_library_path +append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST] +set_ld_library_path_env_vars + +# Main loop. +dg-runtest $tests "" $DEFAULT_CFLAGS + +# All done. +dg-finish diff --git libgomp/testsuite/libgomp.oacc-c/lib-1.c libgomp/testsuite/libgomp.oacc-c/lib-1.c new file mode 100644 index 0000000..8ad1b19 --- /dev/null +++ libgomp/testsuite/libgomp.oacc-c/lib-1.c @@ -0,0 +1,7 @@ +#include <openacc.h> + +int +main (void) +{ + return 0; +} diff --git libgomp/testsuite/libgomp.oacc-fortran/fortran.exp libgomp/testsuite/libgomp.oacc-fortran/fortran.exp new file mode 100644 index 0000000..4070df5 --- /dev/null +++ libgomp/testsuite/libgomp.oacc-fortran/fortran.exp @@ -0,0 +1,69 @@ +# This whole file adapted from libgomp.fortran/fortran.exp. + +load_lib libgomp-dg.exp +load_gcc_lib gcc-dg.exp +load_gcc_lib gfortran-dg.exp + +global shlib_ext +global ALWAYS_CFLAGS + +set shlib_ext [get_shlib_extension] +set lang_library_path "../libgfortran/.libs" +set lang_link_flags "-lgfortran" +set lang_test_file_found 0 +set quadmath_library_path "../libquadmath/.libs" + + +# Initialize dg. +dg-init + +# Turn on OpenACC. +lappend ALWAYS_CFLAGS "additional_flags=-fopenacc" + +if { $blddir != "" } { + lappend ALWAYS_CFLAGS "additional_flags=-fintrinsic-modules-path=${blddir}" + # Look for a static libgfortran first. + if [file exists "${blddir}/${lang_library_path}/libgfortran.a"] { + set lang_test_file "${lang_library_path}/libgfortran.a" + set lang_test_file_found 1 + # We may have a shared only build, so look for a shared libgfortran. + } elseif [file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] { + set lang_test_file "${lang_library_path}/libgfortran.${shlib_ext}" + set lang_test_file_found 1 + } else { + puts "No libgfortran library found, will not execute fortran tests" + } +} elseif [info exists GFORTRAN_UNDER_TEST] { + set lang_test_file_found 1 + # Needs to exist for libgomp.exp. + set lang_test_file "" +} else { + puts "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests" +} + +if { $lang_test_file_found } { + # Gather a list of all tests. + set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]] + + if { $blddir != "" } { + if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"] + || [file exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } { + lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${quadmath_library_path}/" + # Allow for spec subsitution. + lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/${quadmath_library_path}/" + set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}:${blddir}/${quadmath_library_path}" + } else { + set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}" + } + } else { + set ld_library_path "$always_ld_library_path" + } + append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST] + set_ld_library_path_env_vars + + # Main loop. + gfortran-dg-runtest $tests "" +} + +# All done. +dg-finish diff --git libgomp/testsuite/libgomp.oacc-fortran/lib-1.f90 libgomp/testsuite/libgomp.oacc-fortran/lib-1.f90 new file mode 100644 index 0000000..124aa87 --- /dev/null +++ libgomp/testsuite/libgomp.oacc-fortran/lib-1.f90 @@ -0,0 +1,3 @@ +use openacc + +end diff --git libgomp/testsuite/libgomp.oacc-fortran/lib-2.f libgomp/testsuite/libgomp.oacc-fortran/lib-2.f new file mode 100644 index 0000000..64beb9e --- /dev/null +++ libgomp/testsuite/libgomp.oacc-fortran/lib-2.f @@ -0,0 +1,3 @@ + USE OPENACC + + END diff --git libgomp/testsuite/libgomp.oacc-fortran/lib-3.f libgomp/testsuite/libgomp.oacc-fortran/lib-3.f new file mode 100644 index 0000000..3f9940b --- /dev/null +++ libgomp/testsuite/libgomp.oacc-fortran/lib-3.f @@ -0,0 +1,3 @@ + INCLUDE "openacc_lib.h" + + END -- 1.8.1.1