mirror of git://gcc.gnu.org/git/gcc.git
[nvptx] Factor out populate_offload_attrs
Factor out populate_offload_attrs from nvptx_reorg. 2019-01-03 Tom de Vries <tdevries@suse.de> * config/nvptx/nvptx.c (struct offload_attrs): New. (populate_offload_attrs): New function. Factor mask extraction out of nvptx_reorg. Add extraction of dimensions. (nvptx_reorg): Use populate_offload_attrs. From-SVN: r267557
This commit is contained in:
parent
4b1716079d
commit
2498a6abcc
|
|
@ -1,3 +1,10 @@
|
||||||
|
2019-01-03 Tom de Vries <tdevries@suse.de>
|
||||||
|
|
||||||
|
* config/nvptx/nvptx.c (struct offload_attrs): New.
|
||||||
|
(populate_offload_attrs): New function. Factor mask extraction out of
|
||||||
|
nvptx_reorg. Add extraction of dimensions.
|
||||||
|
(nvptx_reorg): Use populate_offload_attrs.
|
||||||
|
|
||||||
2019-01-03 Tom de Vries <tdevries@suse.de>
|
2019-01-03 Tom de Vries <tdevries@suse.de>
|
||||||
|
|
||||||
* config/nvptx/nvptx.c (nvptx_goacc_validate_dims_1): Add early-out
|
* config/nvptx/nvptx.c (nvptx_goacc_validate_dims_1): Add early-out
|
||||||
|
|
|
||||||
|
|
@ -2873,6 +2873,16 @@ nvptx_reorg_uniform_simt ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Offloading function attributes. */
|
||||||
|
|
||||||
|
struct offload_attrs
|
||||||
|
{
|
||||||
|
unsigned mask;
|
||||||
|
int num_gangs;
|
||||||
|
int num_workers;
|
||||||
|
int vector_length;
|
||||||
|
};
|
||||||
|
|
||||||
/* Loop structure of the function. The entire function is described as
|
/* Loop structure of the function. The entire function is described as
|
||||||
a NULL loop. */
|
a NULL loop. */
|
||||||
|
|
||||||
|
|
@ -4576,6 +4586,41 @@ nvptx_neuter_pars (parallel *par, unsigned modes, unsigned outer)
|
||||||
nvptx_neuter_pars (par->next, modes, outer);
|
nvptx_neuter_pars (par->next, modes, outer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
populate_offload_attrs (offload_attrs *oa)
|
||||||
|
{
|
||||||
|
tree attr = oacc_get_fn_attrib (current_function_decl);
|
||||||
|
tree dims = TREE_VALUE (attr);
|
||||||
|
unsigned ix;
|
||||||
|
|
||||||
|
oa->mask = 0;
|
||||||
|
|
||||||
|
for (ix = 0; ix != GOMP_DIM_MAX; ix++, dims = TREE_CHAIN (dims))
|
||||||
|
{
|
||||||
|
tree t = TREE_VALUE (dims);
|
||||||
|
int size = (t == NULL_TREE) ? -1 : TREE_INT_CST_LOW (t);
|
||||||
|
tree allowed = TREE_PURPOSE (dims);
|
||||||
|
|
||||||
|
if (size != 1 && !(allowed && integer_zerop (allowed)))
|
||||||
|
oa->mask |= GOMP_DIM_MASK (ix);
|
||||||
|
|
||||||
|
switch (ix)
|
||||||
|
{
|
||||||
|
case GOMP_DIM_GANG:
|
||||||
|
oa->num_gangs = size;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GOMP_DIM_WORKER:
|
||||||
|
oa->num_workers = size;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GOMP_DIM_VECTOR:
|
||||||
|
oa->vector_length = size;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if WORKAROUND_PTXJIT_BUG_2
|
#if WORKAROUND_PTXJIT_BUG_2
|
||||||
/* Variant of pc_set that only requires JUMP_P (INSN) if STRICT. This variant
|
/* Variant of pc_set that only requires JUMP_P (INSN) if STRICT. This variant
|
||||||
is needed in the nvptx target because the branches generated for
|
is needed in the nvptx target because the branches generated for
|
||||||
|
|
@ -4757,27 +4802,19 @@ nvptx_reorg (void)
|
||||||
{
|
{
|
||||||
/* If we determined this mask before RTL expansion, we could
|
/* If we determined this mask before RTL expansion, we could
|
||||||
elide emission of some levels of forks and joins. */
|
elide emission of some levels of forks and joins. */
|
||||||
unsigned mask = 0;
|
offload_attrs oa;
|
||||||
tree dims = TREE_VALUE (attr);
|
|
||||||
unsigned ix;
|
|
||||||
|
|
||||||
for (ix = 0; ix != GOMP_DIM_MAX; ix++, dims = TREE_CHAIN (dims))
|
populate_offload_attrs (&oa);
|
||||||
{
|
|
||||||
int size = TREE_INT_CST_LOW (TREE_VALUE (dims));
|
|
||||||
tree allowed = TREE_PURPOSE (dims);
|
|
||||||
|
|
||||||
if (size != 1 && !(allowed && integer_zerop (allowed)))
|
|
||||||
mask |= GOMP_DIM_MASK (ix);
|
|
||||||
}
|
|
||||||
/* If there is worker neutering, there must be vector
|
/* If there is worker neutering, there must be vector
|
||||||
neutering. Otherwise the hardware will fail. */
|
neutering. Otherwise the hardware will fail. */
|
||||||
gcc_assert (!(mask & GOMP_DIM_MASK (GOMP_DIM_WORKER))
|
gcc_assert (!(oa.mask & GOMP_DIM_MASK (GOMP_DIM_WORKER))
|
||||||
|| (mask & GOMP_DIM_MASK (GOMP_DIM_VECTOR)));
|
|| (oa.mask & GOMP_DIM_MASK (GOMP_DIM_VECTOR)));
|
||||||
|
|
||||||
/* Discover & process partitioned regions. */
|
/* Discover & process partitioned regions. */
|
||||||
parallel *pars = nvptx_discover_pars (&bb_insn_map);
|
parallel *pars = nvptx_discover_pars (&bb_insn_map);
|
||||||
nvptx_process_pars (pars);
|
nvptx_process_pars (pars);
|
||||||
nvptx_neuter_pars (pars, mask, 0);
|
nvptx_neuter_pars (pars, oa.mask, 0);
|
||||||
delete pars;
|
delete pars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue