diff mbox

[gomp4] New test loop independent clause

Message ID 55A55E89.9020601@codesourcery.com
State New
Headers show

Commit Message

James Norris July 14, 2015, 7:10 p.m. UTC
Hi,

The attached adds testing for the independent clause
with the loop directive in Fortran.

Committed to gomp-4_0-branch.

Jim

Comments

Thomas Schwinge July 15, 2015, 9:28 a.m. UTC | #1
Hi!

On Tue, 14 Jul 2015 14:10:01 -0500, James Norris <jnorris@codesourcery.com> wrote:
> The attached adds testing for the independent clause
> with the loop directive in Fortran.
> 
> Committed to gomp-4_0-branch.

> --- /dev/null
> +++ b/libgomp/testsuite/libgomp.oacc-fortran/kernels-independent.f90

Thanks!  I had a look, and per -O2 -ftree-parallelize-loops=32
-fdump-tree-parloops_oacc_kernels-all -fdump-tree-optimized tree dumps,
indeed I see the anticipated »SUCCESS: may be parallelized« as well as
»#pragma omp target oacc_parallel num_gangs(32)« markers, so I think this
test case is being parallelized (as well as it executes correctly).  So,
I'm correct in assuming that this is not showcasing the Fortran issue
that Tom raised yesterday?  Anyway, assuming that it adds value to the
current set of test cases, should this also be made a compiler test case,
with dg-final directives checking for the anticipated properties, similar
to gcc/testsuite/gfortran.dg/goacc/kernels-loop.f95, for example?

> @@ -0,0 +1,43 @@
> +! { dg-do run } */
> +! { dg-additional-options "-cpp" }
> +! { dg-additional-options "-ftree-parallelize-loops=32" }
> +
> +#define N (1024 * 512)
> +
> +subroutine foo (a,  b,  c)
> +  integer, parameter :: n = N
> +  integer, dimension (n) :: a
> +  integer, dimension (n) :: b
> +  integer, dimension (n) :: c
> +  integer i, ii
> +
> +  do i = 1, n
> +    a(i) = i * 2;
> +  end do
> +
> +  do i = 1, n
> +    b(i) = i * 4;
> +  end do
> +
> +  !$acc kernels copyin (a(1:n), b(1:n)) copyout (c(1:n))
> +    !$acc loop independent
> +    do ii = 1, n
> +      c(ii) = a(ii) + b(ii)
> +    end do
> +  !$acc end kernels
> +
> +  do i = 1, n
> +    if (c(i) .ne. a(i) + b(i)) call abort
> +  end do
> +
> +end subroutine
> +
> +program main
> +  integer, parameter :: n = N
> +  integer :: a(n)
> +  integer :: b(n)
> +  integer :: c(n)
> +
> +  call foo (a, b, c)
> +
> +end program main


Grüße,
 Thomas
Tom de Vries July 15, 2015, 10:43 a.m. UTC | #2
On 15/07/15 11:28, Thomas Schwinge wrote:
> Hi!
>
> On Tue, 14 Jul 2015 14:10:01 -0500, James Norris <jnorris@codesourcery.com> wrote:
>> The attached adds testing for the independent clause
>> with the loop directive in Fortran.
>>
>> Committed to gomp-4_0-branch.
>
>> --- /dev/null
>> +++ b/libgomp/testsuite/libgomp.oacc-fortran/kernels-independent.f90
>
> Thanks!  I had a look, and per -O2 -ftree-parallelize-loops=32
> -fdump-tree-parloops_oacc_kernels-all -fdump-tree-optimized tree dumps,
> indeed I see the anticipated »SUCCESS: may be parallelized« as well as
> »#pragma omp target oacc_parallel num_gangs(32)« markers, so I think this
> test case is being parallelized (as well as it executes correctly).  So,
> I'm correct in assuming that this is not showcasing the Fortran issue
> that Tom raised yesterday?

The issue I remember raising is: PR66873 - fortran variant of outer-1.c 
not parallelized by autopar.

I'm not sure if I mentioned it at the meeting, but marking the outer 
loop of that example as independent does not result in parallelization 
either. So that's something to be investigated.

Thanks,
- Tom

