This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC][gomp4] Offloading patches (1/3): Add '-fopenmp_target' option


Hi everybody,

Here is a set of patches implementing one more piece of offloading support in
GCC.  These three patches allow to build a host binary with target image and all
tables embedded.  Along with patches for libgomp and libgomp plugin, which
hopefully will be sent soon, that gives a functional and runnable executable (or
DSO) with actual offloading to MIC.

There is still a lot to do in this area, but this is the necessary basics - with
this we could actually run offloaded code, produced fully by compiler.

We would like to hear any feedback on these patches: what issues we should
address first before commit (if any), how the patches fit OpenACC work, etc.

Here is a patch 1/3: Add '-fopenmp_target' option This option tells lto1 to look
for "*.target_lto*" sections instead of usual "*.lto*".  That option is passed
to target compiler when we invoke it to build target image.

Thanks,
Michael


---
 gcc/lto/lang.opt     |    4 ++++
 gcc/lto/lto-object.c |    5 +++--
 gcc/lto/lto.c        |    7 ++++++-
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/gcc/lto/lang.opt b/gcc/lto/lang.opt
index 7a9aede..cd0098c 100644
--- a/gcc/lto/lang.opt
+++ b/gcc/lto/lang.opt
@@ -40,4 +40,8 @@ fresolution=
 LTO Joined
 The resolution file
 
+fopenmp_target
+LTO Var(flag_openmp_target)
+Run LTO infrastructure to read target-side bytecode and to build it.
+
 ; This comment is to ensure we retain the blank line above.
diff --git a/gcc/lto/lto-object.c b/gcc/lto/lto-object.c
index 19f10cc..64274f3 100644
--- a/gcc/lto/lto-object.c
+++ b/gcc/lto/lto-object.c
@@ -59,6 +59,8 @@ struct lto_simple_object
 
 static simple_object_attributes *saved_attributes;
 
+extern const char *section_name_prefix;
+
 /* Initialize FILE, an LTO file object for FILENAME.  */
 
 static void
@@ -229,8 +231,7 @@ lto_obj_add_section (void *data, const char *name, off_t offset,
   void **slot;
   struct lto_section_list *list = loasd->list;
 
-  if (strncmp (name, LTO_SECTION_NAME_PREFIX,
-	       strlen (LTO_SECTION_NAME_PREFIX)) != 0)
+  if (strncmp (name, section_name_prefix, strlen (section_name_prefix)))
     return 1;
 
   new_name = xstrdup (name);
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 0211437..dedf8a8 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -49,6 +49,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "context.h"
 #include "pass_manager.h"
 
+extern const char *section_name_prefix;
+
 /* Vector to keep track of external variables we've seen so far.  */
 vec<tree, va_gc> *lto_global_var_decls;
 
@@ -2081,7 +2083,7 @@ lto_section_with_id (const char *name, unsigned HOST_WIDE_INT *id)
 {
   const char *s;
 
-  if (strncmp (name, LTO_SECTION_NAME_PREFIX, strlen (LTO_SECTION_NAME_PREFIX)))
+  if (strncmp (name, section_name_prefix, strlen (section_name_prefix)))
     return 0;
   s = strrchr (name, '.');
   return s && sscanf (s, "." HOST_WIDE_INT_PRINT_HEX_PURE, id) == 1;
@@ -2757,6 +2759,9 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames)
 
   timevar_push (TV_IPA_LTO_DECL_IN);
 
+  if (flag_openmp_target)
+    section_name_prefix = OMP_SECTION_NAME_PREFIX;
+
   real_file_decl_data
     = decl_data = ggc_alloc_cleared_vec_lto_file_decl_data_ptr (nfiles + 1);
   real_file_count = nfiles;
-- 
1.7.1




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]