diff mbox

[gomp4] libgomp: Also consider --with-cuda-driver flags for build-tree testing (was: [2/3] OpenACC 2.0 support for libgomp - new tests)

Message ID 877fzifzoc.fsf@kepler.schwinge.homeip.net
State New
Headers show

Commit Message

Thomas Schwinge Oct. 29, 2014, 7:23 p.m. UTC
Hi!

On Tue, 28 Oct 2014 17:00:38 +0100, I wrote:
> Committed in r216804:
> 
> commit 4f9566b3e2954218c0d9ce3c585e14e539f0c1af
> Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
> Date:   Tue Oct 28 15:57:48 2014 +0000
> 
>     libgomp: Don't refer to CUDA installation in /opt/nvidia/cuda-5.5/.
>     
>     	libgomp/
>     	* testsuite/libgomp.oacc-c/c.exp (ld_library_path, ALWAYS_CFLAGS):
>     	Don't refer to CUDA installation in /opt/nvidia/cuda-5.5/.
>     
>     git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@216804 138bc75d-0d04-0410-961f-82ee72b054a4

> --- libgomp/testsuite/libgomp.oacc-c/c.exp
> +++ libgomp/testsuite/libgomp.oacc-c/c.exp
> @@ -31,7 +31,6 @@ 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]
> -append ld_library_path ":/opt/nvidia/cuda-5.5/lib64"
>  set_ld_library_path_env_vars
>  
>  # Todo: get list of accelerators from configure options --enable-accelerator.
> @@ -58,11 +57,6 @@ foreach accel $accels {
>  	    # Copy ptx file (TEMPORARY)
>  	    remote_download host $srcdir/libgomp.oacc-c/subr.ptx
>  
> -	    # Where cuda.h lives
> -	    # Todo: get that from configure option --with-cuda-driver.
> -	    lappend ALWAYS_CFLAGS "additional_flags=-I/opt/nvidia/cuda-5.5/include"
> -	    lappend ALWAYS_CFLAGS "additional_flags=-L/opt/nvidia/cuda-5.5/lib64"
> -

Jim "complained" that this broke his testing setup.  ;-P

Here is a patch, not tested very much.  Jakub, is that conceptually OK,
and Jim, does it resolve the problem?  I reckon, additionally to
--with-cuda-driver, we might also need --with-cuda-runtime, just for the
purpose of the (few) test cases that test interoperability with the CUDA
Runtime library?

commit 6692df50139e3986d9eb18841b9032e47179db13
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Wed Oct 29 20:14:52 2014 +0100

    libgomp: Also consider --with-cuda-driver flags for build-tree testing.
    
    For installed testing, we assume all that to be provided in the sysroot.



Grüße,
 Thomas
diff mbox

Patch

diff --git libgomp/Makefile.in libgomp/Makefile.in
index 373c417..d12376e 100644
--- libgomp/Makefile.in
+++ libgomp/Makefile.in
@@ -191,6 +191,8 @@  CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CUDA_DRIVER_INCLUDE = @CUDA_DRIVER_INCLUDE@
+CUDA_DRIVER_LIB = @CUDA_DRIVER_LIB@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
diff --git libgomp/configure libgomp/configure
index e23c1e2..7daccd9 100755
--- libgomp/configure
+++ libgomp/configure
@@ -719,6 +719,8 @@  build_os
 build_vendor
 build_cpu
 build
+CUDA_DRIVER_LIB
+CUDA_DRIVER_INCLUDE
 GENINSRC_FALSE
 GENINSRC_TRUE
 target_alias
@@ -2616,6 +2618,10 @@  fi
 
 
 # Look for the CUDA driver package.
+CUDA_DRIVER_INCLUDE=
+CUDA_DRIVER_LIB=
+
+
 CUDA_DRIVER_CPPFLAGS=
 CUDA_DRIVER_LDFLAGS=
 
@@ -2637,14 +2643,20 @@  if test "${with_cuda_driver_lib+set}" = set; then :
 fi
 
 if test "x$with_cuda_driver" != x; then
-  CUDA_DRIVER_CPPFLAGS=-I$with_cuda_driver/include
-  CUDA_DRIVER_LDFLAGS=-L$with_cuda_driver/lib
+  CUDA_DRIVER_INCLUDE=$with_cuda_driver/include
+  CUDA_DRIVER_LIB=$with_cuda_driver/lib
 fi
 if test "x$with_cuda_driver_include" != x; then
-  CUDA_DRIVER_CPPFLAGS=-I$with_cuda_driver_include
+  CUDA_DRIVER_INCLUDE=$with_cuda_driver_include
 fi
 if test "x$with_cuda_driver_lib" != x; then
-  CUDA_DRIVER_LDFLAGS=-L$with_cuda_driver_lib
+  CUDA_DRIVER_LIB=$with_cuda_driver_lib
+fi
+if test "x$CUDA_DRIVER_INCLUDE" != x; then
+  CUDA_DRIVER_CPPFLAGS=-I$CUDA_DRIVER_INCLUDE
+fi
+if test "x$CUDA_DRIVER_LIB" != x; then
+  CUDA_DRIVER_LDFLAGS=-L$CUDA_DRIVER_LIB
 fi
 
 
@@ -11145,7 +11157,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11148 "configure"
+#line 11160 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11251,7 +11263,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11254 "configure"
+#line 11266 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -16453,7 +16465,11 @@  CFLAGS="$save_CFLAGS"
 
 ac_config_files="$ac_config_files omp.h omp_lib.h omp_lib.f90 libgomp_f.h"
 
-ac_config_files="$ac_config_files Makefile testsuite/Makefile libgomp.spec"
+ac_config_files="$ac_config_files Makefile testsuite/Makefile"
+
+ac_config_files="$ac_config_files testsuite/libgomp-test-support.exp"
+
+ac_config_files="$ac_config_files libgomp.spec"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -17598,6 +17614,7 @@  do
     "libgomp_f.h") CONFIG_FILES="$CONFIG_FILES libgomp_f.h" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "testsuite/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/Makefile" ;;
