Re: [PATCH] D69897: Add #pragma clang loop aligned

2019-11-07 Thread HAPPY Mahto via cfe-commits
On Wed, Nov 6, 2019 at 10:43 PM Hal Finkel via Phabricator <
revi...@reviews.llvm.org> wrote:

> hfinkel added inline comments.
>
>
> 
> Comment at: clang/docs/LanguageExtensions.rst:3135
> +
> +This predicates all the array references inside the loop to be aligned.
> The aligned access to them can increase fetch time and increase the
> performance.
> +
> 
> lebedev.ri wrote:
> > What does this actually mean, in the end?
> > Will it assume that whatever alignment is required
> > for whatever vectorization width chosen,
> > is the actual alignment?
>
Currently, it is using 32 bit.

> Also, just arrays, or also pointers?
>
> By pointers, if you mean pointers to arrays? Then Yes.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69897: Add #pragma clang loop aligned

2019-11-06 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D69897#1735983 , @lebedev.ri wrote:

> It would be really best if this could just make use of 
> `CodeGenFunction::EmitAlignmentAssumption()`,
>  else this is a heavy hammer with loose handle.


Since it is a property of the data structure, not of the vectorization, 
`__builtin_assume_aligned` might be preferable anyway.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69897/new/

https://reviews.llvm.org/D69897



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69897: Add #pragma clang loop aligned

2019-11-06 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D69897#1735961 , @Meinersbur wrote:

> Please see my comments in D69900  as well.
>
> For the font-end side, I suggest the syntax `vectorize_assume_alignment(32)` 
> instead. We also need to define what this assumes to be aligned. The first 
> element of the array? Every array element? In an array-of-structs, the struct 
> of the element that is accessed? Scalars?


It would be really best if this could just make use of 
`CodeGenFunction::EmitAlignmentAssumption()`,
else this is a heavy hammer with loose handle.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69897/new/

https://reviews.llvm.org/D69897



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69897: Add #pragma clang loop aligned

2019-11-06 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

Please see my comments in D69900  as well.

For the font-end side, I suggest the syntax `vectorize_assume_alignment(32)` 
instead. We also need to define what this assumes to be aligned. The first 
element of the array? Every array element? In an array-of-structs, the struct 
of the element that is accessed? Scalars?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69897/new/

https://reviews.llvm.org/D69897



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69897: Add #pragma clang loop aligned

2019-11-06 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:3135
+
+This predicates all the array references inside the loop to be aligned. The 
aligned access to them can increase fetch time and increase the performance. 
+

hfinkel wrote:
> lebedev.ri wrote:
> > What does this actually mean, in the end?
> > Will it assume that whatever alignment is required
> > for whatever vectorization width chosen,
> > is the actual alignment?
> Also, just arrays, or also pointers?
> Currently, it is using 32 bit.

You'll need to use the preferred alignment of the element type.

> By pointers, if you mean pointers to arrays? Then Yes.

No, I mean pointers.

What do you intend for these cases:

  double A[Size], B[Size];

  void foo() {
  #pragma clang loop aligned
for (int i = 0; i < n; ++i) {
  A[i] = B[i] + 1;
}
  }

or this:

  void foo(double *A, double *B) {
  #pragma clang loop aligned
for (int i = 0; i < n; ++i) {
  A[i] = B[i] + 1;
}
  }

or this:

  void foo(double *A, double *B, double *C) {
  #pragma clang loop aligned
for (int i = 0; i < n; ++i) {
  A[i] = B[i] + *C + 1;
}
  }

or this:

  void foo(double *A, double *B) {
  #pragma clang loop aligned
for (int i = 0; i < n; ++i) {
  *A++ = *B++ + 1;
}
  }

what about arrays of structs?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69897/new/

https://reviews.llvm.org/D69897



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69897: Add #pragma clang loop aligned

2019-11-06 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:3135
+
+This predicates all the array references inside the loop to be aligned. The 
aligned access to them can increase fetch time and increase the performance. 
+

lebedev.ri wrote:
> What does this actually mean, in the end?
> Will it assume that whatever alignment is required
> for whatever vectorization width chosen,
> is the actual alignment?
Also, just arrays, or also pointers?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69897/new/

https://reviews.llvm.org/D69897



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69897: Add #pragma clang loop aligned

2019-11-06 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:3135
+
+This predicates all the array references inside the loop to be aligned. The 
aligned access to them can increase fetch time and increase the performance. 
+