> Anyway, assuming that it adds value to the
> current set of test cases, should this also be made a compiler test case,
> with dg-final directives checking for the anticipated properties, similar
> to gcc/testsuite/gfortran.dg/goacc/kernels-loop.f95, for example?
>
>> @@ -0,0 +1,43 @@
>> +! { dg-do run } */
>> +! { dg-additional-options "-cpp" }
>> +! { dg-additional-options "-ftree-parallelize-loops=32" }
>> +
>> +#define N (1024 * 512)
>> +
>> +subroutine foo (a,  b,  c)
>> +  integer, parameter :: n = N
>> +  integer, dimension (n) :: a
>> +  integer, dimension (n) :: b
>> +  integer, dimension (n) :: c
>> +  integer i, ii
>> +
>> +  do i = 1, n
>> +    a(i) = i * 2;
>> +  end do
>> +
>> +  do i = 1, n
>> +    b(i) = i * 4;
>> +  end do
>> +
>> +  !$acc kernels copyin (a(1:n), b(1:n)) copyout (c(1:n))
>> +    !$acc loop independent
>> +    do ii = 1, n
>> +      c(ii) = a(ii) + b(ii)
>> +    end do
>> +  !$acc end kernels
>> +
>> +  do i = 1, n
>> +    if (c(i) .ne. a(i) + b(i)) call abort
>> +  end do
>> +
>> +end subroutine
>> +
>> +program main
>> +  integer, parameter :: n = N
>> +  integer :: a(n)
>> +  integer :: b(n)
>> +  integer :: c(n)
>> +
>> +  call foo (a, b, c)
>> +
>> +end program main
>
>
> Grüße,
>   Thomas
>
Thomas Schwinge July 15, 2015, 12:03 p.m. UTC | #3
Hi Tom!

On Wed, 15 Jul 2015 12:43:05 +0200, Tom de Vries <Tom_deVries@mentor.com> wrote:
> On 15/07/15 11:28, Thomas Schwinge wrote:
> > On Tue, 14 Jul 2015 14:10:01 -0500, James Norris <jnorris@codesourcery.com> wrote:
> >> The attached adds testing for the independent clause
> >> with the loop directive in Fortran.
> >>
> >> Committed to gomp-4_0-branch.
> >
> >> --- /dev/null
> >> +++ b/libgomp/testsuite/libgomp.oacc-fortran/kernels-independent.f90
> >
> > Thanks!  I had a look, and per -O2 -ftree-parallelize-loops=32
> > -fdump-tree-parloops_oacc_kernels-all -fdump-tree-optimized tree dumps,
> > indeed I see the anticipated »SUCCESS: may be parallelized« as well as
> > »#pragma omp target oacc_parallel num_gangs(32)« markers, so I think this
> > test case is being parallelized (as well as it executes correctly).  So,
> > I'm correct in assuming that this is not showcasing the Fortran issue
> > that Tom raised yesterday?
> 
> The issue I remember raising is: PR66873 - fortran variant of outer-1.c 
> not parallelized by autopar.

Ah, I mixed that up, sorry.


Anyway, do we want a compiler test case additional to thie libgomp
execution test?

> > Anyway, assuming that it adds value to the
> > current set of test cases, should this also be made a compiler test case,
> > with dg-final directives checking for the anticipated properties, similar
> > to gcc/testsuite/gfortran.dg/goacc/kernels-loop.f95, for example?
> >
> >> @@ -0,0 +1,43 @@
> >> +! { dg-do run } */
> >> +! { dg-additional-options "-cpp" }
> >> +! { dg-additional-options "-ftree-parallelize-loops=32" }
> >> +
> >> +#define N (1024 * 512)
> >> +
> >> +subroutine foo (a,  b,  c)
> >> +  integer, parameter :: n = N
> >> +  integer, dimension (n) :: a
> >> +  integer, dimension (n) :: b
> >> +  integer, dimension (n) :: c
> >> +  integer i, ii
> >> +
> >> +  do i = 1, n
> >> +    a(i) = i * 2;
> >> +  end do
> >> +
> >> +  do i = 1, n
> >> +    b(i) = i * 4;
> >> +  end do
> >> +
> >> +  !$acc kernels copyin (a(1:n), b(1:n)) copyout (c(1:n))
> >> +    !$acc loop independent
> >> +    do ii = 1, n
> >> +      c(ii) = a(ii) + b(ii)
> >> +    end do
> >> +  !$acc end kernels
> >> +
> >> +  do i = 1, n
> >> +    if (c(i) .ne. a(i) + b(i)) call abort
> >> +  end do
> >> +
> >> +end subroutine
> >> +
> >> +program main
> >> +  integer, parameter :: n = N
> >> +  integer :: a(n)
> >> +  integer :: b(n)
> >> +  integer :: c(n)
> >> +
> >> +  call foo (a, b, c)
> >> +
> >> +end program main


Grüße,
 Thomas
