CP2K 2.4 (Revision 12889)
Classes | Functions | Variables

dbcsr_work_operations Namespace Reference

DBCSR work matrix utilities. More...

Classes

interface  dbcsr_create
struct  i_array_p

Functions

subroutine dbcsr_create_new (matrix, name, dist, matrix_type, row_blk_size, col_blk_size, nblks, nze, data_type, data_memory_type, index_memory_type, reuse, mutable_work, replication_type, error)
 Creates a matrix, allocating the essentials.
subroutine dbcsr_create_template (matrix, template, name, dist, matrix_type, row_blk_size, col_blk_size, nblks, nze, data_type, data_memory_type, index_memory_type, reuse, mutable_work, replication_type, error)
subroutine dbcsr_init_wm (wm, data_type, nblks_guess, sizedata_guess, error)
 Initializes one work matrix.
subroutine, public dbcsr_work_create (matrix, nblks_guess, sizedata_guess, n, work_mutable, error)
 Creates a the working matrix(es) for a DBCSR matrix.
subroutine, public dbcsr_finalize (matrix, resort, reshuffle, error)
 Creates the final dbcsr_type matrix from the working matrix.
subroutine, public dbcsr_special_finalize (matrix, reshuffle, error)
LOGICAL can_quickly_finalize (matrix)
 Checks whether the matrix can be finalized with minimal copying.
subroutine quick_finalize (matrix, error)
 Performs quick finalization of matrix.
subroutine, public dbcsr_add_wm_from_matrix (matrix, limits, error)
 Creates a work matrix from the data present in a finalized matrix.
subroutine dbcsr_fill_wm_from_matrix (wm, matrix, size_used, limits, error)
 Fills index and data of the work matrix from the previously-finalized one.
LOGICAL within_limits (row, column, limits)
 Checks whether a point is within bounds.
subroutine, public dbcsr_work_destroy (wm)
 Deallocates and destroys a work matrix.
subroutine dbcsr_work_destroy_all (m)
 Deallocates and destroys a work matrix.
subroutine, public add_work_coordinate (matrix, row, col, blk, index, error)
 Adds a coordinate (or other data) into a work matrix's row_i and col_i arrays and returns its position.
pure subroutine dbcsr_count_wm (row_i, col_i, row_block_sizes, col_block_sizes, nblks, nze)
 Count actual size taken by work matrix.
subroutine dbcsr_merge_all (matrix, old_row_p, old_col_i, old_blk_p, data_starting_offset, sort_data, error)
 Merge data from matrix and work matrices into the final matrix.
subroutine dbcsr_merge_single_wm (matrix, error)
 Each thread has a work matrix. These must be merged and made into a new index. If sort_data is False, then the data areas are simply appended. This is probably quicker but the data blocks are not in order and the data size may expand beyond what is needed. If sort_data is True, then data blocks are sorted in order.
subroutine merge_index (new_row_p, new_col_i, new_blk_p, blk_d, old_row_p, old_col_i, old_blk_p, all_row_p, all_col_i, all_blk_p, all_data_offsets, nwms, nrows, max_row_count, sort_data, error)
 There is a single work matrix. Data blocks are sorted and copied into the matrix data area (which is empty). The index is made consistent.

Variables

CHARACTER(len=*), parameter,
private 
moduleN = 'dbcsr_work_operations'
REAL, parameter default_resize_factor = 1.618034
LOGICAL, parameter careful_mod = .FALSE.

Detailed Description

DBCSR work matrix utilities.

Author:
Urban Borstnik
Date:
2010-02-18
Version:
0.9

Modification history:


Function Documentation

subroutine,public dbcsr_work_operations::add_work_coordinate ( TYPE(dbcsr_work_type),intent(inout)  matrix,
INTEGER,intent(in)  row,
INTEGER,intent(in)  col,
INTEGER,intent(in),optional  blk,
INTEGER,intent(out),optional  index,
TYPE(dbcsr_error_type),intent(inout)  error 
)

Adds a coordinate (or other data) into a work matrix's row_i and col_i arrays and returns its position.

