PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

unrolling or data dependent loops
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
deeppow



Joined: 02 Feb 2012
Posts: 51

PostPosted: Tue Mar 05, 2013 11:36 am    Post subject: unrolling or data dependent loops Reply with quote

I have a typical loop, for example
DO k = 1, JFLagcnt
j = LSTjflag(k)
w(j) = (w(j)+B(j)*p(j))/B(j)
ENDDO

Initially compiler gives "Loop not vectorized: data dependency Loop unrolled 4 times " so I try a compiler directive
!pgi$l nodepchk
DO k = 1, JFLagcnt
j = LSTjflag(k)
w(j) = (w(j)+B(j)*p(j))/B(j)
ENDDO
and get the following compiler output "Loop not parallelized: innermost Loop not vectorized: may not be beneficial Loop unrolled 4 times"

The loop is >12000 elements. What am I doing wrong so I get it to vectorized? There are a number of loops like this so it'll affect run time.
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6206
Location: The Portland Group Inc.

PostPosted: Tue Mar 05, 2013 3:03 pm    Post subject: Reply with quote

Hi deeppow,

I think you're fine, but the compiler isn't tuned to vectorize loops where the indexes come from a look-up table. I added a feature request (TPR#19181) and we will have our engineers see what we can do.

Thanks,
Mat
Back to top
View user's profile
deeppow



Joined: 02 Feb 2012
Posts: 51

PostPosted: Tue Mar 05, 2013 3:11 pm    Post subject: Reply with quote

Matt,

Using indirect indexing to avoid repeated if-testing, do test once and store for reuse. It's an old method, is there a better way these days?


-ralph
Back to top
View user's profile
deeppow



Joined: 02 Feb 2012
Posts: 51

PostPosted: Tue Mar 05, 2013 3:33 pm    Post subject: Reply with quote

An additional weird problem is associated with
DO k = 1, JFLagcnt
j = LSTjflag(k)
u(j) = r(j) + beta*h(j)
p(j) = u(j) + beta*(beta*p(j)+h(j))
ENDDO

which produces the compiler output "Loop not vectorized: data dependency Loop unrolled 2 times". Most data dependency failures such as that noted above produce unrolling of 4 times. Even thought the default is 4, I tried to force it by using the compiler option "-Munroll=c:4" which as one might expect doesn't change the behavior.


-ralph
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6206
Location: The Portland Group Inc.

PostPosted: Wed Mar 06, 2013 11:02 am    Post subject: Reply with quote

Hi Ralph,

Try using "-Munrol=n:4" or "-Munroll=m:4" instead. The "c" option controls the maximum loop count to completely unroll a loop. "n" controls the unroll factor for single block loops while "m" controls the factor for multi-block loops.

Hope this helps,
Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group