Help with dsyev lapack function in cuda!!

Open discussion for MAGMA

Help with dsyev lapack function in cuda!!

Postby maurorodas » Tue Oct 16, 2012 1:14 pm

Hi, I'm new to this forum, I am a Ph.D. student in Colombia, in my thesis I'm working on an application in quantum chemistry, and I need to pass the LAPACK functions of my application to Cuda, and found with MAGMA, that as I read has routines I need.

One of the routines I use is dsyev LAPACK for eigenvalues ​​and eigenvectors problems, the application is written in Fortran 90, I think the equivalent in MAGMA routines are "magmaf_ssyevd" and "magmaf_dsyevd".

The problem I have is that the input parameters in LAPACK routine are:

jobz, uplo, n, a, lda, w, work, lwork, info.

But on MAGMA calls me two more parameters:

iwork and liwork

I do not know its function, I read the documentation, try to adapt my code but I get no results, someone could help with the interface to the routine work?, I appreciate your help.

The program will run on a NVIDIA Gforce GTX 480.

I apologize for my English, greetings from Colombia
maurorodas
 
Posts: 3
Joined: Tue Oct 16, 2012 12:51 pm

Re: Help with dsyev lapack function in cuda!!

Postby mgates3 » Wed Oct 17, 2012 1:35 pm

The LAPACK routine ssyevd should include the same iwork and liwork parameters. See
http://www.netlib.org/lapack/single/ssyevd.f

The MAGMA function is documented in the function itself, e.g., in magma/src/ssyevd.cpp
which is also available in the online documentation at
http://icl.cs.utk.edu/magma/docs/ssyevd_8cpp.html

Let us know if you have further questions.
-mark
mgates3
 
Posts: 413
Joined: Fri Jan 06, 2012 2:13 pm

Re: Help with dsyev lapack function in cuda!!

Postby maurorodas » Mon Oct 22, 2012 10:17 am

I've already read, thank you very much, but what I want to do is spend dsyev lapack routine to respective magma routine.

dsyev of lapack routine has no parameters: iwork and liwork, my question is with these parameters, I keep reading anyway, thank you very much
maurorodas
 
Posts: 3
Joined: Tue Oct 16, 2012 12:51 pm

Re: Help with dsyev lapack function in cuda!!

Postby maurorodas » Mon Oct 22, 2012 1:20 pm

Since the two variables thought to use dsyevd, iwork and liwork, but now I get the following error:

forrtl: severe (174): SIGSEGV, segmentation fault occurred

this code works fine with lapack, but I can not work with magma

this is my interface

Code: Select all
module MagmaInterface_

        use Cuda_Manager_, only: sizeof_real
   implicit none
       
        interface MagmaInterface

subroutine magmaf_dsyevd( jobz, uplo, n, a, lda, w, work, lwork, iwork, liwork, info)
        character          :: jobz
        character          :: uplo
        integer       :: n
        double precision    :: a(*)
        integer       :: lda
        double precision:: w(*)
        double precision    :: work(*)
        integer       :: lwork
        integer       :: iwork(*)
        integer       :: liwork
        integer       :: info
end subroutine magmaf_dsyevd

      end interface MagmaInterface

end module MagmaInterface_


And this is my code:

Code: Select all
subroutine Matrix_eigen( this, eigenValues, eigenVectors, flags, m, dm )
      implicit none
      type(Matrix), intent(in) :: this
      type(Vector), intent(inout) :: eigenValues
      type(Matrix), intent(inout), optional :: eigenVectors
      integer, intent(in), optional :: flags
      integer, intent(in), optional :: dm
      real(8), intent(in), optional :: m(:,:)

      integer :: lengthWorkSpace
      integer :: matrixSize
      integer :: infoProcess
      real(8), allocatable :: workSpace(:)
      type(Matrix) :: eigenVectorsTmp
      integer :: i

  !! Magma variables

                integer, allocatable :: iwork(:)
                integer :: liwork
               
               
      matrixSize = size( this%values, DIM=1 )
               
      if( flags == SYMMETRIC ) then

         lengthWorkSpace=3*matrixSize-1
                        liwork = -1

         allocate( workSpace( lengthWorkSpace ) )
               

         if( present( eigenVectors ) ) then

            if (present ( dm ) ) then
               eigenvectors%values = m
                                   
            else   

            eigenVectors%values=this%values
                             

            end if

            call dsyevd( &
               COMPUTE_EIGENVALUES_AND_EIGENVECTORS, &
               UPPER_TRIANGLE_IS_STORED, &
               matrixSize, &
               eigenVectors%values, &
                                        matrixSize, &
               eigenValues%values, &
                                      workSpace, &
               lengthWorkSpace, &
                                        iwork, &
                                        liwork, &
               infoProcess )

   

         else
            call Matrix_copyConstructor( eigenVectorsTmp, this )

            call dsyevd( &
               COMPUTE_EIGENVALUES, &
               UPPER_TRIANGLE_IS_STORED, &
               matrixSize, &
               eigenVectorsTmp%values, &
               matrixSize, &
               eigenValues%values, &
                                          workSpace, &
               lengthWorkSpace, &
                                        iwork, &
                                        liwork, &
               infoProcess )

            call Matrix_destructor( eigenVectorsTmp )

         end if

         
   WRITE(*,*) 'infoProcess = ', infoProcess
         if ( infoProcess /= 0 )  then

            call Matrix_exception(WARNING, "Diagonalization failed", "Class object Matrix in the getEigen() function")

         end if

         do i=1,size(eigenValues%values)
            if( eigenValues%values(i) == Math_NaN ) then

               call Matrix_exception(WARNING, "Diagonalization failed", "Class object Matrix in the getEigen() function")
            end if
         end do


         deallocate(workSpace)

      end if

   end subroutine Matrix_eigen



appreciate all your help
maurorodas
 
Posts: 3
Joined: Tue Oct 16, 2012 12:51 pm


Return to User discussion

Who is online

Users browsing this forum: Bing [Bot] and 5 guests