This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[og7] Allow the accelerator to have more offloaded functions than the host
- From: Cesar Philippidis <cesar at codesourcery dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 11 Oct 2017 06:58:58 -0700
- Subject: [og7] Allow the accelerator to have more offloaded functions than the host
- Authentication-results: sourceware.org; auth=none
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
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)