@@ -1,3 +1,8 @@
+2016-06-30 Thomas Schwinge <thomas@codesourcery.com>
+
+ * config/nvptx/nvptx.c (nvptx_goacc_validate_dims): Only trigger
+ the "avoid offloading" mechanism for -O2 and higher.
+
2016-06-10 James Norris <jnorris@codesourcery.com>
Backport from mainline r236098.
@@ -4152,8 +4152,13 @@ nvptx_goacc_validate_dims (tree decl, int dims[], int fn_level)
/* Detect if a function is unsuitable for offloading. */
if (!flag_offload_force && decl)
{
+ /* Trigger the "avoid offloading" mechanism if a OpenACC kernels
+ construct could not be parallelized, but only do that for -O2 and
+ higher, as otherwise we're not expecting any parallelization to
+ happen. */
tree oacc_function_attr = get_oacc_fn_attrib (decl);
- if (oacc_function_attr
+ if (optimize >= 2
+ && oacc_function_attr
&& oacc_fn_attrib_kernels_p (oacc_function_attr))
{
bool avoid_offloading_p = true;
@@ -4167,14 +4172,10 @@ nvptx_goacc_validate_dims (tree decl, int dims[], int fn_level)
}
if (avoid_offloading_p)
{
- /* OpenACC kernels constructs will never be parallelized for
- optimization levels smaller than -O2; avoid the diagnostic in
- this case. */
- if (optimize >= 2)
- warning_at (DECL_SOURCE_LOCATION (decl), 0,
- "OpenACC kernels construct will be executed "
- "sequentially; will by default avoid offloading "
- "to prevent data copy penalty");
+ warning_at (DECL_SOURCE_LOCATION (decl), 0,
+ "OpenACC kernels construct will be executed"
+ " sequentially; will by default avoid offloading to"
+ " prevent data copy penalty");
DECL_ATTRIBUTES (decl)
= tree_cons (get_identifier ("omp avoid offloading"),
NULL_TREE, DECL_ATTRIBUTES (decl));
@@ -1,3 +1,9 @@
+2016-06-30 Thomas Schwinge <thomas@codesourcery.com>
+
+ * testsuite/libgomp.oacc-c-c++-common/avoid-offloading-1.c:
+ Update.
+ * testsuite/libgomp.oacc-fortran/avoid-offloading-1.f: Update.
+
2016-06-10 Thomas Schwinge <thomas@codesourcery.com>
PR middle-end/71373
@@ -15,7 +15,15 @@ int main(void)
if (x != 33)
__builtin_abort();
-#if defined ACC_DEVICE_TYPE_host || defined ACC_DEVICE_TYPE_nvidia
+#if defined ACC_DEVICE_TYPE_nvidia
+# if !defined __OPTIMIZE__
+ if (y != 0)
+ __builtin_abort();
+# else
+ if (y != 1)
+ __builtin_abort();
+# endif
+#elif defined ACC_DEVICE_TYPE_host
if (y != 1)
__builtin_abort();
#else
@@ -4,6 +4,10 @@
! { dg-additional-options "-cpp" }
! The warning is only triggered for -O2 and higher.
! { dg-xfail-if "n/a" { openacc_nvidia_accel_selected } { "-O0" "-O1" } { "" } }
+! As __OPTIMIZE__ is defined for -O1 and higher, we don't have an (easy) way to
+! distinguish -O1 (where we will offload) from -O2 (where we won't offload), so
+! for -O1 testing, we expect to abort.
+! { dg-xfail-run-if "" { openacc_nvidia_accel_selected } { "-O1" } { "" } }
IMPLICIT NONE
INCLUDE "openacc_lib.h"
@@ -19,7 +23,13 @@
!$ACC END DATA
IF (X .NE. 33) CALL ABORT
-#if defined ACC_DEVICE_TYPE_host || defined ACC_DEVICE_TYPE_nvidia
+#if defined ACC_DEVICE_TYPE_nvidia
+# if !defined __OPTIMIZE__
+ IF (Y) CALL ABORT
+# else
+ IF (.NOT. Y) CALL ABORT
+# endif
+#elif defined ACC_DEVICE_TYPE_host
IF (.NOT. Y) CALL ABORT
#else
# error Not ported to this ACC_DEVICE_TYPE