aboutsummaryrefslogtreecommitdiff
path: root/gcc/omp-low.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2015-11-05 13:50:13 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2015-11-05 13:50:13 +0000
commitbd7519757549bb0f61433767be4587d1d287fbae (patch)
tree7e0c36ef8da7959fa24be13c6ac216e007bdfb80 /gcc/omp-low.c
parent337d2167ccf01c028e993852f6d3a4681a021505 (diff)
downloadgcc-bd7519757549bb0f61433767be4587d1d287fbae.zip
gcc-bd7519757549bb0f61433767be4587d1d287fbae.tar.gz
gcc-bd7519757549bb0f61433767be4587d1d287fbae.tar.bz2
target.def (goacc.dim_limit): New hook.
* target.def (goacc.dim_limit): New hook. * targhooks.h (default_goacc_dim_limit): Declare. * doc/tm.texi.in (TARGET_GOACC_DIM_LIMIT): Add. * doc/tm.texi: Rebuilt. * omp-low.h (get_oacc_fn_dim_size, get_oacc_ifn_dim_arg): Declare. * omp-low.c (get_oacc_fn_dim_size, get_oacc_ifn_dim_arg): New. (default_goacc_dim_limit): New. * config/nvptx/nvptx.c (PTX_VECTOR_LENGTH, PTX_WORKER_LENGTH): New. (nvptx_goacc_dim_limit) New. (TARGET_GOACC_DIM_LIMIT): Override. * tree-vrp.c: Include omp-low.h, target.h. (extract_range_basic): Add handling for IFN_GOACC_DIM_SIZE & IFN_GOACC_DIM_POS. From-SVN: r229809
Diffstat (limited to 'gcc/omp-low.c')
-rw-r--r--gcc/omp-low.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index ac88fa5..b72c3dd 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -12096,6 +12096,41 @@ get_oacc_fn_attrib (tree fn)
return lookup_attribute (OACC_FN_ATTRIB, DECL_ATTRIBUTES (fn));
}
+/* Extract an oacc execution dimension from FN. FN must be an
+ offloaded function or routine that has already had its execution
+ dimensions lowered to the target-specific values. */
+
+int
+get_oacc_fn_dim_size (tree fn, int axis)
+{
+ tree attrs = get_oacc_fn_attrib (fn);
+
+ gcc_assert (axis < GOMP_DIM_MAX);
+
+ tree dims = TREE_VALUE (attrs);
+ while (axis--)
+ dims = TREE_CHAIN (dims);
+
+ int size = TREE_INT_CST_LOW (TREE_VALUE (dims));
+
+ return size;
+}
+
+/* Extract the dimension axis from an IFN_GOACC_DIM_POS or
+ IFN_GOACC_DIM_SIZE call. */
+
+int
+get_oacc_ifn_dim_arg (const gimple *stmt)
+{
+ gcc_checking_assert (gimple_call_internal_fn (stmt) == IFN_GOACC_DIM_SIZE
+ || gimple_call_internal_fn (stmt) == IFN_GOACC_DIM_POS);
+ tree arg = gimple_call_arg (stmt, 0);
+ HOST_WIDE_INT axis = TREE_INT_CST_LOW (arg);
+
+ gcc_checking_assert (axis >= 0 && axis < GOMP_DIM_MAX);
+ return (int) axis;
+}
+
/* Expand the GIMPLE_OMP_TARGET starting at REGION. */
static void
@@ -19015,6 +19050,18 @@ default_goacc_validate_dims (tree ARG_UNUSED (decl), int *dims,
return changed;
}
+/* Default dimension bound is unknown on accelerator and 1 on host. */
+
+int
+default_goacc_dim_limit (int ARG_UNUSED (axis))
+{
+#ifdef ACCEL_COMPILER
+ return 0;
+#else
+ return 1;
+#endif
+}
+
namespace {
const pass_data pass_data_oacc_device_lower =