Patchwork [gomp4] Add omp_is_initial_device

login
register
mail settings
Submitter Jakub Jelinek
Date June 12, 2013, 12:29 p.m.
Message ID <20130612122922.GS2336@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/250752/
State New
Headers show

Comments

Jakub Jelinek - June 12, 2013, 12:29 p.m.
Hi!

This adds another libgomp entry-point, the function is supposed to return
1/.true. if running on host and 0/.false. when running on the accelerator.
So far we always run on the host.

Tested on x86_64-linux, committed to gomp-4_0-branch.

2013-06-12  Jakub Jelinek  <jakub@redhat.com>

	* fortran.c (omp_is_initial_device): Add ialias_redirect.
	(omp_is_initial_device_): New function.
	* omp_lib.f90.in (omp_is_initial_device): New interface.
	* omp.h.in (omp_is_initial_device): New prototype.
	* libgomp.map (omp_is_initial_device, omp_is_initial_device_):
	Export @@OMP_4.0.
	* env.c (omp_is_initial_device): New function.  Add ialias for it.
	* omp_lib.h.in (omp_is_initial_device): New external.


	Jakub

Patch

--- libgomp/fortran.c.jj	2013-04-10 12:05:38.000000000 +0200
+++ libgomp/fortran.c	2013-06-12 13:59:19.552731481 +0200
@@ -72,6 +72,7 @@  ialias_redirect (omp_get_default_device)
 ialias_redirect (omp_get_num_devices)
 ialias_redirect (omp_get_num_teams)
 ialias_redirect (omp_get_team_num)
+ialias_redirect (omp_is_initial_device)
 #endif
 
 #ifndef LIBGOMP_GNU_SYMBOL_VERSIONING
@@ -485,3 +486,9 @@  omp_get_team_num_ (void)
 {
   return omp_get_team_num ();
 }
+
+int32_t
+omp_is_initial_device_ (void)
+{
+  return omp_is_initial_device ();
+}
--- libgomp/omp_lib.f90.in.jj	2013-04-10 12:34:26.000000000 +0200
+++ libgomp/omp_lib.f90.in	2013-06-12 13:55:54.463119117 +0200
@@ -330,4 +330,10 @@ 
           end function omp_get_team_num
         end interface
 
+        interface
+          function omp_is_initial_device ()
+            logical (4) :: omp_is_initial_device
+          end function omp_is_initial_device
+        end interface
+
       end module omp_lib
--- libgomp/omp.h.in.jj	2013-04-10 11:26:49.000000000 +0200
+++ libgomp/omp.h.in	2013-06-12 13:57:10.357860035 +0200
@@ -118,6 +118,8 @@  extern int omp_get_num_devices (void) __
 extern int omp_get_num_teams (void) __GOMP_NOTHROW;
 extern int omp_get_team_num (void) __GOMP_NOTHROW;
 
+extern int omp_is_initial_device (void) __GOMP_NOTHROW;
+
 #ifdef __cplusplus
 }
 #endif
--- libgomp/libgomp.map.jj	2013-04-10 12:06:47.000000000 +0200
+++ libgomp/libgomp.map	2013-06-12 13:59:48.601251473 +0200
@@ -130,6 +130,8 @@  OMP_4.0 {
 	omp_get_num_teams_;
 	omp_get_team_num;
 	omp_get_team_num_;
+	omp_is_initial_device;
+	omp_is_initial_device_;
 } OMP_3.1;
 
 GOMP_1.0 {
--- libgomp/env.c.jj	2013-04-05 17:08:01.000000000 +0200
+++ libgomp/env.c	2013-06-12 13:58:23.368662731 +0200
@@ -908,6 +908,12 @@  omp_get_team_num (void)
   return 0;
 }
 
+int
+omp_is_initial_device (void)
+{
+  return 1;
+}
+
 ialias (omp_set_dynamic)
 ialias (omp_set_nested)
 ialias (omp_set_num_threads)
@@ -926,3 +932,4 @@  ialias (omp_get_default_device)
 ialias (omp_get_num_devices)
 ialias (omp_get_num_teams)
 ialias (omp_get_team_num)
+ialias (omp_is_initial_device)
--- libgomp/omp_lib.h.in.jj	2013-04-10 13:02:18.000000000 +0200
+++ libgomp/omp_lib.h.in	2013-06-12 13:56:23.717635386 +0200
@@ -92,3 +92,6 @@ 
       external omp_get_team_num
       integer(4) omp_get_default_device, omp_get_num_devices
       integer(4) omp_get_num_teams, omp_get_team_num
+
+      external omp_is_initial_device
+      logical(4) omp_is_initial_device