Hi Andrew!

On 2024-11-06T15:27:19+0000, Andrew Stubbs <a...@baylibre.com> wrote:
> If requested, return the vectorization factor appropriate for the offload
> device, if any.

> --- a/gcc/omp-general.cc
> +++ b/gcc/omp-general.cc
> @@ -987,10 +987,11 @@ find_combined_omp_for (tree *tp, int *walk_subtrees, 
> void *data)
>    return NULL_TREE;
>  }
>  
> -/* Return maximum possible vectorization factor for the target.  */
> +/* Return maximum possible vectorization factor for the target, or for
> +   the OpenMP offload target if one exists.  */
>  
>  poly_uint64
> -omp_max_vf (void)
> +omp_max_vf (bool offload)
>  {
>    if (!optimize
>        || optimize_debug
> @@ -999,6 +1000,18 @@ omp_max_vf (void)
>         && OPTION_SET_P (flag_tree_loop_vectorize)))
>      return 1;
>  
> +  if (ENABLE_OFFLOADING && offload)
> +    {
> +      for (const char *c = getenv ("OFFLOAD_TARGET_NAMES"); c;)
> +     {
> +       if (startswith (c, "amdgcn"))
> +         return ordered_max (64, omp_max_vf (false));
> +       else if ((c = strchr (c, ':')))
> +         c++;
> +     }
> +      /* Otherwise, fall through to host VF.  */
> +    }
> +
>    auto_vector_modes modes;
>    targetm.vectorize.autovectorize_vector_modes (&modes, true);
>    if (!modes.is_empty ())

Maybe move the magic number "64" into a '#define' or similar, and clarify
(source code comment?) whether the choice of 64 is also correct for GCN
'TARGET_WAVE64_COMPAT' configurations (like gfx1100, which default to
'--param=gcn-preferred-vectorization-factor=32')?


Grüße
 Thomas

Reply via email to