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]

Re: Repeated use of the OpenACC routine directive


On 08/16/2016 06:05 PM, Thomas Schwinge wrote:
> On Mon, 01 Aug 2016 17:51:24 +0200, I wrote:
>> > We found that it's not correct that we currently unconditionally diagnose
>> > an error for repeated use of the OpenACC routine directive on one
>> > function/declaration.  (For reference, it is also permissible for an
>> > "ordinary" function to have several declarations plus a definition, as
>> > long as these are compatible.)  This is, the following shall be valid:
>> > 
>> >     #pragma acc routine worker
>> >     void f(void)
>> >     {
>> >     }
>> >     #pragma acc routine (f) worker
>> >     #pragma acc routine worker
>> >     extern void f(void);
>> > 
>> > [...]

Because of the different scoping rules, I don't think it makes sense to
allow users to repeat acc routine directives in fortran. Consequently, I
couldn't create a 1:1 of your c tests to fortran. However, after
inspecting your patch I did find some areas where fortran had
insufficient test coverage, specifically with routines inside interface
blocks and that warning for unutilized parallelism.

I've applied this patch, which addresses the acc routine test coverage
deficiencies in fortran, to gomp-4_0-branch.

Cesar
2016-08-19  Cesar Philippidis  <cesar@codesourcery.com>

	gcc/testsuite/
	* gfortran.dg/goacc/routine-8.f90: New test.
	* gfortran.dg/goacc/routine-level-of-parallelism-1.f90: New test.


diff --git a/gcc/testsuite/gfortran.dg/goacc/routine-8.f90 b/gcc/testsuite/gfortran.dg/goacc/routine-8.f90
new file mode 100644
index 0000000..c903915
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/routine-8.f90
@@ -0,0 +1,32 @@
+! Test ACC ROUTINE inside an interface block.
+
+program main
+  interface
+     function s_1 (a)
+       integer a
+       !$acc routine
+     end function s_1
+  end interface
+
+  interface
+     function s_2 (a)
+       integer a
+       !$acc routine seq
+     end function s_2
+  end interface
+
+  interface
+     function s_3 (a)
+       integer a
+       !$acc routine (s_3) ! { dg-error "Only the ..ACC ROUTINE form without list is allowed in interface block" }
+     end function s_3
+  end interface
+
+  interface
+     function s_4 (a)
+       integer a
+         !$acc routine (s_4) seq ! { dg-error "Only the ..ACC ROUTINE form without list is allowed in interface block" }
+     end function s_4
+  end interface
+end program main
+
diff --git a/gcc/testsuite/gfortran.dg/goacc/routine-level-of-parallelism-1.f90 b/gcc/testsuite/gfortran.dg/goacc/routine-level-of-parallelism-1.f90
new file mode 100644
index 0000000..364a058
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/routine-level-of-parallelism-1.f90
@@ -0,0 +1,74 @@
+! Test various aspects of clauses specifying compatible levels of
+! parallelism with the OpenACC routine directive.  The Fortran counterpart is
+! c-c++-common/goacc/routine-level-of-parallelism-2.c
+
+subroutine g_1 ! { dg-warning "region is gang partitioned but does not contain gang partitioned code" }
+  !$acc routine gang
+! { dg-bogus "region is worker partitioned but does not contain worker partitioned code" "worker partitioned" { xfail *-*-* } 5 }
+! { dg-bogus "region is vector partitioned but does not contain vector partitioned code" "worker partitioned" { xfail *-*-* } 5 }
+end subroutine g_1
+
+subroutine s_1_2a
+  !$acc routine
+end subroutine s_1_2a
+
+subroutine s_1_2b
+  !$acc routine seq
+end subroutine s_1_2b
+
+subroutine s_1_2c
+  !$acc routine (s_1_2c)
+end subroutine s_1_2c
+
+subroutine s_1_2d
+  !$acc routine (s_1_2d) seq
+end subroutine s_1_2d
+
+module s_2
+contains
+  subroutine s_2_1a
+    !$acc routine
+  end subroutine s_2_1a
+
+  subroutine s_2_1b
+    !$acc routine seq
+  end subroutine s_2_1b
+
+  subroutine s_2_1c
+    !$acc routine (s_2_1c)
+  end subroutine s_2_1c
+
+  subroutine s_2_1d
+    !$acc routine (s_2_1d) seq
+  end subroutine s_2_1d
+end module s_2
+
+subroutine test
+  external g_1, w_1, v_1
+  external s_1_1, s_1_2
+
+  interface
+     function s_3_1a (a)
+       integer a
+       !$acc routine
+     end function s_3_1a
+  end interface
+
+  interface
+     function s_3_1b (a)
+       integer a
+       !$acc routine seq
+     end function s_3_1b
+  end interface
+
+  !$acc routine(g_1) gang
+
+  !$acc routine(w_1) worker
+
+  !$acc routine(v_1) worker
+
+  ! Also test the implicit seq clause.
+
+  !$acc routine (s_1_1) seq
+
+end subroutine test

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