Hi Jakub!

We now have to revisit this discussion about
gcc/c-family/c-pragma.h:pragma_omp_clause,
<http://news.gmane.org/find-root.php?message_id=%3C87bnn1rrv3.fsf%40schwinge.name%3E>:

On Thu, 18 Dec 2014 14:48:32 +0100, I wrote:
> > > -/* All clauses defined by OpenMP 2.5, 3.0, 3.1 and 4.0.
> > > +/* All clauses defined by OpenACC 2.0, and OpenMP 2.5, 3.0, 3.1, and 4.0.
> > >     Used internally by both C and C++ parsers.  */
> > >  typedef enum pragma_omp_clause {
> > >    PRAGMA_OMP_CLAUSE_NONE = 0,
> > >  
> > >    PRAGMA_OMP_CLAUSE_ALIGNED,
> > > [...]
> > >    PRAGMA_OMP_CLAUSE_TO,
> > >    PRAGMA_OMP_CLAUSE_UNIFORM,
> > >    PRAGMA_OMP_CLAUSE_UNTIED,
> > > +  PRAGMA_OMP_CLAUSE_VECTOR_LENGTH,
> > > +  PRAGMA_OMP_CLAUSE_WAIT,
> > 
> > Like for CILK, I'd strongly prefer if for the clauses that are
> > specific to OpenACC only you'd use PRAGMA_OACC_CLAUSE_* instead,
> > and put them after the PRAGMA_CILK_* enum values.
> > If you want to have PRAGMA_OACC_CLAUSE_ aliases also for the
> > clauses shared in between OpenMP and OpenACC, feel free to add
> > aliases like Cilk+ has them.

(That's what we ended up doing.)

> > It is unfortunately lots of new clauses
> > and we are getting close to the 64 clauses limit :( when they are used
> > in bitmasks.

We're getting ready to submit patches extending the C/C++ front ends for
the remaining OpenACC clauses, and given the current layout of
gcc/c-family/c-pragma.h:pragma_omp_clause, we're then at 69 unique
clauses, which is more than the 64-bit bitmask limit.

> [...] I understand,
> for example, PRAGMA_OMP_CLAUSE_REDUCTION to just be a "numeric
> representation" of the "reduction" string [...]

Should we now further split parsing of Cilk+/OpenACC/OpenMP pragmas (but
I think you and I agreed that we don't want to go that route), or
revisist Chung-Lin's std::bitset proposal (see below), or something else?

Regarding std::bitset, you've been worried about performance,
<http://news.gmane.org/find-root.php?message_id=%3C20141218142942.GM1667%40tucnak.redhat.com%3E>,
but I'm not sure about this: aren't these code paths only exercised for
pragma parsing, and aren't there really only ever one handful (or, a few)
of pragmas per source code file, so this could hardly be an observable
performance hit?

> Chung-Lin also had a suggestion to make; what do you think of this?
> 
> --- c-family/c-common.h       (revision 442892)
> +++ c-family/c-common.h       (working copy)
> @@ -1076,138 +1076,17 @@ extern void pp_dir_change (cpp_reader *, const cha
>  extern bool check_missing_format_attribute (tree, tree);
>  
>  /* In c-omp.c  */
> -#if HOST_BITS_PER_WIDE_INT >= 64
> -typedef unsigned HOST_WIDE_INT omp_clause_mask;
> -# define OMP_CLAUSE_MASK_1 ((omp_clause_mask) 1)
> -#else
> -struct omp_clause_mask
> +#include <bitset>
> +typedef std::bitset<128> omp_clause_mask;
> +/* Provide '&' before full transition to set() method.  */
> +static inline omp_clause_mask
> +operator & (const omp_clause_mask& a, const omp_clause_mask& b)
>  {
> -  inline omp_clause_mask ();
> -  inline omp_clause_mask (unsigned HOST_WIDE_INT l);
> -  inline omp_clause_mask (unsigned HOST_WIDE_INT l,
> -                       unsigned HOST_WIDE_INT h);
> -  inline omp_clause_mask &operator &= (omp_clause_mask);
> -  inline omp_clause_mask &operator |= (omp_clause_mask);
> -  inline omp_clause_mask operator ~ () const;
> -  inline omp_clause_mask operator & (omp_clause_mask) const;
> -  inline omp_clause_mask operator | (omp_clause_mask) const;
> -  inline omp_clause_mask operator >> (int);
> -  inline omp_clause_mask operator << (int);
> -  inline bool operator == (omp_clause_mask) const;
> -  inline bool operator != (omp_clause_mask) const;
> -  unsigned HOST_WIDE_INT low, high;
> -};
> -
> -inline
> -omp_clause_mask::omp_clause_mask ()
> -{
> +  omp_clause_mask tmp = a;
> +  return (tmp &= b);
>  }
> +#define OMP_CLAUSE_MASK_1 (omp_clause_mask (1))
>  
> -inline
> -omp_clause_mask::omp_clause_mask (unsigned HOST_WIDE_INT l)
> -: low (l), high (0)
> -{
> -}
> -
> -inline
> -omp_clause_mask::omp_clause_mask (unsigned HOST_WIDE_INT l,
> -                               unsigned HOST_WIDE_INT h)
> -: low (l), high (h)
> -{
> -}
> -
> -inline omp_clause_mask &
> -omp_clause_mask::operator &= (omp_clause_mask b)
> -{
> -  low &= b.low;
> -  high &= b.high;
> -  return *this;
> -}
> -
> -inline omp_clause_mask &
> -omp_clause_mask::operator |= (omp_clause_mask b)
> -{
> -  low |= b.low;
> -  high |= b.high;
> -  return *this;
> -}
> -
> -inline omp_clause_mask
> -omp_clause_mask::operator ~ () const
> -{
> -  omp_clause_mask ret (~low, ~high);
> -  return ret;
> -}
> -
> -inline omp_clause_mask
> -omp_clause_mask::operator | (omp_clause_mask b) const
> -{
> -  omp_clause_mask ret (low | b.low, high | b.high);
> -  return ret;
> -}
> -
> -inline omp_clause_mask
> -omp_clause_mask::operator & (omp_clause_mask b) const
> -{
> -  omp_clause_mask ret (low & b.low, high & b.high);
> -  return ret;
> -}
> -
> -inline omp_clause_mask
> -omp_clause_mask::operator << (int amount)
> -{
> -  omp_clause_mask ret;
> -  if (amount >= HOST_BITS_PER_WIDE_INT)
> -    {
> -      ret.low = 0;
> -      ret.high = low << (amount - HOST_BITS_PER_WIDE_INT);
> -    }
> -  else if (amount == 0)
> -    ret = *this;
> -  else
> -    {
> -      ret.low = low << amount;
> -      ret.high = (low >> (HOST_BITS_PER_WIDE_INT - amount))
> -              | (high << amount);
> -    }
> -  return ret;
> -}
> -
> -inline omp_clause_mask
> -omp_clause_mask::operator >> (int amount)
> -{
> -  omp_clause_mask ret;
> -  if (amount >= HOST_BITS_PER_WIDE_INT)
> -    {
> -      ret.low = high >> (amount - HOST_BITS_PER_WIDE_INT);
> -      ret.high = 0;
> -    }
> -  else if (amount == 0)
> -    ret = *this;
> -  else
> -    {
> -      ret.low = (high << (HOST_BITS_PER_WIDE_INT - amount))
> -              | (low >> amount);
> -      ret.high = high >> amount;
> -    }
> -  return ret;
> -}
> -
> -inline bool
> -omp_clause_mask::operator == (omp_clause_mask b) const
> -{
> -  return low == b.low && high == b.high;
> -}
> -
> -inline bool
> -omp_clause_mask::operator != (omp_clause_mask b) const
> -{
> -  return low != b.low || high != b.high;
> -}
> -
> -# define OMP_CLAUSE_MASK_1 omp_clause_mask (1)
> -#endif
> -
>  enum c_omp_clause_split
>  {
>    C_OMP_CLAUSE_SPLIT_TARGET = 0,


Grüße,
 Thomas

Attachment: signature.asc
Description: PGP signature

Reply via email to