This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 3/n] OpenMP 4.0 offloading infrastructure: offload tables
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Ilya Verbin <iverbin at gmail dot com>
- Cc: Jakub Jelinek <jakub at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Bernd Schmidt <bernds at codesourcery dot com>, Kirill Yukhin <kirill dot yukhin at gmail dot com>
- Date: Mon, 8 Dec 2014 10:18:54 +0100
- Subject: Re: [PATCH 3/n] OpenMP 4.0 offloading infrastructure: offload tables
- Authentication-results: sourceware.org; auth=none
- References: <20140930145320 dot GA19623 at msticlxl57 dot ims dot intel dot com> <20141204193519 dot GA8024 at msticlxl57 dot ims dot intel dot com>
On Thu, Dec 4, 2014 at 8:35 PM, Ilya Verbin <iverbin@gmail.com> wrote:
> Hi,
>
> On 30 Sep 18:53, Ilya Verbin wrote:
>> This patch creates 2 vectors with decls: offload_funcs and offload_vars.
>> libgomp will use addresses from these arrays to look up offloaded code.
>>
>> During the compilation they are outputted to:
>> * binary __gnu_offload_funcs/vars sections, or using
>> targetm.record_offload_symbol hook for PTX.
>
> In some cases LTO may optimize out a global variable, declared as target, but
> it still will be referenced from the offload table, that will cause a linking
> error. Here is the example:
>
> #pragma omp declare target
> int G;
> #pragma omp end declare target
So where is that "magic" target use then? Why doesn't the symtab
reachability code see the use? (why don't we prune it from the offload
table?)
Richard.
> int main ()
> {
> int res = 0;
>
> #pragma omp target map(alloc: G) map(from: res)
> {
> G = 1;
> res = G;
> }
>
> return res;
> }
>
> $ gcc -fopenmp -flto -O1 test.c
> xxx.ltrans0.ltrans.o:.offload_var_table.3973: error: undefined reference to 'G'
>
> This issue can be resolved by forcing output of such variables.
> Is this fix ok? Should I add a testcase?
>
>
> diff --git a/gcc/varpool.c b/gcc/varpool.c
> index 0526b7f..db28c2a 100644
> --- a/gcc/varpool.c
> +++ b/gcc/varpool.c
> @@ -175,6 +175,7 @@ varpool_node::get_create (tree decl)
> g->have_offload = true;
> if (!in_lto_p)
> vec_safe_push (offload_vars, decl);
> + node->force_output = 1;
> #endif
> }
>
>
> Thanks,
> -- Ilya