On 15/11/2019 21:44, Julian Brown wrote:
+static void
+hsa_memory_copy_wrapper (void *dst, const void *src, size_t len)
+{
+ hsa_status_t status = hsa_fns.hsa_memory_copy_fn (dst, src, len);
+
+ if (status == HSA_STATUS_SUCCESS)
+ return;
+
+ /* It appears that the copy fails if the source data is in a read-only page.
+ We can't detect that easily, so try copying the data to a temporary buffer
+ and doing the copy again if we got an error above. */
+
+ void *src_copy = malloc (len);
+ memcpy (src_copy, src, len);
+ status = hsa_fns.hsa_memory_copy_fn (dst, (const void *) src_copy, len);
+ free (src_copy);
+ if (status != HSA_STATUS_SUCCESS)
+ GOMP_PLUGIN_error ("memory copy failed");
+}
I'd like a GCN_DEBUG (or GCN_WARNING?) in the fallback case, so that we
can see if it does that very often. If so I'd think we should report it
as a bug to ROCm.
Otherwise the patch is fine by me.
Andrew