From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 59122 invoked by alias); 21 Mar 2016 20:51:27 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 59100 invoked by uid 89); 21 Mar 2016 20:51:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Copying, *fn_ptr, HSA_DEBUG, hsa_debug X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Mon, 21 Mar 2016 20:51:25 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 72334AB08 for ; Mon, 21 Mar 2016 20:51:21 +0000 (UTC) Subject: Re: [HSA, PATCH] Allocate memory for shadow arg (PR hsa/70337) To: GCC Patches References: <56EFEDD5.8010508@suse.cz> <20160321182325.GD3435@virgil.suse.cz> Cc: Martin Jambor From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: <56F05ECF.3020005@suse.cz> Date: Mon, 21 Mar 2016 20:58:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160321182325.GD3435@virgil.suse.cz> Content-Type: multipart/mixed; boundary="------------050604080500050908060903" X-IsSubscribed: yes X-SW-Source: 2016-03/txt/msg01214.txt.bz2 This is a multi-part message in MIME format. --------------050604080500050908060903 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 521 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 --------------050604080500050908060903 Content-Type: text/x-patch; name="0001-Copy-shadow-argument-conditionally-PR-hsa-70337.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Copy-shadow-argument-conditionally-PR-hsa-70337.patch" Content-length: 1446 >From 413707c51bf4b0ac7f8dac6421be9955c18767dd Mon Sep 17 00:00:00 2001 From: marxin 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 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 --------------050604080500050908060903--