Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

2nd openmp 3.0????!!!!

yingwu
Beginner
385 Views

Hi,

Due to the question in my previous thread (not solved yet), I am confused completely now.

If my code is like,

program test3
use omp_lib

integer :: i
real :: a(100)
real, dimension(:), allocatable :: b

allocate (b(100))

a = 10
b = 20

!$OMP PARALLEL DO REDUCTION (+:a) NUM_THREADS(4)
do i = 1, 10
print *, OMP_GET_THREAD_NUM()
a = a+b
end do
!$OMP END PARALLEL DO

end

The result is right, like below,

/home/yingwu/Desktop/IMSLtest $ ./test3
0
0
0
3
3
1
1
1
2
2

However, if I define the array as allocatable, like below,

program test3

use omp_lib

integer :: i
real, dimension(:), allocatable :: a
real, dimension(:), allocatable :: b

allocate (a(100))
allocate (b(100))

a = 10
b = 20

!$OMP PARALLEL DO REDUCTION (+:a) NUM_THREADS(4)
do i = 1, 10
print *, OMP_GET_THREAD_NUM()
a = a+b
end do
!$OMP END PARALLEL DO

end

I get two possible error messages, like

/home/yingwu/Desktop/IMSLtest $ ./test3
0
1
3
aborted

or

/home/yingwu/Desktop/IMSLtest $ ./test3
0
1
3
2
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
. 4001D422 Unknown Unknown Unknown
libiomp5.so 41570F38 Unknown Unknown Unknown
libpthread.so.0 415C580E Unknown Unknown Unknown
libc.so.6 416A67EE Unknown Unknown Unknown

I don't know where I am wrong. It seems the problem of allocatable array in openmp??

Thanks very much.

0 Kudos
1 Solution
Martyn_C_Intel
Employee
385 Views

Ying,

I think I have answered this in your previous thread. Use of static arrays as reduction variables, as in OpenMP 2.5, works. Use of allocatable arrays as reduction variables, new in OpenMP 3.0, did not work in the initial implementation of OpenMP 3.0 in the Intel compilers, but it does work in the latest compiler updates. My tests showed that it worked in the 11.1 compiler update 3 and later updates (11.1.059 and later on Linux).

Please download a recent compiler and let us know if you agree. We regret the problem, thanks for reporting it.

View solution in original post

0 Kudos
2 Replies
Martyn_C_Intel
Employee
386 Views

Ying,

I think I have answered this in your previous thread. Use of static arrays as reduction variables, as in OpenMP 2.5, works. Use of allocatable arrays as reduction variables, new in OpenMP 3.0, did not work in the initial implementation of OpenMP 3.0 in the Intel compilers, but it does work in the latest compiler updates. My tests showed that it worked in the 11.1 compiler update 3 and later updates (11.1.059 and later on Linux).

Please download a recent compiler and let us know if you agree. We regret the problem, thanks for reporting it.

0 Kudos
yingwu
Beginner
385 Views

Hi Martyn,

Thanks for your help. I have tried the newest version today and it works. The compiler is obviously improved in openmp. Meanwhile, I find the compiling time is shorter than before. Thanks very much. It is very help for me.

0 Kudos
Reply