Hi! On Thu, 20 Mar 2014 17:50:13 +0100, Bernd Schmidt <[email protected]> wrote: > This is based on Michael Zolotukhin's patch 2/3 from a while ago. It > adds functionality to build function/variable tables that will allow > libgomp to look up offload target code based on the address of the > corresponding host function. There are two alternatives, one based on > named sections, and one based on a target hook when named sections are > unavailable (as on ptx). > > Committed on gomp-4_0-branch.
> --- gcc/omp-low.c (revision 208706)
> +++ gcc/omp-low.c (working copy)
> @@ -8671,19 +8672,22 @@ expand_omp_target (struct omp_region *re
> }
>
> gimple g;
> - /* FIXME: This will be address of
> - extern char __OPENMP_TARGET__[] __attribute__((visibility ("hidden")))
> - symbol, as soon as the linker plugin is able to create it for us. */
> - tree openmp_target = build_zero_cst (ptr_type_node);
> + tree openmp_target
> + = build_decl (UNKNOWN_LOCATION, VAR_DECL,
> + get_identifier ("__OPENMP_TARGET__"), ptr_type_node);
> + TREE_PUBLIC (openmp_target) = 1;
> + DECL_EXTERNAL (openmp_target) = 1;
> if (kind == GF_OMP_TARGET_KIND_REGION)
> {
> tree fnaddr = build_fold_addr_expr (child_fn);
> - g = gimple_build_call (builtin_decl_explicit (start_ix), 7,
> - device, fnaddr, openmp_target, t1, t2, t3, t4);
> + g = gimple_build_call (builtin_decl_explicit (start_ix), 7, device,
> + fnaddr, build_fold_addr_expr (openmp_target),
> + t1, t2, t3, t4);
> }
> else
> - g = gimple_build_call (builtin_decl_explicit (start_ix), 6,
> - device, openmp_target, t1, t2, t3, t4);
> + g = gimple_build_call (builtin_decl_explicit (start_ix), 6, device,
> + build_fold_addr_expr (openmp_target),
> + t1, t2, t3, t4);
Committed in r209013:
commit 1f54e08135bd8be59438977b4edbc102e7cef2d7
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed Apr 2 08:28:54 2014 +0000
Handle __OPENMP_TARGET__ symbol for OpenACC offloading functions, too.
gcc/
* omp-low.c (expand_oacc_offload): Handle __OPENMP_TARGET__
symbol.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@209013
138bc75d-0d04-0410-961f-82ee72b054a4
---
gcc/ChangeLog.gomp | 5 +++++
gcc/omp-low.c | 14 ++++++++------
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git gcc/ChangeLog.gomp gcc/ChangeLog.gomp
index 1d35b58..8983632 100644
--- gcc/ChangeLog.gomp
+++ gcc/ChangeLog.gomp
@@ -1,3 +1,8 @@
+2014-04-02 Thomas Schwinge <[email protected]>
+
+ * omp-low.c (expand_oacc_offload): Handle __OPENMP_TARGET__
+ symbol.
+
2014-03-20 Thomas Schwinge <[email protected]>
* gimple.h (enum gf_mask): Add GF_OMP_FOR_KIND_OACC_LOOP.
diff --git gcc/omp-low.c gcc/omp-low.c
index a7b93bc..01eda9d 100644
--- gcc/omp-low.c
+++ gcc/omp-low.c
@@ -5138,13 +5138,15 @@ expand_oacc_offload (struct omp_region *region)
}
gimple g;
- /* FIXME: This will be address of
- extern char __OPENMP_TARGET__[] __attribute__((visibility ("hidden")))
- symbol, as soon as the linker plugin is able to create it for us. */
- tree openmp_target = build_zero_cst (ptr_type_node);
+ tree openmp_target
+ = build_decl (UNKNOWN_LOCATION, VAR_DECL,
+ get_identifier ("__OPENMP_TARGET__"), ptr_type_node);
+ TREE_PUBLIC (openmp_target) = 1;
+ DECL_EXTERNAL (openmp_target) = 1;
tree fnaddr = build_fold_addr_expr (child_fn);
- g = gimple_build_call (builtin_decl_explicit (start_ix),
- 10, device, fnaddr, openmp_target, t1, t2, t3, t4,
+ g = gimple_build_call (builtin_decl_explicit (start_ix), 10, device,
+ fnaddr, build_fold_addr_expr (openmp_target),
+ t1, t2, t3, t4,
t_num_gangs, t_num_workers, t_vector_length);
gimple_set_location (g, gimple_location (entry_stmt));
gsi_insert_before (&gsi, g, GSI_SAME_STMT);
> +/* Create new symbol containing (address, size) pairs for omp-marked
> + functions and global variables. */
> +void
> +omp_finish_file (void)
> +{
> + struct cgraph_node *node;
> + struct varpool_node *vnode;
> + const char *funcs_section_name = ".offload_func_table_section";
> + const char *vars_section_name = ".offload_var_table_section";
> + vec<tree, va_gc> *v_funcs, *v_vars;
> +
> + vec_alloc (v_vars, 0);
> + vec_alloc (v_funcs, 0);
> +
> + [...]
> + unsigned num_vars = vec_safe_length (v_vars);
> + unsigned num_funcs = vec_safe_length (v_funcs);
> + [...]
> + if (targetm_common.have_named_sections)
> + {
> + [...]
> + }
> + else
> + {
> + for (unsigned i = 0; i < num_funcs; i++)
> + {
> + tree it = (*v_funcs)[i];
> + targetm.record_offload_symbol (it);
> + }
> + for (unsigned i = 0; i < num_funcs; i++)
> + {
> + tree it = (*v_vars)[i];
> + targetm.record_offload_symbol (it);
> + }
> + }
> +}
Committed in r209014:
commit abae7b762c0b9787dd21e863561af44472096eb3
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed Apr 2 08:29:07 2014 +0000
Fix typo/copy'n'pasto.
gcc/
* omp-low.c (omp_finish_file): Use num_vars instead of num_funcs
when recording offload symbols v_vars.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@209014
138bc75d-0d04-0410-961f-82ee72b054a4
---
gcc/ChangeLog.gomp | 3 +++
gcc/omp-low.c | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git gcc/ChangeLog.gomp gcc/ChangeLog.gomp
index 8983632..64e0c35 100644
--- gcc/ChangeLog.gomp
+++ gcc/ChangeLog.gomp
@@ -1,5 +1,8 @@
2014-04-02 Thomas Schwinge <[email protected]>
+ * omp-low.c (omp_finish_file): Use num_vars instead of num_funcs
+ when recording offload symbols v_vars.
+
* omp-low.c (expand_oacc_offload): Handle __OPENMP_TARGET__
symbol.
diff --git gcc/omp-low.c gcc/omp-low.c
index 01eda9d..6c803a8 100644
--- gcc/omp-low.c
+++ gcc/omp-low.c
@@ -12934,7 +12934,7 @@ omp_finish_file (void)
tree it = (*v_funcs)[i];
targetm.record_offload_symbol (it);
}
- for (unsigned i = 0; i < num_funcs; i++)
+ for (unsigned i = 0; i < num_vars; i++)
{
tree it = (*v_vars)[i];
targetm.record_offload_symbol (it);
Grüße,
Thomas
pgpgqboqjO2is.pgp
Description: PGP signature
