Re: Implementing OpenACC's Fortran module

2017-05-24 Thread Thomas Schwinge
Hi!

On Wed, 24 May 2017 13:58:32 +0200, Jakub Jelinek  wrote:
> On Wed, May 24, 2017 at 01:34:50PM +0200, Thomas Schwinge wrote:
> > Thus OK for trunk, as posted?
> 
> Ok.

Thanks.  Committed to trunk in r248412:

commit b70df2112de1c8fb9b448dc24e3a58055e4bbbdc
Author: tschwinge 
Date:   Wed May 24 13:23:55 2017 +

Fortran OpenACC "openacc_lib.h": acc_pcopyin, acc_pcreate

libgomp/
* openacc_lib.h (acc_pcopyin, acc_pcreate): Route to
acc_present_or_copyin and acc_present_or_create procedures,
respectively.
* testsuite/libgomp.oacc-fortran/lib-32-1.f: Exercise these, and
generally different variants of OpenACC Runtime Library functions.
* testsuite/libgomp.oacc-fortran/lib-32-2.f: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@248412 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog |  7 
 libgomp/openacc_lib.h | 42 ---
 libgomp/testsuite/libgomp.oacc-fortran/lib-32-1.f | 36 ---
 libgomp/testsuite/libgomp.oacc-fortran/lib-32-2.f | 26 +++---
 4 files changed, 42 insertions(+), 69 deletions(-)

diff --git libgomp/ChangeLog libgomp/ChangeLog
index af8c5ca..55869d2 100644
--- libgomp/ChangeLog
+++ libgomp/ChangeLog
@@ -1,5 +1,12 @@
 2017-05-24  Thomas Schwinge  
 
+   * openacc_lib.h (acc_pcopyin, acc_pcreate): Route to
+   acc_present_or_copyin and acc_present_or_create procedures,
+   respectively.
+   * testsuite/libgomp.oacc-fortran/lib-32-1.f: Exercise these, and
+   generally different variants of OpenACC Runtime Library functions.
+   * testsuite/libgomp.oacc-fortran/lib-32-2.f: Likewise.
+
* testsuite/libgomp.oacc-fortran/lib-32-1.f: New file.
* testsuite/libgomp.oacc-fortran/lib-32-2.f: Likewise.
 
diff --git libgomp/openacc_lib.h libgomp/openacc_lib.h
index 65f47a8..7818bd7 100644
--- libgomp/openacc_lib.h
+++ libgomp/openacc_lib.h
@@ -191,23 +191,9 @@
   end interface
 
   interface acc_pcopyin
-subroutine acc_pcopyin_32_h (a, len)
-  use iso_c_binding, only: c_int32_t
-  !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
-  type (*), dimension (*) :: a
-  integer (c_int32_t) len
-end subroutine
-
-subroutine acc_pcopyin_64_h (a, len)
-  use iso_c_binding, only: c_int64_t
-  !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
-  type (*), dimension (*) :: a
-  integer (c_int64_t) len
-end subroutine
-
-subroutine acc_pcopyin_array_h (a)
-  type (*), dimension (..), contiguous :: a
-  end subroutine
+procedure :: acc_present_or_copyin_32_h
+procedure :: acc_present_or_copyin_64_h
+procedure :: acc_present_or_copyin_array_h
   end interface
 
   interface acc_create
@@ -251,23 +237,9 @@
   end interface
 
   interface acc_pcreate
-subroutine acc_pcreate_32_h (a, len)
-  use iso_c_binding, only: c_int32_t
-  !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
-  type (*), dimension (*) :: a
-  integer (c_int32_t) len
-end subroutine
-
-subroutine acc_pcreate_64_h (a, len)
-  use iso_c_binding, only: c_int64_t
-  !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
-  type (*), dimension (*) :: a
-  integer (c_int64_t) len
-end subroutine
-
-subroutine acc_pcreate_array_h (a)
-  type (*), dimension (..), contiguous :: a
-  end subroutine
+procedure :: acc_present_or_create_32_h
+procedure :: acc_present_or_create_64_h
+procedure :: acc_present_or_create_array_h
   end interface
 
   interface acc_copyout