Note:
Uses the matrixlastblk to keep track of the current position.
Parameters:
[in,out]matrixwork matrix
[in]row,colrow, col data to add
[in]blk(optional) block pointer to add
[out]index(optional) saved position
errorcp2k error

Definition at line 1372 of file dbcsr_work_operations.f90.

References dbcsr_data_methods::careful_mod, dbcsr_error_handling::dbcsr_error_set(), dbcsr_error_handling::dbcsr_error_stop(), and dbcsr_data_methods::default_resize_factor.

Referenced by cp_dbcsr_operations::copy_cfm_to_dbcsr(), cp_dbcsr_operations::copy_fm_to_dbcsr(), and dbcsr_fill_wm_from_matrix().

Here is the call graph for this function:

Here is the caller graph for this function:

LOGICAL dbcsr_work_operations::can_quickly_finalize ( TYPE(dbcsr_obj),intent(in)  matrix) [private]

Checks whether the matrix can be finalized with minimal copying.

Parameters:
[in]matrixmatrix to check
Returns:
quick whether matrix can be quickly finalized

Definition at line 1023 of file dbcsr_work_operations.f90.

References dbcsr_data_methods::dbcsr_data_get_memory_type(), and dbcsr_methods::dbcsr_wm_use_mutable().

Referenced by dbcsr_finalize(), and dbcsr_special_finalize().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public dbcsr_work_operations::dbcsr_add_wm_from_matrix ( TYPE(dbcsr_obj),intent(inout)  matrix,
INTEGER,dimension(4),intent(in),optional  limits,
TYPE(dbcsr_error_type),intent(inout)  error 
)

Creates a work matrix from the data present in a finalized matrix.

Parameters:
[in,out]matrixDBCSR matrix
[in]limits(optional) the limits to use for copying
[in,out]errorerror

Definition at line 1104 of file dbcsr_work_operations.f90.

References dbcsr_error_handling::dbcsr_caller_error, dbcsr_error_handling::dbcsr_error_set(), dbcsr_error_handling::dbcsr_error_stop(), dbcsr_error_handling::dbcsr_fatal_level, dbcsr_fill_wm_from_matrix(), dbcsr_error_handling::dbcsr_internal_error, dbcsr_error_handling::dbcsr_warning_level, and dbcsr_work_create().

Referenced by dbcsr_finalize(), and dbcsr_operations::dbcsr_multiply_anytype().

Here is the call graph for this function:

Here is the caller graph for this function:

pure subroutine dbcsr_work_operations::dbcsr_count_wm ( INTEGER,dimension(nblks),intent(in)  row_i,
INTEGER,dimension(nblks),intent(in)  col_i,
INTEGER,dimension(:),intent(in)  row_block_sizes,
INTEGER,dimension(:),intent(in)  col_block_sizes,
INTEGER,intent(in)  nblks,
INTEGER,intent(out)  nze 
) [private]

Count actual size taken by work matrix.

Parameters:
[in]row_irow indices
[in]col_icolumn indices
[in]row_block_sizesoffsets of rows
[in]col_block_sizesoffsets of columns
[in]nblksnumber of blocks
[out]nzecounted data size

Definition at line 1413 of file dbcsr_work_operations.f90.

subroutine dbcsr_work_operations::dbcsr_create_new ( TYPE(dbcsr_obj),intent(inout)  matrix,
CHARACTER(len=*),intent(in)  name,
TYPE(dbcsr_distribution_obj),intent(in)  dist,
CHARACTER,intent(in)  matrix_type,
TYPE(array_i1d_obj),intent(in)  row_blk_size,
TYPE(array_i1d_obj),intent(in)  col_blk_size,
INTEGER,intent(in),optional  nblks,
INTEGER,intent(in),optional  nze,
INTEGER,intent(in),optional  data_type,
INTEGER,intent(in),optional  data_memory_type,
INTEGER,intent(in),optional  index_memory_type,
LOGICAL,intent(in),optional  reuse,
LOGICAL,intent(in),optional  mutable_work,
CHARACTER,intent(in),optional  replication_type,
TYPE(dbcsr_error_type),intent(inout)  error 
) [private]

Creates a matrix, allocating the essentials.

