[CP2K:3966] returning values from a dbcsr matrix

Urban Borštnik urban.b... at gmail.com
Thu Aug 23 13:39:14 UTC 2012


On Fri, 2012-08-03 at 13:51 -0700, Adam wrote:
> Hi,
> 
> Sorry, I need to re-ask my question better... I need to return data
> values from a dbcsr matrix (dbcsr_obj). In a row/col type of way so I
> can insert the values back into a normal fortran array. The code I'm
> working deals with an iterative, sparse matrix algorithm, and I'm
> trying to show that dbcsr can be used to speed up the process linearly
> with mpi. But I can't seem to find an easy dbcsr call to retrieve data
> by row and col. 

There is the dbcsr_get_block* family of subroutines.  Note that they
take *blocked* row and column coordinates; however, since every matrix
stores the starting offset of every row/column, it's pretty trivial to
get convert between the two.  (For example, the
dbcsr_complete_redistribute subroutine can copy data between matrices
with different distributions.  I believe it's also the workhorse
subroutine of the dbcsr_to_fm and fm_to_dbcsr subroutines.)
> 
> Is there a subroutine I could use like this (using just calls in the
> dbcsr library, libcp2k_dbcsr_lib.a), maybe a block call?
> 
> Real(8) :: BO(1000,1000)
> ...
> DO j=1, dbcsr_nblkcols_total(matrix_a)
>     DO i=1, dbcsr_nblkrows_total(matrix_a)
>          dbcsr_routine(matrix_a, i, j, matrix_val)
>          BO(i,j)=matrix_val
>     ENDDO
> ENDDOalls in the dbcsr library, libcp2k_dbcsr_lib.a), maybe a block
> call?
> 
> Real(8) :: BO(1000,1000)
> ...
> DO j=1, dbcsr_nblkcols_total(matrix_a)
>     DO i=1, dbcsr_nblkrows_total(matrix_a)
> 
A double loop like this is not good since you'r going from (hopefully)
O(N) to O(N²).  Have a look at the (cp_)dbcsr_iterator data
structure/routines that iterate through every (stored) block of a DBCSR
matrix.  For every block you can get a pointer to the data as well as
the row/column of the block, the row/column sizes of that block, and,
for convenience, the offset of the row/column.  Note, however, that you
only get data local to the MPI rank...

> Thanks anything helps,
> Adam
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "cp2k" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/cp2k/-/gjfnw8Gg_8kJ.
> To post to this group, send email to cp... at googlegroups.com.
> To unsubscribe from this group, send email to cp2k
> +unsub... at googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/cp2k?hl=en.





More information about the CP2K-user mailing list