@@ -353,7 +325,7 @@
   ! acc_map_data: Only available in C/C++
   ! acc_unmap_data: Only available in C/C++
   ! acc_deviceptr: Only available in C/C++
-  ! acc_ostptr: Only available in C/C++
+  ! acc_hostptr: Only available in C/C++
 
   interface acc_is_present
 function acc_is_present_32_h (a, len)
diff --git libgomp/testsuite/libgomp.oacc-fortran/lib-32-1.f 
libgomp/testsuite/libgomp.oacc-fortran/lib-32-1.f
index 4606d77..177e4fb 100644
--- libgomp/testsuite/libgomp.oacc-fortran/lib-32-1.f
+++ libgomp/testsuite/libgomp.oacc-fortran/lib-32-1.f
@@ -20,8 +20,8 @@
 
   SHARED_MEM = ACC_IS_PRESENT (H)
 
-  CALL ACC_PRESENT_OR_CREATE (H)
-  IF (.NOT. ACC_IS_PRESENT (H)) CALL ABORT
+  CALL ACC_PRESENT_OR_CREATE (H, INT (SIZEOF (H), 4))
+  IF (.NOT. ACC_IS_PRESENT (H, INT (SIZEOF (H), 8))) CALL ABORT
 
 !$ACC PARALLEL LOOP DEFAULT (PRESENT)
   DO I = 1, N
@@ -48,8 +48,7 @@
  H(I) = I + 4
   END DO
 
-!  CALL ACC_PCREATE (H)
-  CALL ACC_PRESENT_OR_CREATE (H)
+  CALL ACC_PCREATE (H, INT (SIZEOF (H), 4))
 
 !$ACC PARALLEL 

Re: Implementing OpenACC's Fortran module

2017-05-24 Thread Jakub Jelinek
On Wed, May 24, 2017 at 01:34:50PM +0200, Thomas Schwinge wrote:
> Thus OK for trunk, as posted?

Ok.

Jakub


Re: Implementing OpenACC's Fortran module

2017-05-24 Thread Thomas Schwinge
Hi Jakub!

On Tue, 23 May 2017 13:12:00 +0200, Jakub Jelinek  wrote:
> On Mon, May 22, 2017 at 05:23:25PM +0200, Thomas Schwinge wrote:
> > --- libgomp/openacc_lib.h
> > +++ libgomp/openacc_lib.h
> > @@ -191,23 +191,9 @@
> >end interface
> >  
> >interface acc_pcopyin
> > -subroutine acc_pcopyin_32_h (a, len)
> > -  use iso_c_binding, only: c_int32_t
> > -  !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
> > -  type (*), dimension (*) :: a
> > -  integer (c_int32_t) len
> > -end subroutine
> > -
> > -subroutine acc_pcopyin_64_h (a, len)
> > -  use iso_c_binding, only: c_int64_t
> > -  !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
> > -  type (*), dimension (*) :: a
> > -  integer (c_int64_t) len
> > -end subroutine
> > -
> > -subroutine acc_pcopyin_array_h (a)
> > -  type (*), dimension (..), contiguous :: a
> > -  end subroutine
> > +procedure :: acc_present_or_copyin_32_h
> > +procedure :: acc_present_or_copyin_64_h
> > +procedure :: acc_present_or_copyin_array_h
> >end interface
> 
> My Fortran knowledge is limited

Same here.  ;-)

> does this actually provide
> the interfaces of those procedures (what arguments they have
> and other their properties)

This ("procedure" instead of "subroutine") is actually what "openacc.f90"
is using in the same context, and upon having inspected (already back in
April) the "-fdump-fortran-original" output for the new
"libgomp.oacc-fortran/lib-32-1.f" test case, this seemed to do the right
things.  And, comparing that to the "openacc.f90" case
("libgomp.oacc-fortran/lib-32-2.f" test case with "USE OPENACC"), the
only difference in "-fdump-fortran-original" output relevant to this
issue here are (expected) additional "USE-ASSOC(openacc)" attributes.

