[RFC PATCH] Coalesce host to device transfers in libgomp

Thomas Schwinge thomas@codesourcery.com
Sun Dec 9 12:53:00 GMT 2018


Hi!

On Thu, 6 Dec 2018 18:57:31 +0100, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Dec 06, 2018 at 06:54:20PM +0100, Thomas Schwinge wrote:
> > On Thu, 6 Dec 2018 18:18:56 +0100, Jakub Jelinek <jakub@redhat.com> wrote:
> > > On Thu, Dec 06, 2018 at 06:01:48PM +0100, Thomas Schwinge wrote:
> > > > While reviewing Chung-Lin's
> > > > <https://gcc.gnu.org/ml/gcc-patches/2018-09/msg01428.html> "[PATCH 4/6,
> > > > OpenACC, libgomp] Async re-work, libgomp/target.c changes", I noticed the
> > > > following unrelated hunk.  Is that intentional or just an oversight that
> > > > it hasn't been included in your "gomp_coalesce_buf" changes (quoted below
> > > > for reference)?
> > > 
> > > I believe it is intentional, the coalescing code coalesces only stuff
> > > allocated by the current gomp_map_vars call, for the link_key case we know
> > > that is not the case, it is a copy to a file scope data variable in the PTX
> > > code.
> > 
> > Hmm, I thought this would just copy an address (as opposed to data) from
> > the host to the device, so that would be fine for coalescing.  But I'm
> > not familiar with that code, so it's certainly possible that I'm not
> > understanding this correctly.
> 
> The actual data transfer can be coalesced, just the address is copied into
> the offloaded file scope var and so that exact transfer can't be coalesced.

Ah, I see, thanks!

> > > Perhaps we could do the change but pass NULL instead
> > > of cbufp as the last argument?

Committed to trunk in r266919:

commit 9d5a0b9dbb3aa4493f6e20b711607a25783bcec3
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Sun Dec 9 12:47:23 2018 +0000

    Coalesce host to device transfers in libgomp: not for link pointer
    
            libgomp/
            * target.c (gomp_map_vars): Call gomp_copy_host2dev instead of
            devicep->host2dev_func.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266919 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog | 6 ++++++
 libgomp/target.c  | 7 ++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git libgomp/ChangeLog libgomp/ChangeLog
index 7ce0cdb42e14..99417ef62cf0 100644
--- libgomp/ChangeLog
+++ libgomp/ChangeLog
@@ -1,3 +1,9 @@
+2018-12-09  Thomas Schwinge  <thomas@codesourcery.com>
+	    Jakub Jelinek  <jakub@redhat.com>
+
+	* target.c (gomp_map_vars): Call gomp_copy_host2dev instead of
+	devicep->host2dev_func.
+
 2018-12-08  Jakub Jelinek  <jakub@redhat.com>
 
 	PR libgomp/87995
diff --git libgomp/target.c libgomp/target.c
index 8ebc2a370a16..a62ae2c3e4b3 100644
--- libgomp/target.c
+++ libgomp/target.c
@@ -957,9 +957,10 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum,
 		    /* Set link pointer on target to the device address of the
 		       mapped object.  */
 		    void *tgt_addr = (void *) (tgt->tgt_start + k->tgt_offset);
-		    devicep->host2dev_func (devicep->target_id,
-					    (void *) n->tgt_offset,
-					    &tgt_addr, sizeof (void *));
+		    /* We intentionally do not use coalescing here, as it's not
+		       data allocated by the current call to this function.  */
+		    gomp_copy_host2dev (devicep, (void *) n->tgt_offset,
+					&tgt_addr, sizeof (void *), NULL);
 		  }
 		array++;
 	      }


Grüße
 Thomas



More information about the Gcc-patches mailing list