Skip to content
Permalink
Browse files

fm: add write_info routines to get distribution info

  • Loading branch information
dev-zero committed Nov 27, 2019
1 parent cfa49ca commit 8e64f517cb430f7f3abeaf63dac84d108601a826
Showing with 68 additions and 22 deletions.
  1. +1 −1 src/fm/cp_fm_diag_utils.F
  2. +38 −2 src/fm/cp_fm_struct.F
  3. +29 −19 src/fm/cp_fm_types.F
@@ -91,7 +91,7 @@ SUBROUTINE cp_fm_redistribute_info_write(self, io_unit)

WRITE (io_unit, '(/,A,I10)') "CP_FM_DIAG| Matrix order: ", self%matrix_order
WRITE (io_unit, '(A,I6,A)') "CP_FM_DIAG| Matrix distributed on ", self%num_pe_old, " processes"
WRITE (io_unit, '(A,I5)') "CP_FM_DIAG| Optimal number of CPUs: ", self%num_pe_opt
WRITE (io_unit, '(A,I5)') "CP_FM_DIAG| Optimal number of CPUs: ", self%num_pe_opt
IF (self%num_pe_max_nz_col < 0) THEN
WRITE (io_unit, '(A,A)') "CP_FM_DIAG| Max number of CPUs (with non-zero columns): ", "<N/A>"
ELSE
@@ -44,8 +44,8 @@ MODULE cp_fm_struct
PUBLIC :: cp_fm_struct_create, cp_fm_struct_retain, cp_fm_struct_release, &
cp_fm_struct_equivalent, &
cp_fm_struct_get, cp_fm_struct_double, cp_fm_struct_config, &
cp_fm_struct_get_nrow_block, cp_fm_struct_get_ncol_block
!***
cp_fm_struct_get_nrow_block, cp_fm_struct_get_ncol_block, &
cp_fm_struct_write_info