> or shall it instead use
> subroutine acc_present_or_copyin_32_h (a, len)
>   ...
> end subroutine
> etc. there?

Apparently not.  These "subroutine"s have already declared above (for
"acc_present_or_copyin" proper), and if declaring them again here, we
get:

Error: Symbol 'acc_present_or_copyin_32_h' at (1) already has an explicit 
interface
[...]


Thus OK for trunk, as posted?


Grüße
 Thomas


Re: Implementing OpenACC's Fortran module

2017-05-23 Thread Jakub Jelinek
On Mon, May 22, 2017 at 05:23:25PM +0200, Thomas Schwinge wrote:
> --- libgomp/openacc_lib.h
> +++ libgomp/openacc_lib.h
> @@ -191,23 +191,9 @@
>end interface
>  
>interface acc_pcopyin
> -subroutine acc_pcopyin_32_h (a, len)
> -  use iso_c_binding, only: c_int32_t
> -  !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
> -  type (*), dimension (*) :: a
> -  integer (c_int32_t) len
> -end subroutine
> -
> -subroutine acc_pcopyin_64_h (a, len)
> -  use iso_c_binding, only: c_int64_t
> -  !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
> -  type (*), dimension (*) :: a
> -  integer (c_int64_t) len
> -end subroutine
> -
> -subroutine acc_pcopyin_array_h (a)
> -  type (*), dimension (..), contiguous :: a
> -  end subroutine
> +procedure :: acc_present_or_copyin_32_h
> +procedure :: acc_present_or_copyin_64_h
> +procedure :: acc_present_or_copyin_array_h
>end interface

My Fortran knowledge is limited, does this actually provide
the interfaces of those procedures (what arguments they have
and other their properties), or shall it instead use
subroutine acc_present_or_copyin_32_h (a, len)
  ...
end subroutine
etc. there?

Jakub


Re: Implementing OpenACC's Fortran module

2017-05-22 Thread Thomas Schwinge
Hi!

On Thu, 13 Apr 2017 19:45:05 +0200, I wrote:
> On Fri, 10 Oct 2014 12:42:06 +0200, I wrote:
> > In the OpenACC Runtime Library, acc_pcopyin and acc_pcreate are to be
> > aliases for acc_present_or_copyin and acc_present_or_create,
> > respectively.
> > 
> > This is implemented in openacc.f90 as follows: [...]

> The following patch seems to do the right thing (that is, "divert" calls
> of "acc_pcopyin" to the existing "acc_present_or_copyin_*_h", and
> likewise for "acc_pcreate").  Is that the correct way of doing this?

Building on ,
OK to commit the following to trunk?

commit e5f5715556a30a0fff71243ad136d6ec29556f92
Author: Thomas Schwinge 
Date:   Wed Apr 19 21:12:33 2017 +0200

Fortran OpenACC "openacc_lib.h": acc_pcopyin, acc_pcreate

libgomp/
* openacc_lib.h (acc_pcopyin, acc_pcreate): Route to
acc_present_or_copyin and acc_present_or_create procedures,
respectively.
* testsuite/libgomp.oacc-fortran/lib-32-1.f: Exercise these, and
generally different variants of OpenACC Runtime Library functions.
* testsuite/libgomp.oacc-fortran/lib-32-2.f: Likewise.
---
 libgomp/openacc_lib.h | 42 ---
 libgomp/testsuite/libgomp.oacc-fortran/lib-32-1.f | 36 ---
 libgomp/testsuite/libgomp.oacc-fortran/lib-32-2.f | 26 +++---
 3 files changed, 35 insertions(+), 69 deletions(-)

diff --git libgomp/openacc_lib.h libgomp/openacc_lib.h
index 65f47a8..7818bd7 100644
--- libgomp/openacc_lib.h
+++ libgomp/openacc_lib.h
@@ -191,23 +191,9 @@
   end interface
 
   interface acc_pcopyin