+    "testsuite/libgomp-test-support.exp") CONFIG_FILES="$CONFIG_FILES testsuite/libgomp-test-support.exp" ;;
     "libgomp.spec") CONFIG_FILES="$CONFIG_FILES libgomp.spec" ;;
 
   *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
diff --git libgomp/configure.ac libgomp/configure.ac
index 2633dac..89c6b31 100644
--- libgomp/configure.ac
+++ libgomp/configure.ac
@@ -31,6 +31,10 @@  AC_MSG_RESULT($enable_generated_files_in_srcdir)
 AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
 
 # 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,
@@ -45,14 +49,20 @@  AC_ARG_WITH(cuda-driver-lib,
 	[AS_HELP_STRING([--with-cuda-driver-lib=PATH],
 		[specify directory for the installed CUDA driver library])])
 if test "x$with_cuda_driver" != x; then
-  CUDA_DRIVER_CPPFLAGS=-I$with_cuda_driver/include
-  CUDA_DRIVER_LDFLAGS=-L$with_cuda_driver/lib
+  CUDA_DRIVER_INCLUDE=$with_cuda_driver/include
+  CUDA_DRIVER_LIB=$with_cuda_driver/lib
 fi
 if test "x$with_cuda_driver_include" != x; then
-  CUDA_DRIVER_CPPFLAGS=-I$with_cuda_driver_include
+  CUDA_DRIVER_INCLUDE=$with_cuda_driver_include
 fi
 if test "x$with_cuda_driver_lib" != x; then
-  CUDA_DRIVER_LDFLAGS=-L$with_cuda_driver_lib
+  CUDA_DRIVER_LIB=$with_cuda_driver_lib
+fi
+if test "x$CUDA_DRIVER_INCLUDE" != x; then
+  CUDA_DRIVER_CPPFLAGS=-I$CUDA_DRIVER_INCLUDE
+fi
+if test "x$CUDA_DRIVER_LIB" != x; then
+  CUDA_DRIVER_LDFLAGS=-L$CUDA_DRIVER_LIB
 fi
 
 
