is the vectorlength clause merely a hint to the compiler?

is the vectorlength clause merely a hint to the compiler?

Hi.

There is a small discussion going on in the GCC mailing list wrt the vectorlength clause (http://gcc.gnu.org/ml/gcc-patches/2013-04/msg01333.html). This is in regards to the vectorlength attribute as it relates to the Cilk Plus #pragma simd construct.

The question is, whether vectorlength is just a hint to the compiler, basically "if you vectorize, prefer this vector length, but the compiler is still responsible for doing any (dependency/etc) analysis, and punting if it can't prove there is no aliasing (or go for runtime checks)".

All I see in the spec is "If the vectorlength clause is used, the VL is selected from among the values of its arguments".  Is this merely a hint?  What if the compiler can't use the vectorlength specified, is this a hard error?  Should we fail?  Is the vectorlength clause an assertion that no further dependence analysis will be done by the compiler, and the following loop is guaranteed to be vectorizable?

Any tips would be greatly appreciated.  Thanks.

Aldy

6 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

When using #pragma simd, the programmer is asserting that there are no loop-carried dependencies and that the iterations can be evaluated in parallel.  The compiler is not responsible for "prooving" this assertion -- it can assume it's true and vectorize accordingly.

Vectorlength is mostly a hint to the compiler, but it does have a subtle semantic meaning.  When used with #pragma simd, the the vectorlength clause tells the compiler that there are no loop-carried dependencies within a specified window as specified in the vectorlength clause.  For example, for vectorlength(8), iteration j can depend a value computed in iteration j - 8, but not on a value computed in j - 7.  If vectorlength is not specified, it defaults to the entire loop count, i.e., no loop-carried dependencies at all. The compiler is never required to use a specific vector length; it is permitted to choose any vector length less than or equal to length specified in the vectorlength clause.

Clarifying this meaning is at the top of my list for the next revision of the Cilk Plus language specification.

-Pablo

Ok, that's a lot clearer.  Thanks.

I assume that if there are multiple vectorlength arguments, then we can depend on the MAX of the arguments?  That is, for vectorlength(8,4), then there can be dependencies on MAX(8,4), j - 8, but not j - 4, or j - 2, etc.

Thanks again,
Aldy

Quote:

Aldy Hernandez wrote:

I assume that if there are multiple vectorlength arguments, then we can depend on the MAX of the arguments?  That is, for vectorlength(8,4), then there can be dependencies on MAX(8,4), j - 8, but not j - 4, or j - 2, etc.

Correct.  The use of multiple vectorlength arguments is being removed (or at least deprecated) in the next revision of the spec., since it carries no semantic meaning and is not even a very good hint to the compiler.

-Pablo

The OpenMP 4.0 RC2 draft standard defines #pragma omp simd safelen(length)

In current Intel compilers, apparently #pragma omp simd safelen is implemented for targets -mavx and -mmic, but ignored for older architectures. 

I haven't seen a decision made in view of OpenMP 4.0 on changing the past marketing point of view that all #pragma simd are considered part of Cilk(tm) Plus.

Kommentar hinterlassen

Bitte anmelden, um einen Kommentar hinzuzufügen. Sie sind noch nicht Mitglied? Jetzt teilnehmen