From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18760 invoked by alias); 16 Oct 2018 13:13:12 -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 18317 invoked by uid 89); 16 Oct 2018 13:13:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.9 required=5.0 tests=BAYES_00,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 16 Oct 2018 13:13:09 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0599B61D07; Tue, 16 Oct 2018 13:13:08 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-222.ams2.redhat.com [10.36.117.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F1F54D9E1; Tue, 16 Oct 2018 13:13:07 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id w9GDD5PN003580; Tue, 16 Oct 2018 15:13:05 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w9GDD38p003579; Tue, 16 Oct 2018 15:13:03 +0200 Date: Tue, 16 Oct 2018 14:49:00 -0000 From: Jakub Jelinek To: cltang@codesourcery.com Cc: gcc-patches@gcc.gnu.org, Thomas Schwinge Subject: Re: [PATCH, OpenACC, 7/8] Multi-dimensional dynamic array support for OpenACC data clauses, libgomp support Message-ID: <20181016131303.GZ11625@tucnak> Reply-To: Jakub Jelinek References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes X-SW-Source: 2018-10/txt/msg00951.txt.bz2 On Tue, Oct 16, 2018 at 08:57:00PM +0800, Chung-Lin Tang wrote: > --- a/libgomp/target.c > +++ b/libgomp/target.c > @@ -490,6 +490,140 @@ gomp_map_val (struct target_mem_desc *tgt, void **hostaddrs, size_t i) > return tgt->tgt_start + tgt->list[i].offset; > } > > +/* Dynamic array related data structures, interfaces with the compiler. */ > + > +struct da_dim { > + size_t base; > + size_t length; > + size_t elem_size; > + size_t is_array; > +}; > + > +struct da_descr_type { > + void *ptr; > + size_t ndims; > + struct da_dim dims[]; > +}; Why do you call the non-contiguous arrays dynamic arrays? Is that some OpenACC term? I'd also prefix those with gomp_ and it is important to make it clear what is the ABI type shared with the compiler and what are the internal types. struct gomp_array_descr would look more natural to me. > + for (i = 0; i < mapnum; i++) > + { > + int kind = get_kind (short_mapkind, kinds, i); > + if (GOMP_MAP_DYNAMIC_ARRAY_P (kind & typemask)) > + { > + da_data_row_num += gomp_dynamic_array_count_rows (hostaddrs[i]); > + da_info_num += 1; > + } > + } I'm not really happy by adding several extra loops which will not do anything in the case there are no non-contiguous arrays being mapped (for now always for OpenMP (OpenMP 5 has support for non-contigious target update to/from though) and guess rarely for OpenACC). Can't you use some flag bit in flags passed to GOMP_target* etc. and do the above loop only if the compiler indicated there are any? > + tgt = gomp_malloc (sizeof (*tgt) > + + sizeof (tgt->list[0]) * (mapnum + da_data_row_num)); > + tgt->list_count = mapnum + da_data_row_num; > tgt->refcount = pragma_kind == GOMP_MAP_VARS_ENTER_DATA ? 0 : 1; > tgt->device_descr = devicep; > struct gomp_coalesce_buf cbuf, *cbufp = NULL; > @@ -687,6 +863,55 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, > } > } > > + /* For dynamic arrays. Each data row is one target item, separated from > + the normal map clause items, hence we order them after mapnum. */ > + for (i = 0, da_index = 0, row_start = 0; i < mapnum; i++) Even if nothing is in flags, you could just avoid this loop if the previous loop(s) haven't found any noncontiguous arrays. > @@ -976,6 +1210,108 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, > array++; > } > } > + > + /* Processing of dynamic array rows. */ > + for (i = 0, da_index = 0, row_start = 0; i < mapnum; i++) > + { > + int kind = get_kind (short_mapkind, kinds, i); > + if (!GOMP_MAP_DYNAMIC_ARRAY_P (kind & typemask)) > + continue; Again. Jakub