[gomp] Handle array reductions plus various fortran reduction handling fixes

Richard Henderson rth@redhat.com
Fri Oct 14 20:58:00 GMT 2005


On Fri, Oct 14, 2005 at 11:57:27AM -0400, Jakub Jelinek wrote:
>      case MIN_EXPR:
>        if (SCALAR_FLOAT_TYPE_P (type))
> +	{
> +	  REAL_VALUE_TYPE inf;
> +	  real_inf (&inf);
> +	  return build_real (type, inf);

Hmm.  I'd have thought FLT_MAX and not +inf.

And am I mistaken, or should the following properly test this case:

-----
       real*4 x
!$omp sections reduction(min:x)
       x = huge(x) * 2.0
!$omp end sections
       write (*,*) x
       end
-----

I would think that x is initialized to +inf in the section, and then
reduced with either outer_x = min(x, outer_x), where the outer_x is
initialized with either +inf or huge, and then printing the outer_x
tells us what went on.

Except ifort 9.0 prints 0.0, so I'm not sure if the test or the
compiler is broken.

> +static void
> +array_reduction_init (tree var, tree x, tree *stmt_list)

Are you sure you can even generate this in generic?  What if this
is a multi-dimensional array with slices?  I'm not even sure that
such arrays are even array types at the generic level.

> +  tree ptr_type = build_pointer_type (TREE_TYPE (TREE_TYPE (var)));
> +  tree array = build_fold_addr_expr_with_type (var, ptr_type);

This is illegal.  At minimum you wanted &a[<min-index>].  However,
this will also not function properly for multi-dimensional arrays,
since TREE_TYPE (TREE_TYPE (var)) is in that case still an array.

> +  stmt = build2 (MODIFY_EXPR, void_type_node, ptr, array);
> +  gimplify_and_add (stmt, stmt_list);
> +  append_to_statement_list (build_and_jump (&test_label), stmt_list);
> +  loop_label = create_artificial_label ();
> +  stmt = build1 (LABEL_EXPR, void_type_node, loop_label);
> +  append_to_statement_list (stmt, stmt_list);
> +  stmt = build2 (MODIFY_EXPR, void_type_node,

And please use blank lines to separate statements.


r~



More information about the Fortran mailing list