Tom de Vries July 15, 2015, 1:43 p.m. UTC | #4
On 15/07/15 14:03, Thomas Schwinge wrote:
> Hi Tom!
>
> On Wed, 15 Jul 2015 12:43:05 +0200, Tom de Vries <Tom_deVries@mentor.com> wrote:
>> On 15/07/15 11:28, Thomas Schwinge wrote:
>>> On Tue, 14 Jul 2015 14:10:01 -0500, James Norris <jnorris@codesourcery.com> wrote:
>>>> The attached adds testing for the independent clause
>>>> with the loop directive in Fortran.
>>>>
>>>> Committed to gomp-4_0-branch.
>>>
>>>> --- /dev/null
>>>> +++ b/libgomp/testsuite/libgomp.oacc-fortran/kernels-independent.f90
>>>
>>> Thanks!  I had a look, and per -O2 -ftree-parallelize-loops=32
>>> -fdump-tree-parloops_oacc_kernels-all -fdump-tree-optimized tree dumps,
>>> indeed I see the anticipated »SUCCESS: may be parallelized« as well as
>>> »#pragma omp target oacc_parallel num_gangs(32)« markers, so I think this
>>> test case is being parallelized (as well as it executes correctly).  So,
>>> I'm correct in assuming that this is not showcasing the Fortran issue
>>> that Tom raised yesterday?
>>
>> The issue I remember raising is: PR66873 - fortran variant of outer-1.c
>> not parallelized by autopar.
>
> Ah, I mixed that up, sorry.
>
>
> Anyway, do we want a compiler test case additional to thie libgomp
> execution test?
>

The important thing is to check in C and Fortran for 'SUCCESS: may be 
parallelized, marked independent'.

So I think we want a fortran variant of 
gcc/testsuite/c-c++-common/goacc/kernels-independent.c, in other words, 
a independent clause variant of of 
gcc/testsuite/gfortran.dg/goacc/kernels-loop.f95

Both gcc/testsuite/gfortran.dg/goacc/kernels-loop.f95 and 
gcc/testsuite/c-c++-common/goacc/kernels-loop.c have libgomp 
counterparts, there's no reason to have libgomp counterparts for the 
respective independent
clause variants.

Thanks,
- Tom

>>> Anyway, assuming that it adds value to the
>>> current set of test cases, should this also be made a compiler test case,
>>> with dg-final directives checking for the anticipated properties, similar
>>> to gcc/testsuite/gfortran.dg/goacc/kernels-loop.f95, for example?
>>>
>>>> @@ -0,0 +1,43 @@
>>>> +! { dg-do run } */
>>>> +! { dg-additional-options "-cpp" }
>>>> +! { dg-additional-options "-ftree-parallelize-loops=32" }
>>>> +
>>>> +#define N (1024 * 512)
>>>> +
>>>> +subroutine foo (a,  b,  c)
>>>> +  integer, parameter :: n = N
>>>> +  integer, dimension (n) :: a
>>>> +  integer, dimension (n) :: b
>>>> +  integer, dimension (n) :: c
>>>> +  integer i, ii
>>>> +
>>>> +  do i = 1, n
>>>> +    a(i) = i * 2;
>>>> +  end do
>>>> +
>>>> +  do i = 1, n
>>>> +    b(i) = i * 4;
>>>> +  end do
>>>> +
>>>> +  !$acc kernels copyin (a(1:n), b(1:n)) copyout (c(1:n))
>>>> +    !$acc loop independent
>>>> +    do ii = 1, n
>>>> +      c(ii) = a(ii) + b(ii)
>>>> +    end do
>>>> +  !$acc end kernels
>>>> +
>>>> +  do i = 1, n
>>>> +    if (c(i) .ne. a(i) + b(i)) call abort
>>>> +  end do
>>>> +
>>>> +end subroutine
>>>> +
>>>> +program main
>>>> +  integer, parameter :: n = N
>>>> +  integer :: a(n)
>>>> +  integer :: b(n)
>>>> +  integer :: c(n)
>>>> +
>>>> +  call foo (a, b, c)
>>>> +
>>>> +end program main
>
>
> Grüße,
>   Thomas
>
diff mbox

Patch

diff --git a/libgomp/testsuite/libgomp.oacc-fortran/kernels-independent.f90 b/libgomp/testsuite/libgomp.oacc-fortran/kernels-independent.f90
new file mode 100644
index 0000000..9f17308
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/kernels-independent.f90
@@ -0,0 +1,43 @@ 
+! { dg-do run } */
+! { dg-additional-options "-cpp" }
+! { dg-additional-options "-ftree-parallelize-loops=32" }
+
+#define N (1024 * 512)
+
+subroutine foo (a,  b,  c)
+  integer, parameter :: n = N
+  integer, dimension (n) :: a
+  integer, dimension (n) :: b
+  integer, dimension (n) :: c
+  integer i, ii
+
+  do i = 1, n
+    a(i) = i * 2;
+  end do
+
+  do i = 1, n
+    b(i) = i * 4;
+  end do
+
+  !$acc kernels copyin (a(1:n), b(1:n)) copyout (c(1:n))
+    !$acc loop independent
+    do ii = 1, n
+      c(ii) = a(ii) + b(ii)
+    end do
+  !$acc end kernels
+
+  do i = 1, n
+    if (c(i) .ne. a(i) + b(i)) call abort
+  end do
+
+end subroutine
+
+program main
+  integer, parameter :: n = N
+  integer :: a(n)
+  integer :: b(n)
+  integer :: c(n)
+
+  call foo (a, b, c)
+
+end program main