This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Issue warning if a simd construct nested inside another simd construct
ClosedPublic

Authored by kkwli0 on Jun 29 2016, 7:58 PM.

Details

Summary

Currently, the following nested scenario is not allowed in the OpenMP spec but clang allows it. Issue a warning.

#pragma omp simd
  for (i=0; i<10; i++)
#pragma omp simd  // warning
    for (j=0; j<10; j++)
      ;

The spec only allows the following case

#pragma omp simd
  for (i=0; i<10; i++)
#pragma omp ordered simd // OK
    for (j=0; j<10; j++)
      ;

Diff Detail

Event Timeline

kkwli0 updated this revision to Diff 62331.Jun 29 2016, 7:58 PM
kkwli0 retitled this revision from to [OpenMP] Only allow 'ordered simd' nested inside simd construct.
kkwli0 updated this object.
kkwli0 updated this object.
ABataev edited edge metadata.Jun 29 2016, 8:04 PM

Kelvin, I allowed it intentionally. I don't see a reason why nested 'simd' directives are not allowed, they just allow to vectorize both outer and inner loops. I think it's nice to have such feature.

Thanks for explanation. As this is an extension, hould we issue a warning message? Code compiled successfully with clang will fail with other compilers.

icc accepts such code. Not sure about gcc. But I agree, that it would be good to emit a warning here.

GCC60 issues an error message.

kkwli0 updated this revision to Diff 62434.Jun 30 2016, 3:52 PM
kkwli0 retitled this revision from [OpenMP] Only allow 'ordered simd' nested inside simd construct to [OpenMP] Issue warning if a simd construct nested inside another simd construct.
kkwli0 updated this object.
kkwli0 edited edge metadata.

Update the patch to issue warning instead.

ABataev added inline comments.Jun 30 2016, 7:48 PM
lib/Sema/SemaOpenMP.cpp
2954–2963

Maybe this code can be changed a little bit:

SemaRef.Diag(StartLoc,
             (CurrentRegion != OMPD_simd) ?
               diag::err_omp_prohibited_region_simd : 
               diag::warn_omp_nesting_simd);
return CurrentRegion != OMPD_simd;
2956–2963

The code is not formatted properly

kkwli0 marked 2 inline comments as done.Jun 30 2016, 9:28 PM
kkwli0 added inline comments.
lib/Sema/SemaOpenMP.cpp
2956–2963

Will update it.

kkwli0 updated this revision to Diff 62463.Jun 30 2016, 9:36 PM
kkwli0 marked an inline comment as done.

Update the patch as comment in the review. Thanks.

ABataev accepted this revision.Jun 30 2016, 9:46 PM
ABataev edited edge metadata.

LG

This revision is now accepted and ready to land.Jun 30 2016, 9:46 PM
kkwli0 closed this revision.Jul 1 2016, 7:54 AM

Committed revision 274352.