@@ -431,5 +441,7 @@  AC_SUBST(OMP_NEST_LOCK_25_KIND)
 CFLAGS="$save_CFLAGS"
 
 AC_CONFIG_FILES(omp.h omp_lib.h omp_lib.f90 libgomp_f.h)
-AC_CONFIG_FILES(Makefile testsuite/Makefile libgomp.spec)
+AC_CONFIG_FILES(Makefile testsuite/Makefile)
+AC_CONFIG_FILES(testsuite/libgomp-test-support.exp)
+AC_CONFIG_FILES(libgomp.spec)
 AC_OUTPUT
diff --git libgomp/testsuite/Makefile.in libgomp/testsuite/Makefile.in
index 77b365e..17ee96b 100644
--- libgomp/testsuite/Makefile.in
+++ libgomp/testsuite/Makefile.in
@@ -35,7 +35,8 @@  build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = testsuite
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(srcdir)/libgomp-test-support.exp.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
@@ -54,7 +55,7 @@  am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
-CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_FILES = libgomp-test-support.exp
 CONFIG_CLEAN_VPATH_FILES =
 SOURCES =
 DEJATOOL = $(PACKAGE)
@@ -71,6 +72,8 @@  CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CUDA_DRIVER_INCLUDE = @CUDA_DRIVER_INCLUDE@
+CUDA_DRIVER_LIB = @CUDA_DRIVER_LIB@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
@@ -251,6 +254,8 @@  $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
+libgomp-test-support.exp: $(top_builddir)/config.status $(srcdir)/libgomp-test-support.exp.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 
 mostlyclean-libtool:
 	-rm -f *.lo
diff --git libgomp/testsuite/lib/libgomp.exp libgomp/testsuite/lib/libgomp.exp
index 78a14cb..eab97b6 100644
--- libgomp/testsuite/lib/libgomp.exp
+++ libgomp/testsuite/lib/libgomp.exp
@@ -31,6 +31,9 @@  load_gcc_lib timeout-dg.exp
 load_gcc_lib torture-options.exp
 load_gcc_lib fortran-modules.exp
 
+# Try to load a test support file, built during libgomp configuration.
+load_file libgomp-test-support.exp
+
 set dg-do-what-default run
 
 #
@@ -144,6 +147,24 @@  proc libgomp_init { args } {
     }
     lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."
 
+    # For build-tree testing, also consider the CUDA paths used for builing.
+    # For installed testing, we assume all that to be provided in the sysroot.
+    if { $blddir != "" } {
+	global cuda_driver_include
+	global cuda_driver_lib
+	if { $cuda_driver_include != "" } {
+	    # Stop gfortran from freaking out:
+	    # Warning: Nonexistent include directory "[...]"
+	    if {[file exists $cuda_driver_include]} {
+		lappend ALWAYS_CFLAGS "additional_flags=-I$cuda_driver_include"
+	    }
+	}
+	if { $cuda_driver_lib != "" } {
+	    lappend ALWAYS_CFLAGS "additional_flags=-L$cuda_driver_lib"
+	    append always_ld_library_path ":$cuda_driver_lib"
+	}
+    }
+
     # We use atomic operations in the testcases to validate results.
     if { ([istarget i?86-*-*] || [istarget x86_64-*-*])
 	 && [check_effective_target_ia32] } {
diff --git libgomp/testsuite/libgomp-test-support.exp.in libgomp/testsuite/libgomp-test-support.exp.in
new file mode 100644
index 0000000..e7afd85
--- /dev/null
+++ libgomp/testsuite/libgomp-test-support.exp.in
@@ -0,0 +1,2 @@ 
+set cuda_driver_include @CUDA_DRIVER_INCLUDE@
+set cuda_driver_lib @CUDA_DRIVER_LIB@