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

CSHIFT in parallel computing

Maxim_Belkin
Beginner
600 Views
Hi all,
The problem that I have is the following.

In my program I have DO-loops which look like this:
c--h-is-(NxN)-matrix---

do i=1,N
ip=i+1
if(i.eq.N) ip=1
im=i-1
if(i.eq.1) im=N

do j=1,N
jp=j+1
if(j.eq.N) jp=1
jm=j-1
if(j.eq.1) jm= N

hx(i,j)=h(ip,j)-h(im,j)

end do
end do

Using CSHIFT it is possible to write it much shorter:
      hx = cshift(h,1,1) - cshift(h,-1,1)

The program successfully compiles with the following line:
ifort -O3 -m64 -static -parallel -par-report1 program.f -L"/opt/intel/Compiler/11.1/046/mkl/lib/em64t" -lfftw2xf_intel -L"/opt/intel/Compiler/11.1/046/mkl/lib/em64t" "/opt/intel/Compiler/11.1/046/mkl/lib/em64t"/libmkl_intel_lp64.a -Wl,--start-group "/opt/intel/Compiler/11.1/046/mkl/lib/em64t"/libmkl_intel_thread.a "/opt/intel/Compiler/11.1/046/mkl/lib/em64t"/libmkl_core.a -Wl,--end-group -L"/opt/intel/Compiler/11.1/046/mkl/lib/em64t" -liomp5 -lpthread -lm

But when I launch created a.out - it exits with Segmentation fault.

I found the way to get rid of Segmentation fault. I have to modify the code in the following way:

      b=1.0
hx = cshift(h*b,1,1) - cshift(h*b,-1,1)
But the result is different from what I got before with DO-loops.

Does anybody know why CSHIFT does work for (h*b) and does not for h?

I must also say that if turn off all the optimization with -O0 option, then segmentation fault goes away.
0 Kudos
4 Replies
Ron_Green
Moderator
600 Views
in our Knowledge Base pointers in the right-hand column of this Forum is this article

http://software.intel.com/en-us/articles/determining-root-cause-of-sigsegv-or-sigbus-errors/

for sigsegv errors. Have you read this and tried these suggestions?

ron
0 Kudos
TimP
Honored Contributor III
600 Views
I wondered about -static, but it's not necessarily a problem. Your cshift code appears likely to force creation of local temporary arrays, in case that is a clue.
It's preferable not to add redundant options, although I assume you're using the same MKL and OpenMP libraries you would get by default in your compiler installation .

0 Kudos
Steven_L_Intel1
Employee
600 Views
Quoting - tim18
The options -static -parallel conflict.

A common confusion. On Linux, -static means "link with static libraries", not "make variables static". The latter is -save.
0 Kudos
Maxim_Belkin
Beginner
600 Views
in our Knowledge Base pointers in the right-hand column of this Forum is this article

http://software.intel.com/en-us/articles/determining-root-cause-of-sigsegv-or-sigbus-errors/

for sigsegv errors. Have you read this and tried these suggestions?

ron

I've read it a little bit before.
But interesting thing is that there is no segmentation fault if I use CSHIFT(A*B). It appears if I use CSHIFT(C), where C=A*B.
Why is that? I would think that the latter should be a "safer" thing to do....
0 Kudos
Reply