The matrix itself is allocated, as well as the essential parts of
the index. When passed the nze argument, the data is also allocated to that size.
Parameters:
[in,out]matrixnew matrix
[in]distdistribution_2d distribution
[in]matrix_type'N' for normal, 'T' for transposed, 'S' for symmetric, and 'A' for antisymmetric
[in]nblks(optional) number of blocks
[in]nze(optional) number of elements
[in]data_typetype of data from [rRcC] for single/double precision real/complex, default is 'R'
[in]memory_type(optional) allocate indices and data using special memory
[in]index_memory_type(optional) allocate indices using special memory
[in]reuse(optional) reuses an existing matrix, default is to create a fresh one
[in]mutable_workuses the mutable data for working and not the append-only data; default is append-only
[in]replication_typereplication to be used for this matrix; default is dbcsr_repl_none
See also:
dbcsr_types.F
Parameters:
[in,out]errorcp2k error

Definition at line 158 of file dbcsr_work_operations.f90.

References dbcsr_util::convert_sizes_to_offsets(), dbcsr_block_buffers::dbcsr_buffers_2d_needed, dbcsr_error_handling::dbcsr_caller_error, dbcsr_data_methods::dbcsr_data_init(), dbcsr_data_methods::dbcsr_data_new(), dbcsr_data_methods::dbcsr_data_set_size_referenced(), dbcsr_methods::dbcsr_distribution_hold(), dbcsr_methods::dbcsr_distribution_ncols(), dbcsr_methods::dbcsr_distribution_nrows(), dbcsr_methods::dbcsr_distribution_release(), dbcsr_error_handling::dbcsr_error_set(), dbcsr_error_handling::dbcsr_error_stop(), dbcsr_error_handling::dbcsr_failure_level, dbcsr_error_handling::dbcsr_fatal_level, dbcsr_error_handling::dbcsr_internal_error, dbcsr_types::dbcsr_magic_number, dbcsr_methods::dbcsr_matrix_counter, dbcsr_types::dbcsr_memory_default, dbcsr_types::dbcsr_meta_size, dbcsr_types::dbcsr_num_slots, dbcsr_types::dbcsr_repl_col, dbcsr_types::dbcsr_repl_full, dbcsr_types::dbcsr_repl_none, dbcsr_types::dbcsr_repl_row, dbcsr_types::dbcsr_slot_nblkcols_local, dbcsr_types::dbcsr_slot_nblkcols_total, dbcsr_types::dbcsr_slot_nblkrows_local, dbcsr_types::dbcsr_slot_nblkrows_total, dbcsr_types::dbcsr_slot_nfullcols_local, dbcsr_types::dbcsr_slot_nfullcols_total, dbcsr_types::dbcsr_slot_nfullrows_local, dbcsr_types::dbcsr_slot_nfullrows_total, dbcsr_types::dbcsr_slot_size, dbcsr_types::dbcsr_type_antihermitian, dbcsr_types::dbcsr_type_antisymmetric, dbcsr_types::dbcsr_type_complex_4, dbcsr_types::dbcsr_type_complex_8, dbcsr_types::dbcsr_type_hermitian, dbcsr_types::dbcsr_type_no_symmetry, dbcsr_types::dbcsr_type_real_4, dbcsr_types::dbcsr_type_real_8, dbcsr_types::dbcsr_type_real_default, dbcsr_types::dbcsr_type_symmetric, dbcsr_error_handling::dbcsr_unimplemented_error_nr, dbcsr_error_handling::dbcsr_warning_level, dbcsr_work_destroy_all(), dbcsr_error_handling::dbcsr_wrong_args_error, and error.

Here is the call graph for this function:

subroutine dbcsr_work_operations::dbcsr_create_template ( TYPE(dbcsr_obj),intent(inout)  matrix,
TYPE(dbcsr_obj),intent(in)  template,
CHARACTER(len=*),intent(in),optional  name,
TYPE(dbcsr_distribution_obj),intent(in),optional  dist,
CHARACTER,intent(in),optional  matrix_type,
TYPE(array_i1d_obj),intent(in),optional  row_blk_size,
TYPE(array_i1d_obj),intent(in),optional  col_blk_size,
INTEGER,intent(in),optional  nblks,
INTEGER,intent(in),optional  nze,
INTEGER,intent(in),optional  data_type,
INTEGER,intent(in),optional  data_memory_type,
INTEGER,intent(in),optional  index_memory_type,
LOGICAL,intent(in),optional  reuse,
LOGICAL,intent(in),optional  mutable_work,
CHARACTER,intent(in),optional  replication_type,
TYPE(dbcsr_error_type),intent(inout)  error 
) [private]
subroutine dbcsr_work_operations::dbcsr_fill_wm_from_matrix ( TYPE(dbcsr_work_type),dimension(:),intent(inout)  wm,
TYPE(dbcsr_obj),intent(inout)  matrix,
INTEGER,intent(in)  size_used,
INTEGER,dimension(4),intent(in),optional  limits,
TYPE(dbcsr_error_type),intent(inout)  error 
) [private]
subroutine,public dbcsr_work_operations::dbcsr_finalize ( TYPE(dbcsr_obj),intent(inout)  matrix,
LOGICAL,intent(in),optional  resort,
LOGICAL,intent(in),optional  reshuffle,
TYPE(dbcsr_error_type),intent(inout)  error 
)

Creates the final dbcsr_type matrix from the working matrix.

Work matrices (array or tree-based) are merged into the base DBCSR matrix.

If a matrix is marked as having a valid index, then nothing is done.

Deleted blocks are pruned from the index.

Parameters:
[in,out]matrixfinal matrix
[in]resortwhether the indices should be sorted, default is true
[in]reshufflewhether the data should be reshuffled, default is false
errorcp2k error

Definition at line 689 of file dbcsr_work_operations.f90.

References can_quickly_finalize(), dbcsr_add_wm_from_matrix(), dbcsr_index_operations::dbcsr_addto_index_array(), dbcsr_block_buffers::dbcsr_buffers_2d_needed, dbcsr_error_handling::dbcsr_caller_error, dbcsr_data_methods::dbcsr_data_get_size(), dbcsr_data_methods::dbcsr_data_get_size_referenced(), dbcsr_error_handling::dbcsr_error_set(), dbcsr_error_handling::dbcsr_error_stop(), dbcsr_error_handling::dbcsr_fatal_level, dbcsr_methods::dbcsr_get_data_size_used(), dbcsr_merge_all(), dbcsr_types::dbcsr_slot_blk_p, dbcsr_types::dbcsr_slot_col_i, dbcsr_types::dbcsr_slot_nze, dbcsr_types::dbcsr_slot_row_p, dbcsr_error_handling::dbcsr_warning_level, dbcsr_methods::dbcsr_wm_use_mutable(), dbcsr_work_create(), dbcsr_work_destroy_all(), and quick_finalize().

Referenced by dbcsr_example_1(), dbcsr_example_2(), and dbcsr_example_3().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine dbcsr_work_operations::dbcsr_init_wm ( TYPE(dbcsr_work_type),intent(out)  wm,
INTEGER,intent(in)  data_type,
INTEGER,intent(in),optional  nblks_guess,
INTEGER,intent(in),optional  sizedata_guess,
TYPE(dbcsr_error_type),intent(inout)  error 
) [private]

Initializes one work matrix.

Parameters:
[out]wminitialized work matrix
[in]nblks_guess(optional) estimated number of blocks
[in]sizedata_guess(optional) estimated size of data

Definition at line 534 of file dbcsr_work_operations.f90.

References dbcsr_data_methods::dbcsr_data_init(), dbcsr_data_methods::dbcsr_data_new(), dbcsr_error_handling::dbcsr_error_set(), dbcsr_error_handling::dbcsr_error_stop(), dbcsr_error_handling::dbcsr_fatal_level, dbcsr_error_handling::dbcsr_internal_error, dbcsr_methods::dbcsr_mutable_init(), and dbcsr_error_handling::dbcsr_wrong_args_error.

