On Tue, Mar 18, 2025 at 11:27:08AM +0530, Tejas Belagod wrote:
> The target clause in OpenMP is used to offload loop kernels to accelarator
> peripeherals.  target's 'map' clause is used to move data from and to the
> accelarator.  When the data is SVE type, it may not be suitable because of
> various reasons i.e. the two SVE targets may not agree on vector size or
> some targets don't support variable vector size.  This makes SVE unsuitable
> for use in OMP's 'map' clause.  This patch diagnoses all such cases and issues
> an error where SVE types are not suitable.
> 
> Co-authored-by: Andrea Corallo <andrea.cora...@arm.com>
> 
> gcc/ChangeLog:
> 
>       * target.h (type_context_kind): Add new context kinds for target 
> clauses.
>       (omp_type_context): Query if the context is of OMP kind.
>       * config/aarch64/aarch64-sve-builtins.cc (verify_type_context): Diagnose
>       SVE types for a given OpenMP context.
>       (omp_type_context): New.
>       * gimplify.cc (omp_notice_variable): Diagnose implicitly-mapped SVE
>       objects in OpenMP regions.
>       (gimplify_scan_omp_clauses): Diagnose SVE types for various target
>       clauses.

> @@ -5234,6 +5238,37 @@ verify_type_context (location_t loc, type_context_kind 
> context,
>        if (!silent_p)
>       error_at (loc, "capture by copy of SVE type %qT", type);
>        return false;
> +
> +    case TCTX_OMP_MAP:
> +      if (!silent_p)
> +     error_at (loc, "SVE type %qT not allowed in map clause", type);

%<map%>

> +      return false;
> +
> +    case TCTX_OMP_MAP_IMP_REF:
> +      if (!silent_p)
> +     error ("cannot reference %qT object types in target region", type);

%<target%>

> +      return false;
> +
> +    case TCTX_OMP_PRIVATE:
> +      if (!silent_p)
> +     error_at (loc, "SVE type %qT not allowed in"
> +               " target private clause", type);

%<target%> %<private%>

> +      return false;
> +
> +    case TCTX_OMP_FIRSTPRIVATE:
> +      if (!silent_p)
> +     error_at (loc, "SVE type %qT not allowed in"
> +               " target firstprivate clause", type);

%<target%> %<firstprivate%>

> +      return false;
> +
> +    case TCTX_OMP_DEVICE_ADDR:
> +      if (!silent_p)
> +     error_at (loc, "SVE type %qT not allowed in"
> +               " target device clauses", type);

%<target>

> +      return false;
> +
> +    default:
> +      break;

Ok with these nits fixed.

        Jakub

Reply via email to