This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [HSA, PATCH] Allocate memory for shadow arg (PR hsa/70337)
- From: Martin LiÅka <mliska at suse dot cz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Martin Jambor <mjambor at suse dot cz>
- Date: Mon, 21 Mar 2016 21:51:27 +0100
- Subject: Re: [HSA, PATCH] Allocate memory for shadow arg (PR hsa/70337)
- Authentication-results: sourceware.org; auth=none
- References: <56EFEDD5 dot 8010508 at suse dot cz> <20160321182325 dot GD3435 at virgil dot suse dot cz>
On 03/21/2016 07:23 PM, Martin Jambor wrote:
This is strange. The pointer to the shadow data structure is, from
the HSA perspective, a normal kernel argument and therefore should
already be included in the kernel->kernarg_segment_size. Have you
checked that the values are indeed off?
Hi Martin.
You are right that size of a shadow argument pointer should be
included in the kernel->kernarg_segment_size. I've been currently
testing a proper patch which conditionally copies shadow argument.
Thanks,
Martin
>From 413707c51bf4b0ac7f8dac6421be9955c18767dd Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Mon, 21 Mar 2016 21:40:03 +0100
Subject: [PATCH] Copy shadow argument conditionally (PR hsa/70337)
libgomp/ChangeLog:
2016-03-21 Martin Liska <mliska@suse.cz>
PR hsa/70337
* plugin/plugin-hsa.c (GOMP_OFFLOAD_run): Copy shadow
argument just in case a dispatched kernel uses that argument.
---
libgomp/plugin/plugin-hsa.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/libgomp/plugin/plugin-hsa.c b/libgomp/plugin/plugin-hsa.c
index d888493..f7ef600 100644
--- a/libgomp/plugin/plugin-hsa.c
+++ b/libgomp/plugin/plugin-hsa.c
@@ -1255,8 +1255,16 @@ GOMP_OFFLOAD_run (int n, void *fn_ptr, void *vars, void **args)
hsa_signal_store_relaxed (s, 1);
memcpy (shadow->kernarg_address, &vars, sizeof (vars));
- memcpy (shadow->kernarg_address + sizeof (vars), &shadow,
- sizeof (struct hsa_kernel_runtime *));
+ /* PR hsa/70337. */
+ size_t vars_size = sizeof (vars);
+ if (kernel->kernarg_segment_size > vars_size)
+ {
+ if (kernel->kernarg_segment_size != vars_size
+ + sizeof (struct hsa_kernel_runtime *))
+ GOMP_PLUGIN_fatal ("Kernel segment size has an unexpected value");
+ memcpy (packet->kernarg_address + vars_size, &shadow,
+ sizeof (struct hsa_kernel_runtime *));
+ }
HSA_DEBUG ("Copying kernel runtime pointer to kernarg_address\n");
--
2.7.1