This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: omp_clause_num_ops


Amittai Aviram <amittai.aviram@yale.edu> writes:

> Hi!  The array omp_clause_num_ops, in gcc/gcc/tree.c, defines the number of "operands" for an AST node representing an OpenMP reduction clause to be 4:
>
> /* Number of operands for each OpenMP clause.  */
> unsigned const char omp_clause_num_ops[] =
> {
>   0, /* OMP_CLAUSE_ERROR  */
>   1, /* OMP_CLAUSE_PRIVATE  */
>   1, /* OMP_CLAUSE_SHARED  */
>   1, /* OMP_CLAUSE_FIRSTPRIVATE  */
>   2, /* OMP_CLAUSE_LASTPRIVATE  */
>   4, /* OMP_CLAUSE_REDUCTION  */
>   1, /* OMP_CLAUSE_COPYIN  */
>   1, /* OMP_CLAUSE_COPYPRIVATE  */
>   1, /* OMP_CLAUSE_IF  */
>   1, /* OMP_CLAUSE_NUM_THREADS  */
>   1, /* OMP_CLAUSE_SCHEDULE  */
>   0, /* OMP_CLAUSE_NOWAIT  */
>   0, /* OMP_CLAUSE_ORDERED  */
>   0, /* OMP_CLAUSE_DEFAULT  */
>   3, /* OMP_CLAUSE_COLLAPSE  */
>   0  /* OMP_CLAUSE_UNTIED   */
> };
>
> What does "operand" mean in this context, and why is it 4?  A typical reduction clause would look like this:
>
> reduction(+:x)
>
> I would guess either one operand (x) or two for the binary operation +.  So this code must imply some different interpretation of the word "operand."  Thanks.

If you search for OMP_CLAUSE_REDUCTION in tree.h you will see this
comment:

  /* OpenMP clause: reduction (operator:variable_list).
     OMP_CLAUSE_REDUCTION_CODE: The tree_code of the operator.
     Operand 1: OMP_CLAUSE_REDUCTION_INIT: Stmt-list to initialize the var.
     Operand 2: OMP_CLAUSE_REDUCTION_MERGE: Stmt-list to merge private var
                into the shared one.
     Operand 3: OMP_CLAUSE_REDUCTION_PLACEHOLDER: A dummy VAR_DECL
                placeholder used in OMP_CLAUSE_REDUCTION_{INIT,MERGE}.  */

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]