The following avoids selecting an unsupported agent early, avoiding
later asserts when we rely on it being supported.
tested on x86_64-unknown-linux-gnu -> amdhsa-gcn on gfx1060
that's the alternative to the other patch. I do indeed seem to get
the other (unsupported) agent selected somehow after the other supported
agent finished a kernel run. Not sure if it's the CPU or the IGPU though.
OK? Which variant?
libgomp/
* plugin/plugin-gcn.c (get_agent_info): When the agent isn't supported
return NULL.
---
libgomp/plugin/plugin-gcn.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
index d8c3907c108..f453f630e06 100644
--- a/libgomp/plugin/plugin-gcn.c
+++ b/libgomp/plugin/plugin-gcn.c
@@ -1036,6 +1036,8 @@ print_kernel_dispatch (struct kernel_dispatch *dispatch,
unsigned indent)
/* }}} */
/* {{{ Utility functions */
+static const char* isa_hsa_name (int isa);
+
/* Cast the thread local storage to gcn_thread. */
static inline struct gcn_thread *
@@ -1589,6 +1591,11 @@ get_agent_info (int n)
GOMP_PLUGIN_error ("Attempt to use an uninitialized GCN agent.");
return NULL;
}
+ if (!isa_hsa_name (hsa_context.agents[n].device_isa))
+ {
+ GOMP_PLUGIN_error ("Attempt to use an unsupported GCN agent.");
+ return NULL;
+ }
return &hsa_context.agents[n];
}
--
2.35.3