-subroutine acc_pcopyin_32_h (a, len)
-  use iso_c_binding, only: c_int32_t
-  !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
-  type (*), dimension (*) :: a
-  integer (c_int32_t) len
-end subroutine
-
-subroutine acc_pcopyin_64_h (a, len)
-  use iso_c_binding, only: c_int64_t
-  !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
-  type (*), dimension (*) :: a
-  integer (c_int64_t) len
-end subroutine
-
-subroutine acc_pcopyin_array_h (a)
-  type (*), dimension (..), contiguous :: a
-  end subroutine
+procedure :: acc_present_or_copyin_32_h
+procedure :: acc_present_or_copyin_64_h
+procedure :: acc_present_or_copyin_array_h
   end interface
 
   interface acc_create
@@ -251,23 +237,9 @@
   end interface
 
   interface acc_pcreate
-subroutine acc_pcreate_32_h (a, len)
-  use iso_c_binding, only: c_int32_t
-  !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
-  type (*), dimension (*) :: a
-  integer (c_int32_t) len
-end subroutine
-
-subroutine acc_pcreate_64_h (a, len)
-  use iso_c_binding, only: c_int64_t
-  !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
-  type (*), dimension (*) :: a
-  integer (c_int64_t) len
-end subroutine
-
-subroutine acc_pcreate_array_h (a)
-  type (*), dimension (..), contiguous :: a
-  end subroutine
+procedure :: acc_present_or_create_32_h
+procedure :: acc_present_or_create_64_h
+procedure :: acc_present_or_create_array_h
   end interface
 
   interface acc_copyout
@@ -353,7 +325,7 @@
   ! acc_map_data: Only available in C/C++
   ! acc_unmap_data: Only available in C/C++
   ! acc_deviceptr: Only available in C/C++
-  ! acc_ostptr: Only available in C/C++
+  ! acc_hostptr: Only available in C/C++
 
   interface acc_is_present
 function acc_is_present_32_h (a, len)
diff --git libgomp/testsuite/libgomp.oacc-fortran/lib-32-1.f 
libgomp/testsuite/libgomp.oacc-fortran/lib-32-1.f
index 4606d77..177e4fb 100644
--- libgomp/testsuite/libgomp.oacc-fortran/lib-32-1.f
+++ libgomp/testsuite/libgomp.oacc-fortran/lib-32-1.f
@@ -20,8 +20,8 @@
 
   SHARED_MEM = ACC_IS_PRESENT (H)
 
-  CALL ACC_PRESENT_OR_CREATE (H)
-  IF (.NOT. ACC_IS_PRESENT (H)) CALL ABORT
+  CALL ACC_PRESENT_OR_CREATE (H, INT (SIZEOF (H), 4))
+  IF (.NOT. ACC_IS_PRESENT (H, INT (SIZEOF (H), 8))) CALL ABORT
 
 !$ACC PARALLEL LOOP DEFAULT (PRESENT)
   DO I = 1, N
@@ -48,8 +48,7 @@
  H(I) = I + 4
   END DO
 
-!  CALL ACC_PCREATE (H)
-  CALL ACC_PRESENT_OR_CREATE (H)
+  CALL ACC_PCREATE (H, INT (SIZEOF (H), 4))
 
 !$ACC PARALLEL LOOP DEFAULT (PRESENT)
   DO I = 1, N
@@ -63,7 +62,7 @@
  H(I) = I + 6
   END DO
 
-  CALL ACC_PRESENT_OR_COPYIN (H)
+  CALL ACC_PRESENT_OR_COPYIN (H, INT (SIZEOF (H), 8))
 
 !$ACC PARALLEL LOOP DEFAULT (PRESENT)
   DO I = 1, N
@@ -77,8 +76,7 @@
  H(I) = I + 8
   END DO
 
-!  CALL ACC_PCOPYIN (H)
-  CALL ACC_PRESENT_OR_COPYIN (H)
+  CALL ACC_PCOPYIN (H, INT (SIZEOF (H), 4))
 
 !$ACC PARALLEL LOOP DEFAULT