Hi,
The libgomp offloading tests libgomp.c/for-{3,5,6}.c are monolithic
tests which test lots of subtests, and if any of them fail, it would be
good to be able to quickly known which subtest(s) fail. [ And if you fix
or break one of the subtests during accel target bringup, it would be
nice if that shows up in the PASS/FAIL status. ]
I've written a patch to generate standalone subtests from the original
ones, and add them to the test list in c.exp. This adds a total of 84
tests.
I've scaled the timeout for each subtest with factor 0.1. If all new
subtests time out, and we have a standard timeout of 300s, this adds 7
hrs testing time). But AFAIK, it's an open issue that dg-timeout and
dg-timeout-factor don't work on remote setups, so that problem may still
present itself.
I'm not sure if it makes sense to enable this by default on a normal
host-only setup, but perhaps this approach is acceptable if we require
effective target offload_device for the sub-test testcases?
If not, I think it would already be good to have this in the sources
disabled by default, and allow it to be enabled by editing a variable in
c.exp or some such.
WDYT?
Tested on x86_64 without offloading device (compile+run times listed in
patch).
Tested on x86_64 with gcn device.
TODO:
- generate only one copy of the subtests, to be used by each parallel
invocation.
- improve tcl, f.i. extracting the DO_TEST arguments could be done
better.
Thanks,
- Tom
0001-Generate-sub-tests-from-libgomp.c-for-3-5-6-.c.patch
Generate sub-tests from libgomp.c/for-{3,5,6}.c
With compiler build at -O0 --enable-checking=yes,rtl:
for-3.c: 33s
for-3-*.c: 2m31s
for-5.c: 59s
for-5-*.c: 5m5s
for-6.c: 43s
for-6-*.c: 3m39s
With compiler build at -O2 --enable-checking=release:
for-3.c: 10s
for-3-*.c: 22s
for-5.c: 8s
for-5-*.c: 42s
for-6.c: 6s
for-6-*.c: 29s
2017-11-24 Tom de Vries <tom@codesourcery.com>
* testsuite/libgomp.c/c.exp: Generate tests from .list files, and add
them to test to be run.
(generate_tests): New proc.
* testsuite/libgomp.c/for-3.list: New test list, factored out of ...
* testsuite/libgomp.c/for-3.c (main): ... here. Use for-3.list to
iterate over tests, or just run ONE_TEST.
(TEST_ALL): Define.
* testsuite/libgomp.c/for-5.list: New test list, factored out of ...
* testsuite/libgomp.c/for-5.c (main): ... here. Use for-5.list to
iterate over tests, or just run ONE_TEST.
(TEST_ALL): Define.
* testsuite/libgomp.c/for-6.list: New test list, factored out of ...
* testsuite/libgomp.c/for-6.c (main): ... here. Use for-6.list to
iterate over tests, or just run ONE_TEST.
(TEST_ALL): Define.
---
libgomp/testsuite/libgomp.c/c.exp | 74 ++++++++++++++++++++++++++++++-
libgomp/testsuite/libgomp.c/for-3.c | 65 +++++++++++++++++-----------
libgomp/testsuite/libgomp.c/for-3.list | 24 +++++++++++
libgomp/testsuite/libgomp.c/for-5.c | 79 ++++++++++++++++++----------------
libgomp/testsuite/libgomp.c/for-5.list | 35 +++++++++++++++
libgomp/testsuite/libgomp.c/for-6.c | 62 +++++++++++++++-----------
libgomp/testsuite/libgomp.c/for-6.list | 24 +++++++++++
7 files changed, 275 insertions(+), 88 deletions(-)
diff --git a/libgomp/testsuite/libgomp.c/c.exp b/libgomp/testsuite/libgomp.c/c.exp
index 31bdd57..791788b 100644
--- a/libgomp/testsuite/libgomp.c/c.exp
+++ b/libgomp/testsuite/libgomp.c/c.exp
@@ -23,10 +23,82 @@ dg-init
# Turn on OpenMP.
lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
+# Generate new tests for each DO_TEST entry in TEST_LIST.
+proc generate_tests { test_list } {
+ global srcdir
+ global subdir
+
+ # Get corresponding source file.
+ set base_file [regsub "\.list" $test_list ""]
+ set base_file [regsub "$srcdir/$subdir/" $base_file ""]
+ set c_file $base_file.c
+
+ # Get dg directives from c file.
+ set dg_directives ""
+ set fp [open "$srcdir/$subdir/$c_file" r]
+ while {[gets $fp line] >= 0} {
+ if {[regexp -line -- "^/\\* \{ dg-" $line]} {
+ if { "$dg_directives" == "" } {
+ set sep ""
+ } else {
+ set sep "\n"
+ }
+ set dg_directives "$dg_directives$sep$line"
+ }
+ }
+ close $fp
+
+ # Get list of tests.
+ set fp [open "$test_list" r]
+ set file_data [read $fp]
+ close $fp
+ set file_data [regsub -all "DO_TEST" $file_data ""]
+ set file_data [regsub -all "\\(" $file_data ""]
+ set file_data [regsub -all "\\)" $file_data ""]
+ set file_data [regsub -all \[\n\] $file_data ""]
+ set file_data [string trimleft $file_data " "]
+ set tests [split $file_data]
+
+ # Create directory to generate files.
+ set test_dir [pwd]
+ set generated_dir $test_dir/generated/libgomp.c
+ file mkdir $generated_dir
+
+ # Generate tests.
+ set new_files []
+ set i 1
+ foreach test $tests {
+ set new_file "$generated_dir/$base_file-$test.c"
+
+ set fp [open "$new_file" w]
+ puts $fp "$dg_directives"
+ puts $fp "/* { dg-timeout-factor 0.1 } */"
+ puts $fp "#define ONE_TEST $test"
+ puts $fp "#define TEST_NR $i"
+ puts $fp "#include \"$srcdir/$subdir/$c_file\""
+ close $fp
+
+ set i [expr $i + 1]
+ lappend new_files $new_file
+ }
+
+ return $new_files
+}
+
+# Generate tests for each .list file
+set test_lists [find $srcdir/$subdir *.list]
+set generated_tests []
+foreach test_list $test_lists {
+ set generated_tests [concat \
+ $generated_tests \
+ [generate_tests $test_list]]
+}
+
# Gather a list of all tests.
set tests [lsort [concat \
[find $srcdir/$subdir *.c] \
- [find $srcdir/$subdir/../libgomp.c-c++-common *.c]]]
+ [find $srcdir/$subdir/../libgomp.c-c++-common *.c] \
+ $generated_tests]]
set ld_library_path $always_ld_library_path
append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
diff --git a/libgomp/testsuite/libgomp.c/for-3.c b/libgomp/testsuite/libgomp.c/for-3.c
index f4cd115..d040f11 100644
--- a/libgomp/testsuite/libgomp.c/for-3.c
+++ b/libgomp/testsuite/libgomp.c/for-3.c
@@ -5,8 +5,15 @@ extern void abort ();
#define M(x, y, z) O(x, y, z)
#define O(x, y, z) x ## _ ## y ## _ ## z
+#ifndef ONE_TEST
+#define TEST_ALL 1
+#else
+#define TEST_ALL 0
+#endif
+
#pragma omp declare target
+#if TEST_ALL || TEST_NR == 1
#define F distribute
#define G d
#define S
@@ -16,7 +23,9 @@ extern void abort ();
#undef N
#undef F
#undef G
+#endif
+#if TEST_ALL || TEST_NR == 2
#define F distribute
#define G d_ds128
#define S dist_schedule(static, 128)
@@ -26,7 +35,9 @@ extern void abort ();
#undef N
#undef F
#undef G
+#endif
+#if TEST_ALL || TEST_NR == 3
#define F distribute simd
#define G ds
#define S
@@ -36,7 +47,9 @@ extern void abort ();
#undef N
#undef F
#undef G
+#endif
+#if TEST_ALL || TEST_NR == 4
#define F distribute simd
#define G ds_ds128
#define S dist_schedule(static, 128)
@@ -46,30 +59,39 @@ extern void abort ();
#undef N
#undef F
#undef G
+#endif
+#if TEST_ALL || (5 <= TEST_NR && TEST_NR <= 9)
#define F distribute parallel for
#define G dpf
#include "for-1.h"
#undef F
#undef G
+#endif
+#if TEST_ALL || (10 <= TEST_NR && TEST_NR <= 14)
#define F distribute parallel for dist_schedule(static, 128)
#define G dpf_ds128
#include "for-1.h"
#undef F
#undef G
+#endif
+#if TEST_ALL || (15 <= TEST_NR && TEST_NR <= 19)
#define F distribute parallel for simd
#define G dpfs
#include "for-1.h"
#undef F
#undef G
+#endif
+#if TEST_ALL || (20 <= TEST_NR && TEST_NR <= 24)
#define F distribute parallel for simd dist_schedule(static, 128)
#define G dpfs_ds128
#include "for-1.h"
#undef F
#undef G
+#endif
#pragma omp end declare target
@@ -77,33 +99,24 @@ int
main ()
{
int err = 0;
+
#pragma omp target teams reduction(|:err)
- {
- err |= test_d_normal ();
- err |= test_d_ds128_normal ();
- err |= test_ds_normal ();
- err |= test_ds_ds128_normal ();
- err |= test_dpf_static ();
- err |= test_dpf_static32 ();
- err |= test_dpf_auto ();
- err |= test_dpf_guided32 ();
- err |= test_dpf_runtime ();
- err |= test_dpf_ds128_static ();
- err |= test_dpf_ds128_static32 ();
- err |= test_dpf_ds128_auto ();
- err |= test_dpf_ds128_guided32 ();
- err |= test_dpf_ds128_runtime ();
- err |= test_dpfs_static ();
- err |= test_dpfs_static32 ();
- err |= test_dpfs_auto ();
- err |= test_dpfs_guided32 ();
- err |= test_dpfs_runtime ();
- err |= test_dpfs_ds128_static ();
- err |= test_dpfs_ds128_static32 ();
- err |= test_dpfs_ds128_auto ();
- err |= test_dpfs_ds128_guided32 ();
- err |= test_dpfs_ds128_runtime ();
- }
+ {
+#define DO_TEST_1(test) \
+ do { \
+ err |= test (); \
+ } while (0)
+
+#ifdef ONE_TEST
+ DO_TEST_1 (ONE_TEST);
+#else
+#define DO_TEST(test) DO_TEST_1(test);
+#include "for-3.list"
+#undef DO_TEST
+#endif
+#undef DO_TEST_1
+ }
+
if (err)
abort ();
return 0;
diff --git a/libgomp/testsuite/libgomp.c/for-3.list b/libgomp/testsuite/libgomp.c/for-3.list
new file mode 100644
index 0000000..6fb25a5
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/for-3.list
@@ -0,0 +1,24 @@
+DO_TEST (test_d_normal)
+DO_TEST (test_d_ds128_normal)
+DO_TEST (test_ds_normal)
+DO_TEST (test_ds_ds128_normal)
+DO_TEST (test_dpf_static)
+DO_TEST (test_dpf_static32)
+DO_TEST (test_dpf_auto)
+DO_TEST (test_dpf_guided32)
+DO_TEST (test_dpf_runtime)
+DO_TEST (test_dpf_ds128_static)
+DO_TEST (test_dpf_ds128_static32)
+DO_TEST (test_dpf_ds128_auto)
+DO_TEST (test_dpf_ds128_guided32)
+DO_TEST (test_dpf_ds128_runtime)
+DO_TEST (test_dpfs_static)
+DO_TEST (test_dpfs_static32)
+DO_TEST (test_dpfs_auto)
+DO_TEST (test_dpfs_guided32)
+DO_TEST (test_dpfs_runtime)
+DO_TEST (test_dpfs_ds128_static)
+DO_TEST (test_dpfs_ds128_static32)
+DO_TEST (test_dpfs_ds128_auto)
+DO_TEST (test_dpfs_ds128_guided32)
+DO_TEST (test_dpfs_ds128_runtime)
diff --git a/libgomp/testsuite/libgomp.c/for-5.c b/libgomp/testsuite/libgomp.c/for-5.c
index 84e636a..8f12579 100644
--- a/libgomp/testsuite/libgomp.c/for-5.c
+++ b/libgomp/testsuite/libgomp.c/for-5.c
@@ -5,6 +5,12 @@ extern void abort ();
#define M(x, y, z) O(x, y, z)
#define O(x, y, z) x ## _ ## y ## _ ## z
+#ifndef ONE_TEST
+#define TEST_ALL 1
+#else
+#define TEST_ALL 0
+#endif
+
#pragma omp declare target
#define F for
@@ -25,12 +31,15 @@ extern void abort ();
#define OMPFROM(v) DO_PRAGMA (omp target update from(v))
#define OMPTO(v) DO_PRAGMA (omp target update to(v))
+#if TEST_ALL || (1 <= TEST_NR && TEST_NR <= 5)
#define F target parallel for
#define G tpf
#include "for-1.h"
#undef F
#undef G
+#endif
+#if TEST_ALL || TEST_NR == 6
#define F target simd
#define G t_simd
#define S
@@ -40,13 +49,17 @@ extern void abort ();
#undef N
#undef F
#undef G
+#endif
+#if TEST_ALL || (7 <= TEST_NR && TEST_NR <= 11)
#define F target parallel for simd
#define G tpf_simd
#include "for-1.h"
#undef F
#undef G
+#endif
+#if TEST_ALL || TEST_NR == 12
#define F target teams distribute
#define G ttd
#define S
@@ -56,7 +69,9 @@ extern void abort ();
#undef N
#undef F
#undef G
+#endif
+#if TEST_ALL || TEST_NR == 13
#define F target teams distribute
#define G ttd_ds128
#define S dist_schedule(static, 128)
@@ -66,7 +81,9 @@ extern void abort ();
#undef N
#undef F
#undef G
+#endif
+#if TEST_ALL || TEST_NR == 14
#define F target teams distribute simd
#define G ttds
#define S
@@ -76,7 +93,9 @@ extern void abort ();
#undef N
#undef F
#undef G
+#endif
+#if TEST_ALL || TEST_NR == 15
#define F target teams distribute simd
#define G ttds_ds128
#define S dist_schedule(static, 128)
@@ -86,69 +105,57 @@ extern void abort ();
#undef N
#undef F
#undef G
+#endif
+#if TEST_ALL || (16 <= TEST_NR && TEST_NR <= 20)
#define F target teams distribute parallel for
#define G ttdpf
#include "for-1.h"
#undef F
#undef G
+#endif
+#if TEST_ALL || (21 <= TEST_NR && TEST_NR <= 25)
#define F target teams distribute parallel for dist_schedule(static, 128)
#define G ttdpf_ds128
#include "for-1.h"
#undef F
#undef G
+#endif
+#if TEST_ALL || (26 <= TEST_NR && TEST_NR <= 30)
#define F target teams distribute parallel for simd
#define G ttdpfs
#include "for-1.h"
#undef F
#undef G
+#endif
+#if TEST_ALL || (31 <= TEST_NR && TEST_NR <= 35)
#define F target teams distribute parallel for simd dist_schedule(static, 128)
#define G ttdpfs_ds128
#include "for-1.h"
#undef F
#undef G
+#endif
int
main ()
{
- if (test_tpf_static ()
- || test_tpf_static32 ()
- || test_tpf_auto ()
- || test_tpf_guided32 ()
- || test_tpf_runtime ()
- || test_t_simd_normal ()
- || test_tpf_simd_static ()
- || test_tpf_simd_static32 ()
- || test_tpf_simd_auto ()
- || test_tpf_simd_guided32 ()
- || test_tpf_simd_runtime ()
- || test_ttd_normal ()
- || test_ttd_ds128_normal ()
- || test_ttds_normal ()
- || test_ttds_ds128_normal ()
- || test_ttdpf_static ()
- || test_ttdpf_static32 ()
- || test_ttdpf_auto ()
- || test_ttdpf_guided32 ()
- || test_ttdpf_runtime ()
- || test_ttdpf_ds128_static ()
- || test_ttdpf_ds128_static32 ()
- || test_ttdpf_ds128_auto ()
- || test_ttdpf_ds128_guided32 ()
- || test_ttdpf_ds128_runtime ()
- || test_ttdpfs_static ()
- || test_ttdpfs_static32 ()
- || test_ttdpfs_auto ()
- || test_ttdpfs_guided32 ()
- || test_ttdpfs_runtime ()
- || test_ttdpfs_ds128_static ()
- || test_ttdpfs_ds128_static32 ()
- || test_ttdpfs_ds128_auto ()
- || test_ttdpfs_ds128_guided32 ()
- || test_ttdpfs_ds128_runtime ())
- abort ();
+#define DO_TEST_1(test) \
+ do { \
+ if (test ()) \
+ abort (); \
+ } while (0)
+
+#ifdef ONE_TEST
+ DO_TEST_1 (ONE_TEST);
+#else
+#define DO_TEST(test) DO_TEST_1 (test);
+#include "for-5.list"
+#undef DO_TEST
+#endif
+#undef DO_TEST_1
+
return 0;
}
diff --git a/libgomp/testsuite/libgomp.c/for-5.list b/libgomp/testsuite/libgomp.c/for-5.list
new file mode 100644
index 0000000..48d0c3a
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/for-5.list
@@ -0,0 +1,35 @@
+DO_TEST (test_tpf_static)
+DO_TEST (test_tpf_static32)
+DO_TEST (test_tpf_auto)
+DO_TEST (test_tpf_guided32)
+DO_TEST (test_tpf_runtime)
+DO_TEST (test_t_simd_normal)
+DO_TEST (test_tpf_simd_static)
+DO_TEST (test_tpf_simd_static32)
+DO_TEST (test_tpf_simd_auto)
+DO_TEST (test_tpf_simd_guided32)
+DO_TEST (test_tpf_simd_runtime)
+DO_TEST (test_ttd_normal)
+DO_TEST (test_ttd_ds128_normal)
+DO_TEST (test_ttds_normal)
+DO_TEST (test_ttds_ds128_normal)
+DO_TEST (test_ttdpf_static)
+DO_TEST (test_ttdpf_static32)
+DO_TEST (test_ttdpf_auto)
+DO_TEST (test_ttdpf_guided32)
+DO_TEST (test_ttdpf_runtime)
+DO_TEST (test_ttdpf_ds128_static)
+DO_TEST (test_ttdpf_ds128_static32)
+DO_TEST (test_ttdpf_ds128_auto)
+DO_TEST (test_ttdpf_ds128_guided32)
+DO_TEST (test_ttdpf_ds128_runtime)
+DO_TEST (test_ttdpfs_static)
+DO_TEST (test_ttdpfs_static32)
+DO_TEST (test_ttdpfs_auto)
+DO_TEST (test_ttdpfs_guided32)
+DO_TEST (test_ttdpfs_runtime)
+DO_TEST (test_ttdpfs_ds128_static)
+DO_TEST (test_ttdpfs_ds128_static32)
+DO_TEST (test_ttdpfs_ds128_auto)
+DO_TEST (test_ttdpfs_ds128_guided32)
+DO_TEST (test_ttdpfs_ds128_runtime)
diff --git a/libgomp/testsuite/libgomp.c/for-6.c b/libgomp/testsuite/libgomp.c/for-6.c
index 7f3c65e..50a866a 100644
--- a/libgomp/testsuite/libgomp.c/for-6.c
+++ b/libgomp/testsuite/libgomp.c/for-6.c
@@ -5,6 +5,12 @@ extern void abort ();
#define M(x, y, z) O(x, y, z)
#define O(x, y, z) x ## _ ## y ## _ ## z
+#ifndef ONE_TEST
+#define TEST_ALL 1
+#else
+#define TEST_ALL 0
+#endif
+
#pragma omp declare target
#define F for
@@ -27,6 +33,7 @@ extern void abort ();
#define OMPFROM(v) DO_PRAGMA (omp target update from(v))
#define OMPTO(v) DO_PRAGMA (omp target update to(v))
+#if TEST_ALL || TEST_NR == 1
#define F teams distribute
#define G td
#define S
@@ -36,7 +43,9 @@ extern void abort ();
#undef N
#undef F
#undef G
+#endif
+#if TEST_ALL || TEST_NR == 2
#define F teams distribute
#define G td_ds128
#define S dist_schedule(static, 128)
@@ -46,7 +55,9 @@ extern void abort ();
#undef N
#undef F
#undef G
+#endif
+#if TEST_ALL || TEST_NR == 3
#define F teams distribute simd
#define G tds
#define S
@@ -56,7 +67,9 @@ extern void abort ();
#undef N
#undef F
#undef G
+#endif
+#if TEST_ALL || TEST_NR == 4
#define F teams distribute simd
#define G tds_ds128
#define S dist_schedule(static, 128)
@@ -66,58 +79,57 @@ extern void abort ();
#undef N
#undef F
#undef G
+#endif
+#if TEST_ALL || (5 <= TEST_NR && TEST_NR <= 9)
#define F teams distribute parallel for
#define G tdpf
#include "for-1.h"
#undef F
#undef G
+#endif
+#if TEST_ALL || (10 <= TEST_NR && TEST_NR <= 14)
#define F teams distribute parallel for dist_schedule(static, 128)
#define G tdpf_ds128
#include "for-1.h"
#undef F
#undef G
+#endif
+#if TEST_ALL || (15 <= TEST_NR && TEST_NR <= 19)
#define F teams distribute parallel for simd
#define G tdpfs
#include "for-1.h"
#undef F
#undef G
+#endif
+#if TEST_ALL || (20 <= TEST_NR && TEST_NR <= 24)
#define F teams distribute parallel for simd dist_schedule(static, 128)
#define G tdpfs_ds128
#include "for-1.h"
#undef F
#undef G
+#endif
int
main ()
{
- if (test_td_normal ()
- || test_td_ds128_normal ()
- || test_tds_normal ()
- || test_tds_ds128_normal ()
- || test_tdpf_static ()
- || test_tdpf_static32 ()
- || test_tdpf_auto ()
- || test_tdpf_guided32 ()
- || test_tdpf_runtime ()
- || test_tdpf_ds128_static ()
- || test_tdpf_ds128_static32 ()
- || test_tdpf_ds128_auto ()
- || test_tdpf_ds128_guided32 ()
- || test_tdpf_ds128_runtime ()
- || test_tdpfs_static ()
- || test_tdpfs_static32 ()
- || test_tdpfs_auto ()
- || test_tdpfs_guided32 ()
- || test_tdpfs_runtime ()
- || test_tdpfs_ds128_static ()
- || test_tdpfs_ds128_static32 ()
- || test_tdpfs_ds128_auto ()
- || test_tdpfs_ds128_guided32 ()
- || test_tdpfs_ds128_runtime ())
- abort ();
+#define DO_TEST_1(test) \
+ do { \
+ if (test ()) \
+ abort (); \
+ } while (0)
+
+#ifdef ONE_TEST
+ DO_TEST_1 (ONE_TEST);
+#else
+#define DO_TEST(test) DO_TEST_1 (test);
+#include "for-6.list"
+#undef DO_TEST
+#endif
+#undef DO_TEST_1
+
return 0;
}
diff --git a/libgomp/testsuite/libgomp.c/for-6.list b/libgomp/testsuite/libgomp.c/for-6.list
new file mode 100644
index 0000000..438ecff
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/for-6.list
@@ -0,0 +1,24 @@
+DO_TEST (test_td_normal)
+DO_TEST (test_td_ds128_normal)
+DO_TEST (test_tds_normal)
+DO_TEST (test_tds_ds128_normal)
+DO_TEST (test_tdpf_static)
+DO_TEST (test_tdpf_static32)
+DO_TEST (test_tdpf_auto)
+DO_TEST (test_tdpf_guided32)
+DO_TEST (test_tdpf_runtime)
+DO_TEST (test_tdpf_ds128_static)
+DO_TEST (test_tdpf_ds128_static32)
+DO_TEST (test_tdpf_ds128_auto)
+DO_TEST (test_tdpf_ds128_guided32)
+DO_TEST (test_tdpf_ds128_runtime)
+DO_TEST (test_tdpfs_static)
+DO_TEST (test_tdpfs_static32)
+DO_TEST (test_tdpfs_auto)
+DO_TEST (test_tdpfs_guided32)
+DO_TEST (test_tdpfs_runtime)
+DO_TEST (test_tdpfs_ds128_static)
+DO_TEST (test_tdpfs_ds128_static32)
+DO_TEST (test_tdpfs_ds128_auto)
+DO_TEST (test_tdpfs_ds128_guided32)
+DO_TEST (test_tdpfs_ds128_runtime)