Referenced by dbcsr_work_create().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine dbcsr_work_operations::dbcsr_merge_all ( TYPE(dbcsr_type),intent(inout)  matrix,
INTEGER,dimension(*),intent(in)  old_row_p,
INTEGER,dimension(*),intent(in)  old_col_i,
INTEGER,dimension(*),intent(in)  old_blk_p,
INTEGER,intent(in)  data_starting_offset,
LOGICAL,intent(in)  sort_data,
TYPE(dbcsr_error_type),intent(inout)  error 
) [private]
subroutine dbcsr_work_operations::dbcsr_merge_single_wm ( TYPE(dbcsr_type),intent(inout)  matrix,
TYPE(dbcsr_error_type),intent(inout)  error 
) [private]

Each thread has a work matrix. These must be merged and made into a new index. If sort_data is False, then the data areas are simply appended. This is probably quicker but the data blocks are not in order and the data size may expand beyond what is needed. If sort_data is True, then data blocks are sorted in order.

OutlineSort data from the WM into the final matrix, based closely on dbcsr_merge_all
Parameters:
[in,out]matrixmatrix to work on
[in,out]errorerror

Definition at line 1741 of file dbcsr_work_operations.f90.

References dbcsr_index_operations::dbcsr_addto_index_array(), dbcsr_error_handling::dbcsr_caller_error, dbcsr_data_methods::dbcsr_data_ensure_size(), dbcsr_error_handling::dbcsr_error_set(), dbcsr_error_handling::dbcsr_error_stop(), dbcsr_error_handling::dbcsr_fatal_level, dbcsr_types::dbcsr_slot_blk_p, dbcsr_types::dbcsr_slot_col_i, dbcsr_types::dbcsr_slot_nblks, dbcsr_types::dbcsr_slot_nze, dbcsr_types::dbcsr_slot_row_p, and dbcsr_methods::dbcsr_wm_use_mutable().

Referenced by dbcsr_special_finalize().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public dbcsr_work_operations::dbcsr_special_finalize ( TYPE(dbcsr_obj),intent(inout)  matrix,
LOGICAL,intent(in),optional  reshuffle,
TYPE(dbcsr_error_type),intent(inout)  error 
)
subroutine,public dbcsr_work_operations::dbcsr_work_create ( TYPE(dbcsr_obj),intent(inout)  matrix,
INTEGER,intent(in),optional  nblks_guess,
INTEGER,intent(in),optional  sizedata_guess,
INTEGER,intent(in),optional  n,
LOGICAL,intent(in),optional  work_mutable,
TYPE(dbcsr_error_type),intent(inout)  error 
)

Creates a the working matrix(es) for a DBCSR matrix.

Parameters:
[out]matrixnew matrix
[in]nblks_guess(optional) estimated number of blocks
[in]sizedata_guess(optional) estimated size of data
[in]n(optional) number work matrices to create, default is 1
[in]work_mutable(optional) use mutable work type, default is what was specified in create
[in,out]errorcp2k error

Definition at line 600 of file dbcsr_work_operations.f90.

References dbcsr_error_handling::dbcsr_caller_error, dbcsr_error_handling::dbcsr_error_set(), dbcsr_error_handling::dbcsr_error_stop(), dbcsr_error_handling::dbcsr_fatal_level, dbcsr_init_wm(), dbcsr_error_handling::dbcsr_internal_error, dbcsr_types::dbcsr_magic_number, dbcsr_methods::dbcsr_mutable_new(), dbcsr_error_handling::dbcsr_warning_level, and error.

Referenced by dbcsr_add_wm_from_matrix(), and dbcsr_finalize().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public dbcsr_work_operations::dbcsr_work_destroy ( TYPE(dbcsr_work_type),intent(inout)  wm)

Deallocates and destroys a work matrix.

Parameters:
[in,out]wmwork matrix

Definition at line 1304 of file dbcsr_work_operations.f90.

References dbcsr_data_methods::dbcsr_data_release(), and dbcsr_methods::dbcsr_mutable_destroy().

Referenced by dbcsr_work_destroy_all().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine dbcsr_work_operations::dbcsr_work_destroy_all ( TYPE(dbcsr_type),intent(inout)  m) [private]

Deallocates and destroys a work matrix.

Parameters:
[in,out]wmwork matrix
[in,out]errorcp2k error
keepdatado not deallocate data
keepfinaldo not destroy the final, non-work matrix
keepfinaldatado not destroy the data in the final, non-work matrix

