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

Potential Challenge with ifort and OpenMP

David_Race
Beginner
215 Views
I have the following code that is compiled with ifort
================Begin Program=========================================
program mpiopenmp
use IFPORT
implicit none
integer :: i,j,k,ii,jj,sorl
character*1 :: argstr = 'S'
double precision:: stime, endtime
integer :: n_of_comm_args
integer :: ip
real(8) :: wet, inj
!
! cell variable
!
integer :: ierr
integer :: lx, ly, lz
integer :: local_lx, local_ly
integer :: local_ivoid
integer,allocatable,dimension(:,:,:),save :: cell
lx= 404
ly=404
lz=400
local_lx=lx
local_ly=ly
allocate( cell(-1:local_lx,-1:local_ly,0:lz-1) )
if (ip==0) then
print *, 'model size = ',lx,'*',ly,'*',lz
endif
wet = (1.0d0-sqrt(3.0d0)/2.0d0)/2.0d0
inj = 0.0d0
call srand(0)
do k=0,lz-1
do j=0,local_ly-1
do i=0,local_lx-1
if (rand() < .5) then
cell(i,j,k)=0
else
cell(i,j,k)=1
end if
end do
end do
end do
local_ivoid = 0
!$omp parallel
!$omp do reduction(+:local_ivoid) private(i,j,k) &
!$omp firstprivate(local_lx,local_ly)
do k=0,lz-1
do j=0,local_ly-1
do i=0,local_lx-1
if (cell(i,j,k)==0) local_ivoid = local_ivoid + 1
end do
end do
end do
!$omp end do
print *,local_ivoid
!$omp end parallel
!
end program mpiopenmp
======================End Program==================================
======================Makefile Start==================================
############################################################
# Setting
FC = ifort
FFLAGS = -O3 -openmp -xHost
LD = $(FC)
LDFLAGS = $(FFLAGS)
TARGET = MPI-OPENMP
MAIN_SRCS = MPI-OPENMP2.F90
OBJS = $(MAIN_SRCS:.F90=.o)
############################################################
# Rules
$(TARGET): $(OBJS)
$(LD) -o $@ $(OBJS) $(LDFLAGS)
MPI-OPENMP2.o: MPI-OPENMP2.F90
$(FC) $(FFLAGS) -c MPI-OPENMP2.F90
clean:
$(RM) -f *.[os] *.mod $(TARGET) *.o
############################################################
# SUFFIXS
.SUFFIXES:
.SUFFIXES: .o .F .f .F90 .f90 .c .s
############################################################
=======================Makefile End=============================
If I compile with gfortran or with ifort v 12.0.5 (dated 19 July 2011) or with ifort v 12.1.0 without -openmp , the result follows:
model size = 404 * 404 * 400
32635952
32635952
32635952
32635952
32635952
32635952
32635952
32635952
32635952
32635952
32635952
32635952
32635952
32635952
32635952
32635952
---------------------------------------------------------------------------------------------------
compiling with ifort v12.1.0 with -openmp yields
model size = 404 * 404 * 400
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
--------------------------------------------------------------------------------------------
This is part of a larger application, so this OpenMP construct is used several times in the application. Any help with this would be appreciated.
Thanks

David Race
program mpiopenmp use IFPORT implicit none integer :: i,j,k,ii,jj,sorl character*1 :: argstr = 'S' double precision:: stime, endtime integer :: n_of_comm_args integer :: ip real(8) :: wet, inj!! cell variable! integer :: ierr integer :: lx, ly, lz integer :: local_lx, local_ly integer :: local_ivoid integer,allocatable,dimension(:,:,:),save :: cell lx= 404 ly=404 lz=400 local_lx=lx local_ly=ly allocate( cell(-1:local_lx,-1:local_ly,0:lz-1) ) if (ip==0) then print *, 'model size = ',lx,'*',ly,'*',lz endif wet = (1.0d0-sqrt(3.0d0)/2.0d0)/2.0d0 inj = 0.0d0 call srand(0) do k=0,lz-1 do j=0,local_ly-1 do i=0,local_lx-1 if (rand() < .5) then cell(i,j,k)=0 else cell(i,j,k)=1 end if end do end do end do local_ivoid = 0!$omp parallel!$omp do reduction(+:local_ivoid) private(i,j,k) &!$omp firstprivate(local_lx,local_ly) do k=0,lz-1 do j=0,local_ly-1 do i=0,local_lx-1 if (cell(i,j,k)==0) local_ivoid = local_ivoid + 1 end do end do end do!$omp end doprint *,local_ivoid!$omp end parallel!end program mpiopenmp
0 Kudos
2 Replies
TimP
Honored Contributor III
215 Views
I don't see such a problem with the current Intel64 version: 12.1.3.293 Build 20120212
0 Kudos
David_Race
Beginner
215 Views
Thanks. I will get the admin to upgrade to the latest version.
0 Kudos
Reply