Hi!

I've noticed that the file &1 in libgomp/testsuite/ directory after make
check and left over hsa_offloading_src*.exe files.
After looking more carefully, I found various issues.
1) the way check_compile is invoked leaves result with values on which
lindex doesn't do what is expected to do
2) "2>&1" doesn't do redirection of stderr to stdout for remote_load; but
apparently both stdout and stderr make up into [lindex $result 1], so it
isn't really needed
3) if $status isn't pass, we wouldn't remote_file build delete the
executable
4) otherwise neither, because while output variable contained the executable
filename initially, it was later set to the stdout+stderr of the proglet

I don't have HSA offloading configured (no HSAIL offloading capable HW on
this WS, and on another WS where I have that I don't have the needed kernel
driver), so couldn't test with proper HSA offloading, but tested without it
and additionally tested with following hack that simulated in the proglet
what the plugin would do (in that case make check started compiling/running
libgomp.hsa.c/ tests where some of them obviously failed miserably with
actually NVPTX offloading, but that is to be expected when I cheated).

Martin, can you please test this yourself, so that I can check it in?

The attached patch is the hack I used, which obviously shouldn't be applied.

2017-01-26  Jakub Jelinek  <ja...@redhat.com>

        * testsuite/lib/libgomp.exp
        (check_effective_target_hsa_offloading_selected_nocache): Fix up
        check_compile invocation.  Fix up removal of executable.  Drop
        bogus "2>&1" argument.

--- libgomp/testsuite/lib/libgomp.exp.jj        2016-11-23 13:59:03.000000000 
+0100
+++ libgomp/testsuite/lib/libgomp.exp   2017-01-26 13:50:06.889062714 +0100
@@ -408,16 +408,16 @@ proc check_effective_target_hsa_offloadi
        }
     }
     
-    set result [eval [list check_compile hsa_offloading_src executable $src] 
""]
+    set result [check_compile hsa_offloading_src executable $src]
     set lines [lindex $result 0]
-    set output [lindex $result 1]
+    set exe [lindex $result 1]
 
     set ok 0
     if { [string match "" $lines] } {
        # No error messages, let us switch on HSA debugging output and run it
        set prev_HSA_DEBUG [getenv HSA_DEBUG]
        setenv HSA_DEBUG "1"
-       set result [remote_load target "./$output" "2>&1" ""]
+       set result [remote_load target "./$exe"]
        if { [string match "" $prev_HSA_DEBUG] } {
            unsetenv HSA_DEBUG
        } else {
@@ -425,6 +425,7 @@ proc check_effective_target_hsa_offloadi
        }
        set status [lindex $result 0]
        if { $status != "pass" } {
+           remote_file build delete $exe
            verbose "HSA availability test failed"
            return 0
        }
@@ -434,7 +435,7 @@ proc check_effective_target_hsa_offloadi
            set ok 1
        }
     }
-    remote_file build delete $output
+    remote_file build delete $exe
     return $ok
 }
 

        Jakub
--- libgomp/testsuite/lib/libgomp.exp.jj        2017-01-26 13:50:06.000000000 
+0100
+++ libgomp/testsuite/lib/libgomp.exp   2017-01-26 13:53:43.750215729 +0100
@@ -400,8 +400,12 @@ proc check_effective_target_hsa_offloadi
     global tool
 
     set src {
+       #include <stdio.h>
+       #include <stdlib.h>
        int main () {
            int v = 1;
+           if (getenv ("HSA_DEBUG"))
+               fprintf (stderr, "HSA debug: Going to dispatch kernel");
            #pragma omp target map(from:v)
            v = 0;
            return v;

Reply via email to