+2019-03-21 Thomas Schwinge <thomas@codesourcery.com>
+
+ PR fortran/72741
+ * module.c (verify_OACC_ROUTINE_LOP_NONE): New function.
+ (enum ab_attribute): Add AB_OACC_ROUTINE_LOP_GANG,
+ AB_OACC_ROUTINE_LOP_WORKER, AB_OACC_ROUTINE_LOP_VECTOR,
+ AB_OACC_ROUTINE_LOP_SEQ.
+ (attr_bits): Add these.
+ (mio_symbol_attribute): Handle these.
+
2019-03-20 Janus Weil <janus@gcc.gnu.org>
PR fortran/71861
AB_OACC_DECLARE_COPYIN, AB_OACC_DECLARE_DEVICEPTR,
AB_OACC_DECLARE_DEVICE_RESIDENT, AB_OACC_DECLARE_LINK,
AB_OMP_DECLARE_TARGET_LINK, AB_PDT_KIND, AB_PDT_LEN, AB_PDT_TYPE,
- AB_PDT_TEMPLATE, AB_PDT_ARRAY, AB_PDT_STRING
+ AB_PDT_TEMPLATE, AB_PDT_ARRAY, AB_PDT_STRING,
+ AB_OACC_ROUTINE_LOP_GANG, AB_OACC_ROUTINE_LOP_WORKER,
+ AB_OACC_ROUTINE_LOP_VECTOR, AB_OACC_ROUTINE_LOP_SEQ
};
static const mstring attr_bits[] =
minit ("PDT_TEMPLATE", AB_PDT_TEMPLATE),
minit ("PDT_ARRAY", AB_PDT_ARRAY),
minit ("PDT_STRING", AB_PDT_STRING),
+ minit ("OACC_ROUTINE_LOP_GANG", AB_OACC_ROUTINE_LOP_GANG),
+ minit ("OACC_ROUTINE_LOP_WORKER", AB_OACC_ROUTINE_LOP_WORKER),
+ minit ("OACC_ROUTINE_LOP_VECTOR", AB_OACC_ROUTINE_LOP_VECTOR),
+ minit ("OACC_ROUTINE_LOP_SEQ", AB_OACC_ROUTINE_LOP_SEQ),
minit (NULL, -1)
};
DECL_MIO_NAME (inquiry_type)
#undef DECL_MIO_NAME
+/* Verify OACC_ROUTINE_LOP_NONE. */
+
+static void
+verify_OACC_ROUTINE_LOP_NONE (enum oacc_routine_lop lop)
+{
+ if (lop != OACC_ROUTINE_LOP_NONE)
+ bad_module ("Unsupported: multiple OpenACC 'routine' levels of parallelism");
+}
+
/* Symbol attributes are stored in list with the first three elements
being the enumerated fields, while the remaining elements (if any)
indicate the individual attribute bits. The access field is not
MIO_NAME (ab_attribute) (AB_PDT_ARRAY, attr_bits);
if (attr->pdt_string)
MIO_NAME (ab_attribute) (AB_PDT_STRING, attr_bits);
+ switch (attr->oacc_routine_lop)
+ {
+ case OACC_ROUTINE_LOP_NONE:
+ /* This is the default anyway, and for maintaining compatibility with
+ the current MOD_VERSION, we're not emitting anything in that
+ case. */
+ break;
+ case OACC_ROUTINE_LOP_GANG:
+ MIO_NAME (ab_attribute) (AB_OACC_ROUTINE_LOP_GANG, attr_bits);
+ break;
+ case OACC_ROUTINE_LOP_WORKER:
+ MIO_NAME (ab_attribute) (AB_OACC_ROUTINE_LOP_WORKER, attr_bits);
+ break;
+ case OACC_ROUTINE_LOP_VECTOR:
+ MIO_NAME (ab_attribute) (AB_OACC_ROUTINE_LOP_VECTOR, attr_bits);
+ break;
+ case OACC_ROUTINE_LOP_SEQ:
+ MIO_NAME (ab_attribute) (AB_OACC_ROUTINE_LOP_SEQ, attr_bits);
+ break;
+ case OACC_ROUTINE_LOP_ERROR:
+ /* ... intentionally omitted here; it's only unsed internally. */
+ default:
+ gcc_unreachable ();
+ }
mio_rparen ();
case AB_PDT_STRING:
attr->pdt_string = 1;
break;
+ case AB_OACC_ROUTINE_LOP_GANG:
+ verify_OACC_ROUTINE_LOP_NONE (attr->oacc_routine_lop);
+ attr->oacc_routine_lop = OACC_ROUTINE_LOP_GANG;
+ break;
+ case AB_OACC_ROUTINE_LOP_WORKER:
+ verify_OACC_ROUTINE_LOP_NONE (attr->oacc_routine_lop);
+ attr->oacc_routine_lop = OACC_ROUTINE_LOP_WORKER;
+ break;
+ case AB_OACC_ROUTINE_LOP_VECTOR:
+ verify_OACC_ROUTINE_LOP_NONE (attr->oacc_routine_lop);
+ attr->oacc_routine_lop = OACC_ROUTINE_LOP_VECTOR;
+ break;
+ case AB_OACC_ROUTINE_LOP_SEQ:
+ verify_OACC_ROUTINE_LOP_NONE (attr->oacc_routine_lop);
+ attr->oacc_routine_lop = OACC_ROUTINE_LOP_SEQ;
+ break;
}
}
}
2019-03-21 Thomas Schwinge <thomas@codesourcery.com>
+ PR fortran/72741
+ * gfortran.dg/goacc/routine-module-1.f90: New file.
+ * gfortran.dg/goacc/routine-module-2.f90: Likewise.
+ * gfortran.dg/goacc/routine-module-mod-1.f90: Likewise.
+
* gfortran.dg/goacc/goacc.exp (dg-compile-aux-modules): New proc.
PR fortran/56408
--- /dev/null
+! Valid use of routines defined inside a Fortran module.
+
+! { dg-compile-aux-modules "routine-module-mod-1.f90" }
+! { dg-additional-options "-fopt-info-optimized-omp" }
+
+program main
+ use routine_module_mod_1
+ implicit none
+
+ integer :: i
+
+ call pl_1
+
+ !$acc parallel loop seq ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+ do i = 1, 10
+ call s_1 ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+ call s_2 ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+ call g_1 ! { dg-message "optimized: assigned OpenACC gang worker vector loop parallelism" }
+ call w_1 ! { dg-message "optimized: assigned OpenACC worker vector loop parallelism" }
+ call v_1 ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+ end do
+ !$acc end parallel loop
+
+ !$acc parallel loop gang ! { dg-message "optimized: assigned OpenACC gang loop parallelism" }
+ do i = 1, 10
+ call s_1 ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+ call s_2 ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+ call w_1 ! { dg-message "optimized: assigned OpenACC worker vector loop parallelism" }
+ call v_1 ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+ end do
+ !$acc end parallel loop
+
+ !$acc parallel loop worker ! { dg-message "optimized: assigned OpenACC worker loop parallelism" }
+ do i = 1, 10
+ call s_1 ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+ call s_2 ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+ call v_1 ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+ end do
+ !$acc end parallel loop
+
+ !$acc parallel loop vector ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+ do i = 1, 10
+ call s_1 ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+ call s_2 ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+ end do
+ !$acc end parallel loop
+end program main
--- /dev/null
+! Invalid use of routines defined inside a Fortran module.
+
+! { dg-compile-aux-modules "routine-module-mod-1.f90" }
+
+program main
+ use routine_module_mod_1
+ implicit none
+
+ integer :: i
+
+ !$acc parallel loop gang
+ do i = 1, 10
+ call g_1 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" }
+ end do
+ !$acc end parallel loop
+
+ !$acc parallel loop worker
+ do i = 1, 10
+ call g_1 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" }
+ call w_1 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" }
+ end do
+ !$acc end parallel loop
+
+ !$acc parallel loop vector
+ do i = 1, 10
+ call g_1 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" }
+ call w_1 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" }
+ call v_1 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" }
+ end do
+ !$acc end parallel loop
+end program main
--- /dev/null
+! OpenACC 'routine' directives inside a Fortran module.
+
+! { dg-additional-options "-fopt-info-optimized-omp" }
+
+module routine_module_mod_1
+contains
+ subroutine s_1
+ implicit none
+ !$acc routine
+
+ integer :: i
+
+ !$acc loop ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+ ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
+ do i = 1, 3
+ end do
+ end subroutine s_1
+
+ subroutine s_2
+ implicit none
+ !$acc routine seq
+
+ integer :: i
+
+ !$acc loop ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+ ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
+ do i = 1, 3
+ end do
+ end subroutine s_2
+
+ subroutine v_1
+ implicit none
+ !$acc routine vector
+
+ integer :: i
+
+ !$acc loop ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+ do i = 1, 3
+ end do
+ end subroutine v_1
+
+ subroutine w_1
+ implicit none
+ !$acc routine worker
+
+ integer :: i
+
+ !$acc loop ! { dg-message "optimized: assigned OpenACC worker vector loop parallelism" }
+ do i = 1, 3
+ end do
+ end subroutine w_1
+
+ subroutine g_1
+ implicit none
+ !$acc routine gang
+
+ integer :: i
+
+ !$acc loop ! { dg-message "optimized: assigned OpenACC gang vector loop parallelism" }
+ do i = 1, 3
+ end do
+ end subroutine g_1
+
+ subroutine pl_1
+ implicit none
+
+ integer :: i
+
+ !$acc parallel loop ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+ ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
+ do i = 1, 3
+ call s_1 ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+ call s_2 ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+ call v_1 ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+ call w_1 ! { dg-message "optimized: assigned OpenACC worker vector loop parallelism" }
+ call g_1 ! { dg-message "optimized: assigned OpenACC gang worker vector loop parallelism" }
+ end do
+ end subroutine pl_1
+end module routine_module_mod_1