[gomp4 01/14] nvptx: emit kernels for 'omp target entrypoint' only for OpenACC

Alexander Monakov amonakov@ispras.ru
Tue Oct 20 18:34:00 GMT 2015


The NVPTX backend emits each functions either as .func (callable only from the
device code) or as .kernel (entry point for a parallel region).  OpenMP
lowering adds "omp target entrypoint" attribute to functions outlined from
target regions.  Unlike OpenACC offloading, OpenMP offloading does not invoke
such outlined functions directly, but instead passes their address to
'gomp_nvptx_main'.  Restrict the special attribute treatment to OpenACC only.

	* config/nvptx/nvptx.c (write_as_kernel): Additionally test
	flag_openacc for "omp_target_entrypoint".
---
 gcc/config/nvptx/nvptx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index 21c59ef..df7b61f 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -401,8 +401,10 @@ write_one_arg (std::stringstream &s, tree type, int i, machine_mode mode,
 static bool
 write_as_kernel (tree attrs)
 {
-  return (lookup_attribute ("kernel", attrs) != NULL_TREE
-	  || lookup_attribute ("omp target entrypoint", attrs) != NULL_TREE);
+  if (flag_openacc
+      && lookup_attribute ("omp target entrypoint", attrs) != NULL_TREE)
+    return true;
+  return lookup_attribute ("kernel", attrs) != NULL_TREE;
 }
 
 /* Write a function decl for DECL to S, where NAME is the name to be used.



More information about the Gcc-patches mailing list