- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With the risk of annoying you, i am posting my problem clearly. there is a matrix multiplication code:
module mmat
CONTAINS
subroutine matmult(ap5,i,srl)
use kinds
use parameters
use mthread
implicit none
integer(i3),intent(in):: i
integer(i3):: j,l,ii,jj,k
real*8:: sumk
real*8, dimension(lorbit,lorbit),intent(in):: ap5
real*8, dimension(lorbit,lorbit,0:nrsite),intent(inout):: srl
real(8),dimension(lorbit,lorbit)::t,t1
real*8::alpha=1.0, beta=0.0
do j=1,lorbit
do l=1,lorbit
sumk=0.0d0
do k=1,lorbit
sumk=sumk+srl(j,k,i)*ap5(k,l)
enddo
threadcontext%ap61(j,l)=sumk
enddo
enddo
do j=1,lorbit
do l=1,lorbit
sumk=0.0d0
do k=1,lorbit
sumk=sumk+ap5(j,k)*threadcontext%ap61(k,l)
enddo
threadcontext%ap71(j,l)=sumk
enddo
enddo
do j=1,lorbit
do k=1,lorbit
srl(j,k,i)=threadcontext%ap71(j,k)
enddo
enddo
end subroutine matmult
end module mmat
module mthread
use parameters
implicit none
type::typethread
sequence
real*8,dimension(lorbit,lorbit)::ap61,ap71
end type typethread
type(typethread):: threadcontext
common/context/threadcontext
!$omp threadprivate(/context/)
end module mthread
which is called in the main routine as:
!$OMP PARALLEL DO schedule(static,1)
do i=1,nrsite
call matmult(ap5,i,srl)
end do
!$OMP END PARALLEL DO
for the smaller lorbit, this method was ok, but as lorbit grows,as is shown by bubin(check this thread), it is advantegious to use external multiplication code(LAPACK here) as:
call dgemm('N','N',lorbit,lorbit,lorbit,alpha,t,lorbit,ap5,lorbit,beta,ap61,lorbit)]
but this will not work as ap61 is derived data type in this case. Is there any wayout?
hope i am explicit enough. plz suggest something.
module mmat
CONTAINS
subroutine matmult(ap5,i,srl)
use kinds
use parameters
use mthread
implicit none
integer(i3),intent(in):: i
integer(i3):: j,l,ii,jj,k
real*8:: sumk
real*8, dimension(lorbit,lorbit),intent(in):: ap5
real*8, dimension(lorbit,lorbit,0:nrsite),intent(inout):: srl
real(8),dimension(lorbit,lorbit)::t,t1
real*8::alpha=1.0, beta=0.0
do j=1,lorbit
do l=1,lorbit
sumk=0.0d0
do k=1,lorbit
sumk=sumk+srl(j,k,i)*ap5(k,l)
enddo
threadcontext%ap61(j,l)=sumk
enddo
enddo
do j=1,lorbit
do l=1,lorbit
sumk=0.0d0
do k=1,lorbit
sumk=sumk+ap5(j,k)*threadcontext%ap61(k,l)
enddo
threadcontext%ap71(j,l)=sumk
enddo
enddo
do j=1,lorbit
do k=1,lorbit
srl(j,k,i)=threadcontext%ap71(j,k)
enddo
enddo
end subroutine matmult
end module mmat
module mthread
use parameters
implicit none
type::typethread
sequence
real*8,dimension(lorbit,lorbit)::ap61,ap71
end type typethread
type(typethread):: threadcontext
common/context/threadcontext
!$omp threadprivate(/context/)
end module mthread
which is called in the main routine as:
!$OMP PARALLEL DO schedule(static,1)
do i=1,nrsite
call matmult(ap5,i,srl)
end do
!$OMP END PARALLEL DO
for the smaller lorbit, this method was ok, but as lorbit grows,as is shown by bubin(check this thread), it is advantegious to use external multiplication code(LAPACK here) as:
call dgemm('N','N',lorbit,lorbit,lorbit,alpha,t,lorbit,ap5,lorbit,beta,ap61,lorbit)]
but this will not work as ap61 is derived data type in this case. Is there any wayout?
hope i am explicit enough. plz suggest something.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
roddur,
Add the two thread context references to the argument list on the call
!$OMP PARALLEL DO schedule(static,1)
do i=1,nrsite
call matmult(ap5,i,srl, threadcontext%ap61, threadcontext%ap71)
end do
!$OMP END PARALLEL DO
Then add and useinside the subroutine reference the dummy arguments for ap61 and ap71
Note, you may need to use a modified name for ap61 and ap71 if the names conflict with global names in USE.
Jim Dempsey

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page