Definition at line 1338 of file dbcsr_work_operations.f90.

References dbcsr_error_handling::dbcsr_caller_error, dbcsr_error_handling::dbcsr_warning_level, and dbcsr_work_destroy().

Referenced by dbcsr_create_new(), dbcsr_finalize(), and dbcsr_special_finalize().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine dbcsr_work_operations::merge_index ( INTEGER,dimension(*),intent(in)  new_row_p,
INTEGER,dimension(*),intent(out),target  new_col_i,
INTEGER,dimension(*),intent(out),target  new_blk_p,
INTEGER,dimension(*),intent(in),target  blk_d,
INTEGER,dimension(*),intent(in)  old_row_p,
INTEGER,dimension(*),intent(in)  old_col_i,
INTEGER,dimension(*),intent(in)  old_blk_p,
TYPE(i_array_p),dimension(*),intent(in)  all_row_p,
TYPE(i_array_p),dimension(*),intent(in)  all_col_i,
TYPE(i_array_p),dimension(*),intent(in)  all_blk_p,
INTEGER,dimension(*),intent(in)  all_data_offsets,
INTEGER,intent(in)  nwms,
INTEGER,intent(in)  nrows,
INTEGER,intent(in)  max_row_count,
LOGICAL,intent(in)  sort_data,
TYPE(dbcsr_error_type),intent(inout)  error 
) [private]

There is a single work matrix. Data blocks are sorted and copied into the matrix data area (which is empty). The index is made consistent.

OutlineBuilds a new index from several work matrices.
Parameters:
[in]wmwork matrix
[in,out]additions_per_rownumber of blocks and data to add for every row
[out]additions_totaltotal number of blocks and data to add
[out]blk_pblock sizes of data to add
[in,out]errorerror

Definition at line 1845 of file dbcsr_work_operations.f90.

References dbcsr_error_handling::dbcsr_error_set(), dbcsr_error_handling::dbcsr_error_stop(), and error.

Referenced by dbcsr_merge_all().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine dbcsr_work_operations::quick_finalize ( TYPE(dbcsr_obj),intent(inout)  matrix,
TYPE(dbcsr_error_type),intent(inout)  error 
) [private]

Performs quick finalization of matrix.

The data area from the work matrix is accepted as the new matrix's data area and the index is built from the work matrix.

Parameters:
[in,out]matrixmatrix to finalize
[in,out]errorerror

Definition at line 1054 of file dbcsr_work_operations.f90.

References dbcsr_index_operations::dbcsr_addto_index_array(), dbcsr_error_handling::dbcsr_error_set(), dbcsr_error_handling::dbcsr_error_stop(), dbcsr_types::dbcsr_slot_blk_p, dbcsr_types::dbcsr_slot_col_i, dbcsr_types::dbcsr_slot_nblks, dbcsr_types::dbcsr_slot_nze, dbcsr_types::dbcsr_slot_row_p, and dbcsr_methods::dbcsr_switch_data_area().

Referenced by dbcsr_finalize(), and dbcsr_special_finalize().

Here is the call graph for this function:

Here is the caller graph for this function:

LOGICAL dbcsr_work_operations::within_limits ( INTEGER,intent(in)  row,
INTEGER,intent(in)  column,
INTEGER,dimension(4),intent(in)  limits 
) [private]

Checks whether a point is within bounds.

Parameters:
[in]row,columnpoint to check
[in]limitslimits (low_row, high_row, low_col, high_col)
Returns:
whether the point is within the bounds

Definition at line 1290 of file dbcsr_work_operations.f90.

Referenced by dbcsr_fill_wm_from_matrix().

Here is the caller graph for this function:


Variable Documentation

LOGICAL,parameter dbcsr_work_operations::careful_mod = .FALSE.

Definition at line 112 of file dbcsr_work_operations.f90.

Definition at line 111 of file dbcsr_work_operations.f90.

CHARACTER(len=*),parameter,private dbcsr_work_operations::moduleN = 'dbcsr_work_operations'

Definition at line 109 of file dbcsr_work_operations.f90.