@@ -1,3 +1,41 @@
+2015-05-13 Thomas Schwinge <thomas@codesourcery.com>
+
+ * env.c (initialize_env): Remove static attribute.
+ * libgomp.map (INTERNAL): Export initialize_env.
+ * testsuite/lib/libgomp.exp (libgomp_init): Build a few object
+ files to pre-set environment variables.
+ (ALWAYS_CFLAGS): Add constructor-setenv-defaults.o to ldflags.
+ (libgomp_target_compile): Don't set the compiler.
+ * testsuite/libgomp.c++/c++.exp (GXX_UNDER_TEST): Provide default.
+ (libgomp_compile_options): Set the compiler.
+ * testsuite/libgomp.c/c.exp (libgomp_compile_options): Set the
+ compiler.
+ * testsuite/libgomp.fortran/fortran.exp (GFORTRAN_UNDER_TEST):
+ Provide default.
+ (libgomp_compile_options): Set the compiler.
+ * testsuite/libgomp.graphite/graphite.exp
+ (libgomp_compile_options): Set the compiler.
+ * testsuite/libgomp.oacc-c++/c++.exp (SAVE_GCC_UNDER_TEST)
+ (GCC_UNDER_TEST): Don't set.
+ (GXX_UNDER_TEST): Provide default.
+ (libgomp_compile_options): Set the compiler.
+ (ALWAYS_CFLAGS): Add the respective
+ constructor-setenv-ACC_DEVICE_TYPE-$offload_target_openacc.o to
+ ldflags.
+ (ACC_DEVICE_TYPE): Don't set.
+ * testsuite/libgomp.oacc-c/c.exp (libgomp_compile_options): Set
+ the compiler.
+ (ALWAYS_CFLAGS): Add the respective
+ constructor-setenv-ACC_DEVICE_TYPE-$offload_target_openacc.o to
+ ldflags.
+ (ACC_DEVICE_TYPE): Don't set.
+ * testsuite/libgomp.oacc-fortran/fortran.exp
+ (libgomp_compile_options): Set the compiler.
+ (ALWAYS_CFLAGS): Add the respective
+ constructor-setenv-ACC_DEVICE_TYPE-$offload_target_openacc.o to
+ ldflags.
+ (ACC_DEVICE_TYPE): Don't set.
+
2015-05-13 Cesar Philippidis <cesar@codesourcery.com>
* testsuite/libgomp.oacc-c-c++-common/routine-1.c: Remove
@@ -1175,7 +1175,11 @@ handle_omp_display_env (unsigned long stacksize, int wait_policy)
}
-static void __attribute__((constructor))
+/* TODO. See testsuite/lib/libgomp.exp:libgomp_init. */
+#if 0
+static
+#endif
+void __attribute__((constructor))
initialize_env (void)
{
unsigned long thread_limit_var, stacksize;
@@ -344,3 +344,9 @@ GOMP_PLUGIN_1.0 {
GOMP_PLUGIN_async_unmap_vars;
GOMP_PLUGIN_acc_thread;
};
+
+# TODO. See testsuite/lib/libgomp.exp:libgomp_init.
+INTERNAL {
+ global:
+ initialize_env;
+};
@@ -235,6 +235,57 @@ proc libgomp_init { args } {
if { $offload_additional_options != "" } {
lappend ALWAYS_CFLAGS "additional_flags=${offload_additional_options}"
}
+
+ # TODO. Evil hack. DejaGnu doesn't have a mechanism for setting
+ # environment variables on remote boards. Thus, we have to fake it, using
+ # GCC's constructor attributes to create object files that install the
+ # desired environment variables.
+ set e_list [list \
+ [list defaults DUMMY=dummy ] \
+ [list ACC_DEVICE_TYPE-host ACC_DEVICE_TYPE=host ] \
+ [list ACC_DEVICE_TYPE-host_nonshm ACC_DEVICE_TYPE=host_nonshm ] \
+ [list ACC_DEVICE_TYPE-nvidia ACC_DEVICE_TYPE=nvidia ] ]
+ foreach e $e_list {
+ set v [lindex $e 0]
+ set s [lindex $e 1]
+ verbose "creating constructor-setenv: $v: $s"
+ set src constructor-setenv-$v.c
+ set obj constructor-setenv-$v.o
+ set f_src [open $src "w"]
+ puts $f_src "static void __attribute__((constructor(1000)))"
+ puts $f_src "init_env(void) {"
+ puts $f_src " int putenv(char *);"
+ puts $f_src " putenv(\"$s\");"
+ puts $f_src "}"
+ if { $v == "defaults" } {
+ # TODO. We want libgomp to initialize after the putenv calls.
+ # But: shared libraries' constructors (and thus
+ # env.c:initialize_env) will be called before the executable's
+ # (init_env functions created above), so it will already have been
+ # initialized (and has to be, in case we're not linking in this
+ # gunk). Assuming no execution of other libgomp functionality in
+ # between (which we're not doing during initialization),
+ # initialize_env's effects are idempotent when calling it again, so
+ # we'll do that now, after the putenv calls have been executed.
+ puts $f_src "static void __attribute__((constructor(1001)))"
+ puts $f_src "init_libgomp(void) {"
+ # Some test cases specify -fno-openmp, so libgomp isn't linked in.
+ puts $f_src " void initialize_env(void) __attribute__((weak));"
+ puts $f_src " if (initialize_env)"
+ puts $f_src " initialize_env();"
+ puts $f_src "}"
+ }
+ close $f_src
+ # TODO. Using whichever compiler is currently configured... At least
+ # switch it into C mode.
+ set lines [libgomp_target_compile $src $obj object "additional_flags=-xc"]
+ # TODO. Error checking.
+ file delete $src
+ }
+ # When adding constructor-setenv-*.o files, make sure to cancel any -x flag
+ # that may have been set before.
+ lappend ALWAYS_CFLAGS "ldflags=-x none"
+ lappend ALWAYS_CFLAGS "ldflags=constructor-setenv-defaults.o"
}
#
@@ -246,7 +297,6 @@ proc libgomp_target_compile { source dest type options } {
global libgomp_compile_options
global gluefile wrap_flags
global ALWAYS_CFLAGS
- global GCC_UNDER_TEST
global lang_test_file
global lang_library_path
global lang_link_flags
@@ -274,7 +324,6 @@ proc libgomp_target_compile { source dest type options } {
lappend options "additional_flags=[libio_include_flags]"
lappend options "timeout=[timeout_value]"
- lappend options "compiler=$GCC_UNDER_TEST"
set options [concat $libgomp_compile_options $options]
@@ -332,8 +381,7 @@ proc check_effective_target_openacc_nvidia_accel_present { } {
}
# Return 1 if at least one nvidia board is present, and the nvidia device type
-# is selected by default by means of setting the environment variable
-# ACC_DEVICE_TYPE.
+# is selected by default.
proc check_effective_target_openacc_nvidia_accel_selected { } {
if { ![check_effective_target_openacc_nvidia_accel_present] } {
@@ -4,6 +4,7 @@ load_gcc_lib gcc-dg.exp
global shlib_ext
set shlib_ext [get_shlib_extension]
+#TODO
set lang_link_flags "-lstdc++"
set lang_test_file_found 0
set lang_library_path "../libstdc++-v3/src/.libs"
@@ -41,6 +42,13 @@ if { $blddir != "" } {
}
if { $lang_test_file_found } {
+ if ![info exists GXX_UNDER_TEST] then {
+ # TODO. See libgomp.oacc-c++/c++.exp.
+ set HAVE_SET_GXX_UNDER_TEST ""
+ set GXX_UNDER_TEST "$GCC_UNDER_TEST"
+ }
+ lappend libgomp_compile_options "compiler=$GXX_UNDER_TEST"
+
# Gather a list of all tests.
set tests [lsort [find $srcdir/$subdir *.C]]
@@ -63,5 +71,10 @@ if { $lang_test_file_found } {
dg-runtest $tests "" $libstdcxx_includes
}
+# TODO. See above.
+if { [info exists HAVE_SET_GXX_UNDER_TEST] } {
+ unset GXX_UNDER_TEST
+}
+
# All done.
dg-finish
@@ -23,6 +23,8 @@ dg-init
# Turn on OpenMP.
lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
+lappend libgomp_compile_options "compiler=$GCC_UNDER_TEST"
+
# Gather a list of all tests.
set tests [lsort [find $srcdir/$subdir *.c]]
@@ -47,6 +47,11 @@ if { $blddir != "" } {
}
if { $lang_test_file_found } {
+ if ![info exists GFORTRAN_UNDER_TEST] then {
+ set GFORTRAN_UNDER_TEST $GCC_UNDER_TEST
+ }
+ lappend libgomp_compile_options "compiler=$GFORTRAN_UNDER_TEST"
+
# Gather a list of all tests.
set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
@@ -48,6 +48,8 @@ dg-init
# Turn on OpenMP.
lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
+lappend libgomp_compile_options "compiler=$GCC_UNDER_TEST"
+
# Gather a list of all tests.
set tests [lsort [find $srcdir/$subdir *.c]]
@@ -6,6 +6,7 @@ load_gcc_lib gcc-dg.exp
global shlib_ext
set shlib_ext [get_shlib_extension]
+#TODO
set lang_link_flags "-lstdc++"
set lang_test_file_found 0
set lang_library_path "../libstdc++-v3/src/.libs"
@@ -19,11 +20,6 @@ dg-init
# Turn on OpenACC.
lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
-# Switch into C++ mode. Otherwise, the libgomp.oacc-c-c++-common/*.c
-# files would be compiled as C files.
-set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
-set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
-
set blddir [lookfor_file [get_multilibs] libgomp]
@@ -48,6 +44,14 @@ if { $blddir != "" } {
}
if { $lang_test_file_found } {
+ if ![info exists GXX_UNDER_TEST] then {
+ # Use GCC_UNDER_TEST, but switch into C++ mode, as otherwise the
+ # libgomp.oacc-c-c++-common/*.c files would be compiled as C files.
+ set HAVE_SET_GXX_UNDER_TEST ""
+ set GXX_UNDER_TEST "$GCC_UNDER_TEST -x c++"
+ }
+ lappend libgomp_compile_options "compiler=$GXX_UNDER_TEST"
+
# Gather a list of all tests.
set tests [lsort [concat \
[find $srcdir/$subdir *.C] \
@@ -69,8 +73,13 @@ if { $lang_test_file_found } {
}
# Test OpenACC with available accelerators.
+ set SAVE_ALWAYS_CFLAGS "$ALWAYS_CFLAGS"
foreach offload_target_openacc $offload_targets_s_openacc {
+ set ALWAYS_CFLAGS "$SAVE_ALWAYS_CFLAGS"
set tagopt "-DACC_DEVICE_TYPE_$offload_target_openacc=1"
+ # Set $ACC_DEVICE_TYPE. See the comments in
+ # ../lib/libgomp.exp:libgomp_init.
+ lappend ALWAYS_CFLAGS "ldflags=constructor-setenv-ACC_DEVICE_TYPE-$offload_target_openacc.o"
# Todo: Determine shared memory or not using run-time test.
switch $offload_target_openacc {
@@ -95,15 +104,14 @@ if { $lang_test_file_found } {
}
set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
- # Todo: Verify that this works for both local and remote testing.
- setenv ACC_DEVICE_TYPE $offload_target_openacc
-
dg-runtest $tests "$tagopt" $libstdcxx_includes
}
}
# See above.
-set GCC_UNDER_TEST "$SAVE_GCC_UNDER_TEST"
+if { [info exists HAVE_SET_GXX_UNDER_TEST] } {
+ unset GXX_UNDER_TEST
+}
# All done.
dg-finish
@@ -25,6 +25,8 @@ dg-init
# Turn on OpenACC.
lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
+lappend libgomp_compile_options "compiler=$GCC_UNDER_TEST"
+
# Gather a list of all tests.
set tests [lsort [concat \
[find $srcdir/$subdir *.c] \
@@ -39,6 +41,9 @@ set SAVE_ALWAYS_CFLAGS "$ALWAYS_CFLAGS"
foreach offload_target_openacc $offload_targets_s_openacc {
set ALWAYS_CFLAGS "$SAVE_ALWAYS_CFLAGS"
set tagopt "-DACC_DEVICE_TYPE_$offload_target_openacc=1"
+ # Set $ACC_DEVICE_TYPE. See the comments in
+ # ../lib/libgomp.exp:libgomp_init.
+ lappend ALWAYS_CFLAGS "ldflags=constructor-setenv-ACC_DEVICE_TYPE-$offload_target_openacc.o"
# Todo: Determine shared memory or not using run-time test.
switch $offload_target_openacc {
@@ -63,9 +68,6 @@ foreach offload_target_openacc $offload_targets_s_openacc {
}
set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
- # Todo: Verify that this works for both local and remote testing.
- setenv ACC_DEVICE_TYPE $offload_target_openacc
-
dg-runtest $tests "$tagopt" $DEFAULT_CFLAGS
}
@@ -49,6 +49,11 @@ if { $blddir != "" } {
}
if { $lang_test_file_found } {
+ if ![info exists GFORTRAN_UNDER_TEST] then {
+ set GFORTRAN_UNDER_TEST $GCC_UNDER_TEST
+ }
+ lappend libgomp_compile_options "compiler=$GFORTRAN_UNDER_TEST"
+
# Gather a list of all tests.
set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
@@ -69,8 +74,13 @@ if { $lang_test_file_found } {
set_ld_library_path_env_vars
# Test OpenACC with available accelerators.
+ set SAVE_ALWAYS_CFLAGS "$ALWAYS_CFLAGS"
foreach offload_target_openacc $offload_targets_s_openacc {
+ set ALWAYS_CFLAGS "$SAVE_ALWAYS_CFLAGS"
set tagopt "-DACC_DEVICE_TYPE_$offload_target_openacc=1"
+ # Set $ACC_DEVICE_TYPE. See the comments in
+ # ../lib/libgomp.exp:libgomp_init.
+ lappend ALWAYS_CFLAGS "ldflags=constructor-setenv-ACC_DEVICE_TYPE-$offload_target_openacc.o"
# Todo: Determine shared memory or not using run-time test.
switch $offload_target_openacc {
@@ -89,9 +99,6 @@ if { $lang_test_file_found } {
}
set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
- # Todo: Verify that this works for both local and remote testing.
- setenv ACC_DEVICE_TYPE $offload_target_openacc
-
# For Fortran we're doing torture testing, as Fortran has far more tests
# with arrays etc. that testing just -O0 or -O2 is insufficient, that is
# typically not the case for C/C++.