Fortran 90 interface, workspace allocation issue

Open forum for general discussions relating to PLASMA.

Fortran 90 interface, workspace allocation issue

Postby dobson156 » Tue Dec 10, 2013 12:49 pm

I am using the following routines (however I am sure it applies to all routines with workspace allocation).

Code: Select all
    PLASMA_dsyevd
    PLASMA_dsyev
    PLASMA_dgesvd

Each of which require allocation of workspace via PLASMA's workspace allocation routines, when I call these routines from the Fortran interface the newly allocated data is not assigned to the `c_ptr` pararmeter.

The Fortran wrapper for the workspace allocation routines look like this:

in control/plasma_df90.F90 using dsyev as an example:

Code: Select all
      interface
         function PLASMA_Alloc_Workspace_dsyev_c(M,N,descT) &
          & bind(c, name='PLASMA_Alloc_Workspace_dsyev')
            use iso_c_binding
            implicit none
            integer(kind=c_int) :: PLASMA_Alloc_Workspace_dsyev_c
            integer(kind=c_int), value :: M
            integer(kind=c_int), value :: N
            type(c_ptr) :: descT ! descT is **, so pass by reference
          end function PLASMA_Alloc_Workspace_dsyev_c
      end interface

      subroutine PLASMA_Alloc_Workspace_dsyev(M,N,descT,info)
         use iso_c_binding
         implicit none                                                   
         integer(kind=c_int), intent(out) :: info                       
         integer(kind=c_int), intent(in) :: M
         integer(kind=c_int), intent(in) :: N
         type(c_ptr), value :: descT ! Arg managed by PLASMA: opaque to Fortran
         info = PLASMA_Alloc_Workspace_dsyev_c(M,N,descT)                       
      end subroutine PLASMA_Alloc_Workspace_dsyev

The error makes sense as descT is being passed by value, thus the new value is being assign to the copy rather than the c_ptr at the call site.
Changing the line defining descT in both the interface block and subroutine, so that it's intent is "inout" rather than pass by value semantics seems to fix the issue.

Code: Select all
type(c_ptr), intent(inout) :: descT

So am I doing something wrong here or should the Fortran interface be changed?

Thanks,
Joe
dobson156
 
Posts: 11
Joined: Thu Jun 21, 2012 12:50 pm

Re: Fortran 90 interface, workspace allocation issue

Postby mateo70 » Tue Dec 10, 2013 12:56 pm

Hello Joe,

Thank you for this report, we don't have many testings for the F90 interface. I'll integrate the changes to the upcoming release, that I hope will be available by the end of the month.

Regards,
Mathieu
mateo70
 
Posts: 92
Joined: Fri May 07, 2010 3:48 pm

Re: Fortran 90 interface, workspace allocation issue

Postby dobson156 » Tue Dec 10, 2013 1:18 pm

Ok, that would be great thanks.

Joe
dobson156
 
Posts: 11
Joined: Thu Jun 21, 2012 12:50 pm

Re: Fortran 90 interface, workspace allocation issue

Postby mateo70 » Tue Dec 10, 2013 1:50 pm

Hello,

I couldn't generate a patch for the former release, so here is a tarball of the new release that includes the changes. You also need to download the last release of Lapacke included in Lapack 3.5.0.
Please, let me know if you have trouble with it, so I can include the fix before the final release.

http://icl.cs.utk.edu/projectsfiles/plasma/pubs/plasma_2.6.0alpha.tar.gz

Thank you,
Mathieu
mateo70
 
Posts: 92
Joined: Fri May 07, 2010 3:48 pm

Re: Fortran 90 interface, workspace allocation issue

Postby dobson156 » Wed Dec 11, 2013 7:16 am

Thanks, just what I needed.

Does this alpha also contain the fix for the PLSAMA_WITH_ACML bug (calling omp_set_num_threads from all workers)?

Joe
dobson156
 
Posts: 11
Joined: Thu Jun 21, 2012 12:50 pm


Return to User discussion

Who is online

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

cron