! **************************************************************************************************
!> \brief keeps the information about the structure of a full matrix
@@ -502,6 +502,42 @@ SUBROUTINE cp_fm_struct_get(fmstruct, para_env, context, &
ENDIF
END SUBROUTINE cp_fm_struct_get

! **************************************************************************************************
!> \brief Write nicely formatted info about the FM struct to the given I/O unit
!> \param fmstruct a cp_fm_struct_type instance
!> \param io_unit the I/O unit to use for writing
! **************************************************************************************************
SUBROUTINE cp_fm_struct_write_info(fmstruct, io_unit)
TYPE(cp_fm_struct_type), INTENT(IN), POINTER :: fmstruct
INTEGER, INTENT(IN) :: io_unit

INTEGER, PARAMETER :: oblock_size = 8

CHARACTER(len=30) :: fm
INTEGER :: oblock

WRITE (fm, "(A,I2,A)") "(A,I5,A,I5,A,", oblock_size, "I6)"

WRITE (io_unit, '(A,I12)') "CP_FM_STRUCT | No. of matrix columns: ", fmstruct%ncol_global
WRITE (io_unit, '(A,I12)') "CP_FM_STRUCT | No. of matrix rows: ", fmstruct%nrow_global
WRITE (io_unit, '(A,I12)') "CP_FM_STRUCT | No. of block columns: ", fmstruct%ncol_block
WRITE (io_unit, '(A,I12)') "CP_FM_STRUCT | No. of block rows: ", fmstruct%nrow_block

WRITE (io_unit, '(A)') "CP_FM_STRUCT | Number of local columns: "
DO oblock = 0, (SIZE(fmstruct%ncol_locals) - 1)/oblock_size
WRITE (io_unit, fm) "CP_FM_STRUCT | CPUs ", &
oblock*oblock_size, "..", (oblock + 1)*oblock_size - 1, ": ", &
fmstruct%ncol_locals(oblock*oblock_size:MIN(SIZE(fmstruct%ncol_locals), (oblock + 1)*oblock_size) - 1)
END DO

WRITE (io_unit, '(A)') "CP_FM_STRUCT | Number of local rows: "
DO oblock = 0, (SIZE(fmstruct%nrow_locals) - 1)/oblock_size
WRITE (io_unit, fm) "CP_FM_STRUCT | CPUs ", &
oblock*oblock_size, "..", (oblock + 1)*oblock_size - 1, ": ", &
fmstruct%nrow_locals(oblock*oblock_size:MIN(SIZE(fmstruct%nrow_locals), (oblock + 1)*oblock_size) - 1)
END DO
END SUBROUTINE cp_fm_struct_write_info

! **************************************************************************************************
!> \brief creates a struct with twice the number of blocks on each core.
!> If matrix A has to be multiplied with B anc C, a
@@ -21,7 +21,8 @@ MODULE cp_fm_types
cp_fm_struct_get,&
cp_fm_struct_release,&
cp_fm_struct_retain,&
cp_fm_struct_type
cp_fm_struct_type,&
cp_fm_struct_write_info
USE cp_log_handling, ONLY: cp_to_string
USE cp_para_types, ONLY: cp_para_env_type
USE kinds, ONLY: dp,&
@@ -79,7 +80,8 @@ MODULE cp_fm_types
cp_fm_write_formatted, & ! writes a full matrix to an open unit
cp_fm_read_unformatted, & ! reads a full matrix from an open unit
cp_fm_setup, & ! allows to set flags for fms
cp_fm_get_mm_type
cp_fm_get_mm_type, &
cp_fm_write_info

PUBLIC :: cp_fm_indxg2p, &
cp_fm_indxg2l, &
@@ -872,23 +874,18 @@ SUBROUTINE cp_fm_get_info(matrix, name, nrow_global, ncol_global, &
row_indices, col_indices, local_data, context, &
nrow_locals, ncol_locals, matrix_struct, para_env)
TYPE(cp_fm_type), POINTER :: matrix
CHARACTER(LEN=*), OPTIONAL, INTENT(OUT) :: name
INTEGER, OPTIONAL, INTENT(OUT) :: ncol_block, ncol_global, &
nrow_block, nrow_global, &
nrow_local, ncol_local
INTEGER, OPTIONAL, DIMENSION(:), POINTER :: row_indices, col_indices, &
nrow_locals, ncol_locals
TYPE(cp_para_env_type), POINTER, OPTIONAL :: para_env
TYPE(cp_blacs_env_type), POINTER, OPTIONAL :: context
TYPE(cp_fm_struct_type), POINTER, OPTIONAL :: matrix_struct
REAL(KIND=dp), DIMENSION(:, :), POINTER, OPTIONAL :: local_data
CHARACTER(len=*), PARAMETER :: routineN = 'cp_fm_get_info', &
routineP = moduleN//':'//routineN
#if defined(__SCALAPACK)
INTEGER, EXTERNAL :: indxl2g
#endif
TYPE(cp_fm_type), POINTER :: matrix
CHARACTER(LEN=*), INTENT(OUT), OPTIONAL :: name
INTEGER, INTENT(OUT), OPTIONAL :: nrow_global, ncol_global, nrow_block, &
ncol_block, nrow_local, ncol_local
INTEGER, DIMENSION(:), OPTIONAL, POINTER :: row_indices, col_indices
REAL(KIND=dp), DIMENSION(:, :), OPTIONAL, POINTER :: local_data
TYPE(cp_blacs_env_type), OPTIONAL, POINTER :: context
INTEGER, DIMENSION(:), OPTIONAL, POINTER :: nrow_locals, ncol_locals
TYPE(cp_fm_struct_type), OPTIONAL, POINTER :: matrix_struct
TYPE(cp_para_env_type), OPTIONAL, POINTER :: para_env
CHARACTER(len=*), PARAMETER :: routineN = 'cp_fm_get_info', routineP = moduleN//':'//routineN
IF (PRESENT(name)) name = matrix%name
IF (PRESENT(context)) context => matrix%matrix_struct%context
@@ -916,6 +913,19 @@ SUBROUTINE cp_fm_get_info(matrix, name, nrow_global, ncol_global, &
END SUBROUTINE cp_fm_get_info
! **************************************************************************************************
!> \brief Write nicely formatted info about the FM to the given I/O unit (including the underlying FM struct)
!> \param matrix a cp_fm_type instance
!> \param io_unit the I/O unit to use for writing
! **************************************************************************************************
SUBROUTINE cp_fm_write_info(matrix, io_unit)
TYPE(cp_fm_type), INTENT(IN), POINTER :: matrix
INTEGER, INTENT(IN) :: io_unit
WRITE (io_unit, '(/,A,A12)') "CP_FM | Name: ", matrix%name
CALL cp_fm_struct_write_info(matrix%matrix_struct, io_unit)
END SUBROUTINE cp_fm_write_info
! **************************************************************************************************
!> \brief find the maximum absolute value of the matrix element
!> maxval(abs(matrix))

0 comments on commit 8e64f51

Please sign in to comment.
You can’t perform that action at this time.