|
| View previous topic :: View next topic |
| Author |
Message |
r2d2085
Joined: 26 Apr 2010 Posts: 2
|
Posted: Mon Apr 26, 2010 11:20 pm Post subject: Fortran90: Loop vectorization failed - data dependency |
|
|
Hi,
I'm using PGI-Fortran compilers (10.2.0) on Cray XT5 and having trouble vectorizing part of my code. I would appreciate if someone could shed some light on this issue.
I'm invoking the compiler with the following options:
ftn -fast -Minfo -c test.F90
17, Loop not vectorized: data dependency
Loop unrolled 2 times
22, Loop not vectorized: data dependency
Loop unrolled 2 times
AFAIK there are no dependencies between the loop statements and also across iterations. When I encountered a similar issue in a C program, I used the -Msafeptr flag to resolve it, is there something similar for Fortran90?
Thanks in advance.
| Code: |
1 PROGRAM test
2
3 IMPLICIT NONE
4
5 type reaction
6 integer, pointer :: foo(:)
7 real, pointer :: foo1(:)
8 real, pointer :: bar(:)
9 end type reaction
10
11 integer num, i, j, k
12 type(reaction) node
13 real, allocatable :: temp(:)
14
15 allocate(temp(num))
16
17 do i = 1, num
18 k = node%foo(i)
19 node%bar(k) = node%bar(k) + node%foo1(i)
20 enddo
21
22 do i = 1, num
23 node%bar(node%foo(i)) = node%bar(node%foo(i)) + node%foo1(i)
24 enddo
25
26 END PROGRAM test
|
|
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 4996 Location: The Portland Group Inc.
|
Posted: Tue Apr 27, 2010 10:49 am Post subject: |
|
|
Hi r2d2085,
| Code: |
17 do i = 1, num
18 k = node%foo(i)
19 node%bar(k) = node%bar(k) + node%foo1(i)
20 enddo |
What happens if some or all values of "k" are the same? The result will depend upon the order in which the vectors are executed and the memory updated. Since the order can vary from run to run, your results will be non-deterministic.
The compiler must be conservative (it's better to get correct answers, then wrong answers fast) and not vectorize this loop.
Hope this helps,
Mat |
|
| Back to top |
|
 |
r2d2085
Joined: 26 Apr 2010 Posts: 2
|
Posted: Tue Apr 27, 2010 11:00 pm Post subject: |
|
|
Thanks, Mat for the explanation. It was helpful.
I've one more question, if I make sure that "k" always has an unique value, is there some way to tell the compiler to go ahead with its vectorization? |
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 4996 Location: The Portland Group Inc.
|
Posted: Wed Apr 28, 2010 9:10 am Post subject: |
|
|
Yes, you can use the "-Mnodepchk" flag. However, use with care since it can cause wrong answers of all value of K are not independent. Also, it will be applied to all loops in the file, not just this one. Because of this, you might want to use the "nodepchk" directive instead since it can be localized to particular loops.
Note that these loops still won't vectorize even with "-Mnodepchk" since there isn't enough work to justify vectorization.
Hope this helps,
Mat |
|
| Back to top |
|
 |
|
|
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 © 2001, 2002 phpBB Group
|