## Problem with parellel tridiagonal solver

General OpenMP discussion

### Problem with parellel tridiagonal solver

Hi

I am new to OpenMP and I am trying to parallize the following part this do-loop in Fortran

Code: Select all
`!\$OMP PARALLEL DEFAULT(none) SHARED(Nx,Nr,psi_out,psi_in,potential,electronic_curve,E,q_ni,eps,dx) PRIVATE(i,j,a,c,m,vv,dd,bb)!\$OMP DO SCHEDULE(static)do j=1,Nr        a=(1.d0/(2.d0*dx**2))*(1.d0/eps)        c=(1.d0/(2.d0*dx**2))*(1.d0/eps)        vv=0.d0        dd=psi_in(:,j)        bb=dcmplx(1.d0/eps,0.d0)*(-1.d0*(dreal(potential(:,j)))+electronic_curve(j)+(E-q_ni*eps-(1.d0/dx**2)))        bb(1) = bb(1)        dd(1) = dd(1)        !The first pass (setting coefficients):        do i = 2,Nx         m = a/bb(i-1)         bb(i) = bb(i) - m*c         dd(i) = dd(i) - m*dd(i-1)        end do         vv(Nx) = dd(Nx)/bb(Nx)       !The second pass (back-substition)      do i =Nx-1, 1, -1         vv(i) = (dd(i) - c*vv(i+1))/bb(i)      end do        forall(i=1:Nx) psi_out(i,j)=vv(i)enddo!\$OMP END DO!\$OMP END PARALLEL`

I don't know what is the problem. vv, dd and bb are arrays with one dimension and length Nx. Could anyone see the problem in this code?

Best regards
R.
ruiefs

Posts: 2
Joined: Wed Mar 28, 2012 3:04 am

### Re: Problem with parellel tridiagonal solver

Maybe I'm losing something, but I do not see any problem...

Why do you have
Code: Select all
`        bb(1) = bb(1)        dd(1) = dd(1)`

?

What is the problem and how you see it?

Maybe you can "complete" the code so that it is a complete program reproducing the bahavior and I could play around a little a bit in order to see if I see something else...

Fernando.
ftinetti

Posts: 603
Joined: Wed Feb 10, 2010 2:44 pm

### Re: Problem with parellel tridiagonal solver

ftinetti wrote:Maybe I'm losing something, but I do not see any problem...

Why do you have
Code: Select all
`        bb(1) = bb(1)        dd(1) = dd(1)`

?

What is the problem and how you see it?

Maybe you can "complete" the code so that it is a complete program reproducing the bahavior and I could play around a little a bit in order to see if I see something else...

Fernando.

Hi

That part of the code is redundant. The problem is that the program compiles well but stop at the first iteration. I think, and correct me if i am wrong, that the variables that I declare as private are local to each thread and if inside of the loop I change a private array, that thread can see imideatly after that change or need to wait until the end of the cycle just as for shared variables.
ruiefs

Posts: 2
Joined: Wed Mar 28, 2012 3:04 am

### Re: Problem with parellel tridiagonal solver

The problem is that the program compiles well but stop at the first iteration

I don't see why... Are you sure there is nothing else in the loop (subroutine call/s, I/O, etc.)?

I think, and correct me if i am wrong, that the variables that I declare as private are local to each thread and if inside of the loop I change a private array, that thread can see imideatly after that change...

Yes. But I do not understand how this could be related to the wrong behavior you describe for the code...

Fernando.
ftinetti

Posts: 603
Joined: Wed Feb 10, 2010 2:44 pm

### Re: Problem with parellel tridiagonal solver

what do you mean by "stop", does the loop exit or does the program stop making progress?
james

Posts: 54
Joined: Fri May 16, 2008 9:27 am