What does this actually mean, in the end?
Will it assume that whatever alignment is required
for whatever vectorization width chosen,
is the actual alignment?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69897/new/

https://reviews.llvm.org/D69897



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69897: Add #pragma clang loop aligned

2019-11-06 Thread Happy via Phabricator via cfe-commits
m-happy created this revision.
m-happy added reviewers: hfinkel, DTharun, rscottmanley, Meinersbur.
m-happy added a project: clang.
Herald added subscribers: cfe-commits, zzheng.

This patch adds functionality '#pragma clang loop aligned'. The load/store 
access in for loop following the '#pragma clang loop aligned' uses 32 bit for 
align access.

  #pragma clang loop aligned(enable)
  for(){

  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69897

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGLoopInfo.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/AST/ast-print-pragmas.cpp
  clang/test/CodeGenCXX/pragma-loop-aligned.cpp
  clang/test/Parser/pragma-loop.cpp
  clang/test/Parser/pragma-unroll-and-jam.cpp

Index: clang/test/Parser/pragma-unroll-and-jam.cpp
===
--- clang/test/Parser/pragma-unroll-and-jam.cpp
+++ clang/test/Parser/pragma-unroll-and-jam.cpp
@@ -67,7 +67,7 @@
   }
 
 // pragma clang unroll_and_jam is disabled for the moment
-/* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, vectorize_predicate, or distribute}} */ #pragma clang loop unroll_and_jam(4)
+/* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, vectorize_predicate, aligned, or distribute}} */ #pragma clang loop unroll_and_jam(4)
   for (int i = 0; i < Length; i++) {
 for (int j = 0; j < Length; j++) {
   List[i * Length + j] = Value;
Index: clang/test/Parser/pragma-loop.cpp
===
--- clang/test/Parser/pragma-loop.cpp
+++ clang/test/Parser/pragma-loop.cpp
@@ -82,6 +82,7 @@
 #pragma clang loop vectorize(enable)
 #pragma clang loop interleave(enable)
 #pragma clang loop vectorize_predicate(enable)
+#pragma clagn loop aligned(enable)
 #pragma clang loop unroll(full)
   while (i + 1 < Length) {
 List[i] = i;
@@ -97,6 +98,7 @@
 #pragma clang loop vectorize(disable)
 #pragma clang loop interleave(disable)
 #pragma clang loop vectorize_predicate(disable)
+#pragma clang loop aligned(disable)
 #pragma clang loop unroll(disable)
   while (i - 1 < Length) {
 List[i] = i;
@@ -113,7 +115,7 @@
   }
 
   int VList[Length];
-#pragma clang loop vectorize(disable) interleave(disable) unroll(disable) vectorize_predicate(disable)
+#pragma clang loop vectorize(disable) interleave(disable) unroll(disable) vectorize_predicate(disable) aligned(disable)
   for (int j : VList) {
 VList[j] = List[j];
   }
@@ -133,12 +135,14 @@
 /* expected-error {{expected '('}} */ #pragma clang loop vectorize
 /* expected-error {{expected '('}} */ #pragma clang loop interleave
 /* expected-error {{expected '('}} */ #pragma clang loop vectorize_predicate
+/* expected-error {{expected '('}} */ #pragma clang loop aligned
 /* expected-error {{expected '('}} */ #pragma clang loop unroll
 /* expected-error {{expected '('}} */ #pragma clang loop distribute
 
 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop interleave(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize_predicate(enable
+/* expected-error {{expected ')'}} */ #pragma clang loop aligned(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop unroll(full
 /* expected-error {{expected ')'}} */ #pragma clang loop distribute(enable
 
@@ -151,7 +155,7 @@
 /* expected-error {{missing argument; expected 'enable', 'full' or 'disable'}} */ #pragma clang loop unroll()
 /* expected-error {{missing argument; expected 'enable' or 'disable'}} */ #pragma clang loop distribute()
 
-/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, vectorize_predicate, or distribute}} */ #pragma clang loop
+/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, vectorize_predicate, aligned, or distribute}} */ #pragma clang loop
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword(enable)
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop vectorize(enable) badkeyword(4)
@@ -252,6 +256,9 @@
 #pragma clang loop vectorize_predicate(enable)
 /* expected-error@+1 {{duplicate directives 'vectorize_predicate(enable)' and 'vectorize_predicate(disable)'}} */