public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Cesar Philippidis <cesar@codesourcery.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: [og7] Allow the accelerator to have more offloaded functions than the host
Date: Wed, 11 Oct 2017 14:02:00 -0000	[thread overview]
Message-ID: <711d1dba-0574-c7e6-0639-e49c105ee18b@codesourcery.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 842 bytes --]

Consider the following example:

Let lib1.c contain function f1.
Let lib2.c contain function f2.

Both f1 and f2 contain offloaded functions. Create a static library with
both lib1.o and lib2.o.

Next create a program which using that static library, but only calls f1.

If you build this program without program-wide -flto, this will cause
the nvptx linker to embed the offloaded functions for both f1 and f2 in
the host's executable, whereas the host will only have the offloaded
function for f1. This is a problem because the libgomp expects both the
host and accelerator to have the same number of offloaded functions.

As a temporary workaround, this patch teaches libgomp to allow the
accelerator to possess more offloaded functions than the host.

I've applied this patch to openacc-gcc-7-branch. Is it also suitable for
trunk?

Cesar

[-- Attachment #2: og7-linker.diff --]
[-- Type: text/x-patch, Size: 697 bytes --]

2017-10-11  Cesar Philippidis  <cesar@codesourcery.com>

	libgomp/
	* target.c (gomp_load_image_to_device): Allow the accelerator to
	possess more offloaded functions than the host.


diff --git a/libgomp/target.c b/libgomp/target.c
index a55c8f074d9..336581d2196 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -1452,7 +1452,7 @@ gomp_load_image_to_device (struct gomp_device_descr *devicep, unsigned version,
     = devicep->load_image_func (devicep->target_id, version,
 				target_data, &target_table);
 
-  if (num_target_entries != num_funcs + num_vars)
+  if (num_target_entries < num_funcs + num_vars)
     {
       gomp_mutex_unlock (&devicep->lock);
       if (is_register_lock)

                 reply	other threads:[~2017-10-11 13:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=711d1dba-0574-c7e6-0639-e49c105ee18b@codesourcery.com \
    --to=cesar@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).