diff mbox

[HSA] Load an HSA runtime via dlopen mechanism

Message ID 87shk1ynqr.fsf@hertz.schwinge.homeip.net
State New
Headers show

Commit Message

Thomas Schwinge May 19, 2017, 1:34 p.m. UTC
Hi!

On Sun, 9 Apr 2017 18:22:00 +0200, Martin Jambor <mjambor@suse.cz> wrote:
> On Wed, Apr 05, 2017 at 10:11:34AM +0200, Thomas Schwinge wrote:
> > I ran into a case where the libgomp hsa plugin wouldn't load.  The
> > following patch helped me to quickly diagnose and then fix that.  OK for
> > trunk?
> 
> Yes, thanks.

Thanks, now finally, as posted, committed to trunk in r248277:

commit b7d6170b96407c80b3e21dd6a665ebff7715d62e
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri May 19 13:32:04 2017 +0000

    libgomp hsa plugin: debug output for HSA runtime library loading failure
    
            libgomp/
            * plugin/plugin-hsa.c (DLSYM_FN, init_hsa_runtime_functions):
            Debug output for failure.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@248277 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog           | 5 +++++
 libgomp/plugin/plugin-hsa.c | 8 ++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)



Grüße
 Thomas
diff mbox

Patch

diff --git libgomp/ChangeLog libgomp/ChangeLog
index 083cb85..84d1c839 100644
--- libgomp/ChangeLog
+++ libgomp/ChangeLog
@@ -1,3 +1,8 @@ 
+2017-05-19  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* plugin/plugin-hsa.c (DLSYM_FN, init_hsa_runtime_functions):
+	Debug output for failure.
+
 2017-05-12  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
 	* testsuite/lib/libgomp.exp: Load scanlang.exp.
diff --git libgomp/plugin/plugin-hsa.c libgomp/plugin/plugin-hsa.c
index 9cc243d..90ca247 100644
--- libgomp/plugin/plugin-hsa.c
+++ libgomp/plugin/plugin-hsa.c
@@ -491,14 +491,14 @@  static struct hsa_context_info hsa_context;
 #define DLSYM_FN(function) \
   hsa_fns.function##_fn = dlsym (handle, #function); \
   if (hsa_fns.function##_fn == NULL) \
-    return false;
+    goto dl_fail;
 
 static bool
 init_hsa_runtime_functions (void)
 {
   void *handle = dlopen (hsa_runtime_lib, RTLD_LAZY);
   if (handle == NULL)
-    return false;
+    goto dl_fail;
 
   DLSYM_FN (hsa_status_string)
   DLSYM_FN (hsa_agent_get_info)
@@ -530,6 +530,10 @@  init_hsa_runtime_functions (void)
   DLSYM_FN (hsa_ext_program_destroy)
   DLSYM_FN (hsa_ext_program_finalize)
   return true;
+
+ dl_fail:
+  HSA_DEBUG ("while loading %s: %s\n", hsa_runtime_lib, dlerror ());
+  return false;
 }
 
 /* Find kernel for an AGENT by name provided in KERNEL_NAME.  */