50#include "base/base_uses.f90"
55 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cp_dbcsr_operations'
56 LOGICAL,
PARAMETER :: debug_mod = .false.
64 TYPE dbcsr_fm_thread_plan_type
65 INTEGER,
ALLOCATABLE :: blocks(:, :), slots(:)
66 END TYPE dbcsr_fm_thread_plan_type
70 TYPE(cp_fm_struct_type),
POINTER :: matrix_struct => null()
71 CHARACTER :: matrix_type =
" "
72 TYPE(dbcsr_fm_thread_plan_type),
ALLOCATABLE :: thread(:)
73 INTEGER,
ALLOCATABLE :: send_count(:), send_disp(:), recv_count(:), recv_disp(:), recv_index(:, :)
74 REAL(kind=
dp),
ALLOCATABLE :: send_values(:), recv_values(:)
96 MODULE PROCEDURE allocate_dbcsr_matrix_set_1d
97 MODULE PROCEDURE allocate_dbcsr_matrix_set_2d
98 MODULE PROCEDURE allocate_dbcsr_matrix_set_3d
99 MODULE PROCEDURE allocate_dbcsr_matrix_set_4d
100 MODULE PROCEDURE allocate_dbcsr_matrix_set_5d
104 MODULE PROCEDURE deallocate_dbcsr_matrix_set_1d
105 MODULE PROCEDURE deallocate_dbcsr_matrix_set_2d
106 MODULE PROCEDURE deallocate_dbcsr_matrix_set_3d
107 MODULE PROCEDURE deallocate_dbcsr_matrix_set_4d
108 MODULE PROCEDURE deallocate_dbcsr_matrix_set_5d
131 LOGICAL,
INTENT(IN),
OPTIONAL :: keep_sparsity
133 CHARACTER(LEN=*),
PARAMETER :: routinen =
'copy_fm_to_dbcsr'
136 LOGICAL :: my_keep_sparsity
139 CALL timeset(routinen, handle)
141 my_keep_sparsity = .false.
142 IF (
PRESENT(keep_sparsity)) my_keep_sparsity = keep_sparsity
146 IF (my_keep_sparsity)
THEN
149 CALL dbcsr_copy(matrix, redist_mat, keep_sparsity=.true.)
157 CALL timestop(handle)
170 CHARACTER(LEN=*),
PARAMETER :: routinen =
'copy_fm_to_dbcsr_bc'
172 INTEGER :: col, handle, ncol_block, ncol_global, &
173 nrow_block, nrow_global, row
174 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: first_col, first_row, last_col, last_row
175 INTEGER,
DIMENSION(:),
POINTER :: col_blk_size, row_blk_size
176 INTEGER,
DIMENSION(:, :),
POINTER :: pgrid
177 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: dbcsr_block, fm_block
181 CALL timeset(routinen, handle)
184 pgrid => fm%matrix_struct%context%blacs2mpi
187 nrow_block = fm%matrix_struct%nrow_block
188 ncol_block = fm%matrix_struct%ncol_block
189 nrow_global = fm%matrix_struct%nrow_global
190 ncol_global = fm%matrix_struct%ncol_global
191 NULLIFY (col_blk_size, row_blk_size)
192 CALL dbcsr_create_dist_block_cyclic(bc_dist, &
193 nrows=nrow_global, ncolumns=ncol_global, &
194 nrow_block=nrow_block, ncol_block=ncol_block, &
195 group_handle=fm%matrix_struct%para_env%get_handle(), pgrid=pgrid, &
196 row_blk_sizes=row_blk_size, col_blk_sizes=col_blk_size)
200 dbcsr_type_no_symmetry, row_blk_size, col_blk_size, reuse_arrays=.true.)
206 CALL calculate_fm_block_ranges(bc_mat, first_row, last_row, first_col, last_col)
210 fm_block => fm%local_data
216 dbcsr_block(:, :) = fm_block(first_row(row):last_row(row), first_col(col):last_col(col))
221 CALL timestop(handle)
237 LOGICAL,
INTENT(IN),
OPTIONAL :: check_plan
239 CHARACTER(LEN=*),
PARAMETER :: routinen =
'copy_dbcsr_to_fm'
241 CHARACTER(len=default_string_length) :: name
242 INTEGER :: group_handle, handle, ncol_block, &
243 nfullcols_total, nfullrows_total, &
245 INTEGER,
DIMENSION(:),
POINTER :: col_blk_size, row_blk_size
246 INTEGER,
DIMENSION(:, :),
POINTER :: pgrid
247 LOGICAL :: validate_plan
252 CALL timeset(routinen, handle)
253 validate_plan = .false.
254 IF (
PRESENT(check_plan)) validate_plan = check_plan
260 nfullrows_total=nfullrows_total, &
261 nfullcols_total=nfullcols_total)
263 cpassert(fm%matrix_struct%nrow_global == nfullrows_total)
264 cpassert(fm%matrix_struct%ncol_global == nfullcols_total)
267 CASE (dbcsr_type_symmetric, dbcsr_type_antisymmetric)
268 IF (
PRESENT(plan))
THEN
269 CALL copy_dbcsr_to_fm_sym(matrix, fm, plan, validate_plan)
271 CALL copy_dbcsr_to_fm_sym(matrix, fm, local_plan, .false.)
273 CALL timestop(handle)
281 nrow_block = fm%matrix_struct%nrow_block
282 ncol_block = fm%matrix_struct%ncol_block
285 NULLIFY (col_blk_size, row_blk_size)
287 CALL dbcsr_create_dist_block_cyclic(bc_dist, &
288 nrows=nfullrows_total, ncolumns=nfullcols_total, &
289 nrow_block=nrow_block, ncol_block=ncol_block, &
290 group_handle=group_handle, pgrid=pgrid, &
291 row_blk_sizes=row_blk_size, col_blk_sizes=col_blk_size)
293 CALL dbcsr_create(bc_mat,
"Block-cyclic"//name, bc_dist, &
294 dbcsr_type_no_symmetry, row_blk_size, col_blk_size, reuse_arrays=.true.)
300 CALL dbcsr_create(matrix_nosym, template=matrix, matrix_type=dbcsr_type_no_symmetry)
310 CALL timestop(handle)
321 SUBROUTINE copy_dbcsr_to_fm_sym(matrix, fm, plan, check_plan)
325 LOGICAL,
INTENT(IN) :: check_plan
327 INTEGER :: attempt, col, col_offset, i, iblock, j, &
328 k, mirror, ncol, nrecv, nrow, &
329 nthreads, pos, rebuild, row, &
331 LOGICAL :: block_matches, layout_matches, transposed
332 REAL(kind=
dp) :: symmetry_sign,
value
333 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: block
337 IF (.NOT.
ALLOCATED(plan%thread))
CALL dbcsr_to_fm_plan_create(matrix, fm, plan)
338 para_env => fm%matrix_struct%context%para_env
339 symmetry_sign = 1.0_dp
343 layout_matches =
ASSOCIATED(plan%matrix_struct, fm%matrix_struct) .AND. &
353 IF (.NOT. layout_matches .OR. nthreads /=
SIZE(plan%thread))
THEN
361 row_size=nrow, col_size=ncol, row_offset=row_offset, col_offset=col_offset)
363 block_matches = iblock <=
SIZE(plan%thread(thread)%blocks, 2)
364 IF (block_matches) block_matches = all(plan%thread(thread)%blocks(:, iblock) == &
365 [row, col, nrow, ncol, row_offset, col_offset])
366 IF (.NOT. block_matches)
THEN
373 value = symmetry_sign*block(j, i)
378 IF (mirror == 2 .AND. row == col) cycle
380 k = plan%thread(thread)%slots(pos)
381 plan%send_values(k) =
value
382 value = symmetry_sign*
value
388 IF (iblock /=
SIZE(plan%thread(thread)%blocks, 2) .OR. &
389 pos /=
SIZE(plan%thread(thread)%slots)) rebuild = 1
392 IF (check_plan)
CALL para_env%max(rebuild)
393 IF (rebuild == 0)
EXIT
394 cpassert(check_plan .AND. attempt == 1)
395 CALL dbcsr_to_fm_plan_create(matrix, fm, plan)
399 CALL para_env%alltoall(plan%send_values, plan%send_count, plan%send_disp, &
400 plan%recv_values, plan%recv_count, plan%recv_disp)
401 nrecv = sum(plan%recv_count)
402 fm%local_data = 0.0_dp
405 fm%local_data(plan%recv_index(1, k), plan%recv_index(2, k)) = plan%recv_values(k)
409 END SUBROUTINE copy_dbcsr_to_fm_sym
419 SUBROUTINE dbcsr_to_fm_plan_create(matrix, fm, plan)
424 CHARACTER(LEN=*),
PARAMETER :: routinen =
'dbcsr_to_fm_plan_create'
426 INTEGER :: col, col_offset, dest, handle, i, &
427 iblock, j, k, mirror, ncol, nproc, &
428 nrow, nthreads, pass, pos, row, &
429 row_offset, thread, x, y
430 INTEGER(KIND=int_8) :: count, offset
431 INTEGER(KIND=int_8),
ALLOCATABLE,
DIMENSION(:) :: local_pos
432 INTEGER(KIND=int_8),
ALLOCATABLE,
DIMENSION(:, :) :: thread_pos
433 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: nblocks
434 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: send_index
435 LOGICAL :: transposed
440 CALL timeset(routinen, handle)
441 fms => fm%matrix_struct
442 plan%matrix_struct => fms
444 para_env => fms%context%para_env
445 nproc = para_env%num_pe
448 ALLOCATE (thread_pos(0:nproc - 1, 0:nthreads - 1), nblocks(0:nthreads - 1))
449 ALLOCATE (plan%send_count(0:nproc - 1), plan%send_disp(0:nproc - 1), &
450 plan%recv_count(0:nproc - 1), plan%recv_disp(0:nproc - 1))
461 ALLOCATE (local_pos(0:nproc - 1))
468 cpassert(sum(thread_pos) <= int(huge(0),
int_8)/2)
469 plan%send_count(:) = int(sum(thread_pos, dim=2))
471 ALLOCATE (plan%thread(0:nthreads - 1))
472 DO k = 0, nthreads - 1
473 ALLOCATE (plan%thread(k)%blocks(6, nblocks(k)), &
474 plan%thread(k)%slots(int(sum(thread_pos(:, k)))))
477 DO dest = 0, nproc - 1
478 plan%send_disp(dest) = int(offset)
479 DO k = 0, nthreads - 1
480 count = thread_pos(dest, k)
481 thread_pos(dest, k) = offset
482 offset = offset + count
485 ALLOCATE (send_index(2, max(1, sum(plan%send_count))), &
486 plan%send_values(max(1, sum(plan%send_count))))
488 plan%send_values(:) = 0.0_dp
490 local_pos(:) = thread_pos(:, thread)
495 row_offset=row_offset, col_offset=col_offset, transposed=transposed)
498 plan%thread(thread)%blocks(:, iblock) = [row, col, nrow, ncol, row_offset, col_offset]
503 IF (mirror == 2 .AND. row == col) cycle
504 x = row_offset + i - 1
505 y = col_offset + j - 1
506 IF (mirror == 2)
THEN
507 x = col_offset + j - 1
508 y = row_offset + i - 1
510 dest = fms%context%blacs2mpi(fms%g2p_row(x), fms%g2p_col(y))
511 local_pos(dest) = local_pos(dest) + 1
513 k = int(local_pos(dest))
514 send_index(:, k) = [fms%g2l_row(x), fms%g2l_col(y)]
516 plan%thread(thread)%slots(pos) = k
523 thread_pos(:, thread) = local_pos(:)
524 nblocks(thread) = iblock
528 DEALLOCATE (local_pos)
530 DEALLOCATE (thread_pos, nblocks)
532 CALL para_env%alltoall(plan%send_count, plan%recv_count, 1)
533 cpassert(sum(int(plan%recv_count,
int_8)) <= int(huge(0),
int_8)/2)
534 plan%recv_disp(0) = 0
535 DO dest = 1, nproc - 1
536 plan%recv_disp(dest) = plan%recv_disp(dest - 1) + plan%recv_count(dest - 1)
538 ALLOCATE (plan%recv_index(2, max(1, sum(plan%recv_count))), &
539 plan%recv_values(max(1, sum(plan%recv_count))))
540 plan%recv_index(:, :) = 0
541 plan%recv_values(:) = 0.0_dp
542 CALL para_env%alltoall(send_index, 2*plan%send_count, 2*plan%send_disp, &
543 plan%recv_index, 2*plan%recv_count, 2*plan%recv_disp)
544 CALL timestop(handle)
546 END SUBROUTINE dbcsr_to_fm_plan_create
557 CHARACTER(LEN=*),
PARAMETER :: routinen =
'copy_dbcsr_to_fm_bc'
559 INTEGER :: col, handle, row
560 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: first_col, first_row, last_col, last_row
561 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: dbcsr_block, fm_block
564 CALL timeset(routinen, handle)
566 CALL calculate_fm_block_ranges(bc_mat, first_row, last_row, first_col, last_col)
569 fm_block => fm%local_data
570 fm_block = real(0.0, kind=
dp)
576 fm_block(first_row(row):last_row(row), first_col(col):last_col(col)) = dbcsr_block(:, :)
581 CALL timestop(handle)
593 SUBROUTINE calculate_fm_block_ranges(bc_mat, first_row, last_row, first_col, last_col)
595 INTEGER,
ALLOCATABLE,
DIMENSION(:),
INTENT(OUT) :: first_row, last_row, first_col, last_col
597 INTEGER :: col, nblkcols_local, nblkcols_total, &
598 nblkrows_local, nblkrows_total, row
599 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: local_col_sizes, local_row_sizes
600 INTEGER,
DIMENSION(:),
POINTER :: col_blk_size, local_cols, local_rows, &
604 nblkrows_total=nblkrows_total, &
605 nblkcols_total=nblkcols_total, &
606 nblkrows_local=nblkrows_local, &
607 nblkcols_local=nblkcols_local, &
608 local_rows=local_rows, &
609 local_cols=local_cols, &
610 row_blk_size=row_blk_size, &
611 col_blk_size=col_blk_size)
614 ALLOCATE (local_row_sizes(nblkrows_total))
615 local_row_sizes(:) = 0
616 IF (nblkrows_local >= 1)
THEN
617 DO row = 1, nblkrows_local
618 local_row_sizes(local_rows(row)) = row_blk_size(local_rows(row))
621 ALLOCATE (first_row(nblkrows_total), last_row(nblkrows_total))
622 CALL dbcsr_convert_sizes_to_offsets(local_row_sizes, first_row, last_row)
623 DEALLOCATE (local_row_sizes)
626 ALLOCATE (local_col_sizes(nblkcols_total))
627 local_col_sizes(:) = 0
628 IF (nblkcols_local >= 1)
THEN
629 DO col = 1, nblkcols_local
630 local_col_sizes(local_cols(col)) = col_blk_size(local_cols(col))
633 ALLOCATE (first_col(nblkcols_total), last_col(nblkcols_total))
634 CALL dbcsr_convert_sizes_to_offsets(local_col_sizes, first_col, last_col)
635 DEALLOCATE (local_col_sizes)
637 END SUBROUTINE calculate_fm_block_ranges
651 ncol, source_start, target_start, para_env, blacs_env)
655 INTEGER,
INTENT(IN) :: ncol, source_start, target_start
659 INTEGER :: nfullcols_total, nfullrows_total
664 CALL dbcsr_get_info(matrix_a, nfullrows_total=nfullrows_total, nfullcols_total=nfullcols_total)
666 ncol_global=nfullcols_total, para_env=para_env)
667 CALL cp_fm_create(fm_matrix_a, fm_struct, name=
"fm_matrix_a")
670 CALL dbcsr_get_info(matrix_b, nfullrows_total=nfullrows_total, nfullcols_total=nfullcols_total)
672 ncol_global=nfullcols_total, para_env=para_env)
673 CALL cp_fm_create(fm_matrix_b, fm_struct, name=
"fm_matrix_b")
679 CALL cp_fm_to_fm(fm_matrix_a, fm_matrix_b, ncol, source_start, target_start)
699 INTEGER,
DIMENSION(:),
POINTER :: col_dist, row_dist
700 INTEGER,
DIMENSION(:, :),
POINTER :: col_dist_data, pgrid, row_dist_data
707 row_distribution=row_dist_data, &
708 col_distribution=col_dist_data, &
710 CALL blacs_env%get(para_env=para_env, blacs2mpi=pgrid)
713 row_dist => row_dist_data(:, 1)
714 col_dist => col_dist_data(:, 1)
719 group=para_env%get_handle(), pgrid=pgrid, &
737 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: vec_b
738 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT) :: vec_c
739 INTEGER,
INTENT(in),
OPTIONAL :: ncol
740 REAL(
dp),
INTENT(IN),
OPTIONAL :: alpha
742 CHARACTER(LEN=*),
PARAMETER :: routinen =
'dbcsr_multiply_local'
744 INTEGER :: col, coloff, my_ncol, row, rowoff, &
747 REAL(
dp) :: my_alpha, my_alpha2
748 REAL(
dp),
DIMENSION(:, :),
POINTER :: data_d
751 CALL timeset(routinen, timing_handle)
754 IF (
PRESENT(alpha)) my_alpha = alpha
756 my_ncol =
SIZE(vec_b, 2)
757 IF (
PRESENT(ncol)) my_ncol = ncol
771 IF (my_ncol /= 1)
THEN
772 CALL dgemm(
'N',
'N', &
773 SIZE(data_d, 1), my_ncol,
SIZE(data_d, 2), &
774 my_alpha, data_d(1, 1),
SIZE(data_d, 1), &
775 vec_b(coloff, 1),
SIZE(vec_b, 1), &
776 1.0_dp, vec_c(rowoff, 1),
SIZE(vec_c, 1))
778 CALL dgemv(
'N',
SIZE(data_d, 1),
SIZE(data_d, 2), &
779 my_alpha, data_d(1, 1),
SIZE(data_d, 1), &
780 vec_b(coloff, 1), 1, &
781 1.0_dp, vec_c(rowoff, 1), 1)
794 IF (my_ncol /= 1)
THEN
795 CALL dgemm(
'T',
'N', &
796 SIZE(data_d, 2), my_ncol,
SIZE(data_d, 1), &
797 my_alpha2, data_d(1, 1),
SIZE(data_d, 1), &
798 vec_b(rowoff, 1),
SIZE(vec_b, 1), &
799 1.0_dp, vec_c(coloff, 1),
SIZE(vec_c, 1))
801 CALL dgemv(
'T',
SIZE(data_d, 1),
SIZE(data_d, 2), &
802 my_alpha2, data_d(1, 1),
SIZE(data_d, 1), &
803 vec_b(rowoff, 1), 1, &
804 1.0_dp, vec_c(coloff, 1), 1)
811 CALL timestop(timing_handle)
832 INTEGER,
INTENT(IN) :: ncol
833 REAL(
dp),
INTENT(IN),
OPTIONAL :: alpha, beta
835 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_dbcsr_sm_fm_multiply'
837 INTEGER :: a_ncol, a_nrow, b_ncol, b_nrow, c_ncol, &
838 c_nrow, k_in, k_out, timing_handle, &
840 INTEGER,
DIMENSION(:),
POINTER :: col_blk_size, col_blk_size_right_in, &
841 col_blk_size_right_out, col_dist, &
842 row_blk_size, row_dist
845 REAL(
dp) :: my_alpha, my_beta
847 CALL timeset(routinen, timing_handle)
851 IF (
PRESENT(alpha)) my_alpha = alpha
852 IF (
PRESENT(beta)) my_beta = beta
855 CALL cp_fm_get_info(fm_in, ncol_global=b_ncol, nrow_global=b_nrow)
856 CALL cp_fm_get_info(fm_out, ncol_global=c_ncol, nrow_global=c_nrow)
857 CALL dbcsr_get_info(matrix, nfullrows_total=a_nrow, nfullcols_total=a_ncol)
871 IF (ncol > 0 .AND. k_out > 0 .AND. k_in > 0)
THEN
872 CALL dbcsr_get_info(matrix, row_blk_size=row_blk_size, col_blk_size=col_blk_size, distribution=dist)
875 CALL dbcsr_create(in,
"D", dist_right_in, dbcsr_type_no_symmetry, &
876 col_blk_size, col_blk_size_right_in)
881 row_dist=row_dist, col_dist=col_dist)
882 ALLOCATE (col_blk_size_right_out(
SIZE(col_blk_size_right_in)))
883 col_blk_size_right_out = col_blk_size_right_in
884 CALL match_col_sizes(col_blk_size_right_out, col_blk_size_right_in, k_out)
891 CALL dbcsr_create(out,
"D", product_dist, dbcsr_type_no_symmetry, &
892 row_blk_size, col_blk_size_right_out)
895 IF (ncol /= k_out .OR. my_beta /= 0.0_dp)
THEN
899 CALL timeset(routinen//
'_core', timing_handle_mult)
900 CALL dbcsr_multiply(
"N",
"N", my_alpha, matrix, in, my_beta, out, &
902 CALL timestop(timing_handle_mult)
908 DEALLOCATE (col_blk_size_right_in, col_blk_size_right_out)
914 CALL timestop(timing_handle)
924 SUBROUTINE match_col_sizes(sizes1, sizes2, full_num)
925 INTEGER,
DIMENSION(:),
INTENT(INOUT) :: sizes1
926 INTEGER,
DIMENSION(:),
INTENT(IN) :: sizes2
927 INTEGER,
INTENT(IN) :: full_num
929 INTEGER :: left, n1, n2, p, rm, used
934 cpabort(
"distributions must be equal!")
936 sizes1(1:n1) = sizes2(1:n1)
937 used = sum(sizes1(1:n1))
941 IF (used < full_num)
THEN
942 sizes1(n1) = sizes1(n1) + full_num - used
944 left = used - full_num
946 DO WHILE (left > 0 .AND. p > 0)
947 rm = min(left, sizes1(p))
948 sizes1(p) = sizes1(p) - rm
953 END SUBROUTINE match_col_sizes
974 TYPE(
dbcsr_type),
INTENT(INOUT) :: sparse_matrix
976 TYPE(
cp_fm_type),
INTENT(IN),
OPTIONAL :: matrix_g
977 INTEGER,
INTENT(IN) :: ncol
978 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: alpha
979 LOGICAL,
INTENT(IN),
OPTIONAL :: keep_sparsity
980 INTEGER,
INTENT(IN),
OPTIONAL :: symmetry_mode
982 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_dbcsr_plus_fm_fm_t'
984 INTEGER :: k, my_symmetry_mode, nao, npcols, &
986 INTEGER,
DIMENSION(:),
POINTER :: col_blk_size_left, col_dist_left, &
987 row_blk_size, row_dist
988 LOGICAL :: check_product, my_keep_sparsity
989 REAL(kind=
dp) :: my_alpha, norm
993 TYPE(
dbcsr_type) :: mat_g, mat_v, sparse_matrix2, &
996 check_product = .false.
998 CALL timeset(routinen, timing_handle)
1000 my_keep_sparsity = .true.
1001 IF (
PRESENT(keep_sparsity)) my_keep_sparsity = keep_sparsity
1003 my_symmetry_mode = 0
1004 IF (
PRESENT(symmetry_mode)) my_symmetry_mode = symmetry_mode
1006 NULLIFY (col_dist_left)
1010 cpabort(
"sparse_matrix must pre-exist")
1018 CALL create_bl_distribution(col_dist_left, col_blk_size_left, k, npcols)
1020 row_dist=row_dist, col_dist=col_dist_left)
1021 DEALLOCATE (col_dist_left)
1023 CALL dbcsr_create(mat_v,
"DBCSR matrix_v", dist_left, dbcsr_type_no_symmetry, &
1024 row_blk_size, col_blk_size_left)
1029 IF (
PRESENT(matrix_g))
THEN
1030 CALL dbcsr_create(mat_g,
"DBCSR matrix_g", dist_left, dbcsr_type_no_symmetry, &
1031 row_blk_size, col_blk_size_left)
1035 DEALLOCATE (col_blk_size_left)
1039 IF (check_product)
THEN
1041 CALL cp_fm_struct_create(fm_struct_tmp, context=matrix_v%matrix_struct%context, nrow_global=nao, &
1042 ncol_global=nao, para_env=matrix_v%matrix_struct%para_env)
1043 CALL cp_fm_create(fm_matrix, fm_struct_tmp, name=
"fm matrix")
1046 CALL dbcsr_copy(sparse_matrix3, sparse_matrix)
1050 IF (
PRESENT(alpha)) my_alpha = alpha
1051 IF (
PRESENT(matrix_g))
THEN
1052 IF (my_symmetry_mode == 1)
THEN
1055 1.0_dp, sparse_matrix, &
1056 retain_sparsity=my_keep_sparsity, &
1059 1.0_dp, sparse_matrix, &
1060 retain_sparsity=my_keep_sparsity, &
1062 ELSE IF (my_symmetry_mode == -1)
THEN
1065 1.0_dp, sparse_matrix, &
1066 retain_sparsity=my_keep_sparsity, &
1069 1.0_dp, sparse_matrix, &
1070 retain_sparsity=my_keep_sparsity, &
1075 1.0_dp, sparse_matrix, &
1076 retain_sparsity=my_keep_sparsity, &
1081 1.0_dp, sparse_matrix, &
1082 retain_sparsity=my_keep_sparsity, &
1086 IF (check_product)
THEN
1087 IF (
PRESENT(matrix_g))
THEN
1088 IF (my_symmetry_mode == 1)
THEN
1089 CALL cp_fm_gemm(
"N",
"T", nao, nao, ncol, 0.5_dp*my_alpha, matrix_v, matrix_g, &
1091 CALL cp_fm_gemm(
"N",
"T", nao, nao, ncol, 0.5_dp*my_alpha, matrix_g, matrix_v, &
1093 ELSE IF (my_symmetry_mode == -1)
THEN
1094 CALL cp_fm_gemm(
"N",
"T", nao, nao, ncol, 0.5_dp*my_alpha, matrix_v, matrix_g, &
1096 CALL cp_fm_gemm(
"N",
"T", nao, nao, ncol, -0.5_dp*my_alpha, matrix_g, matrix_v, &
1099 CALL cp_fm_gemm(
"N",
"T", nao, nao, ncol, my_alpha, matrix_v, matrix_g, &
1103 CALL cp_fm_gemm(
"N",
"T", nao, nao, ncol, my_alpha, matrix_v, matrix_v, &
1107 CALL dbcsr_copy(sparse_matrix2, sparse_matrix)
1108 CALL dbcsr_scale(sparse_matrix2, alpha_scalar=0.0_dp)
1109 CALL copy_fm_to_dbcsr(fm_matrix, sparse_matrix2, keep_sparsity=my_keep_sparsity)
1110 CALL dbcsr_add(sparse_matrix2, sparse_matrix, alpha_scalar=1.0_dp, &
1111 beta_scalar=-1.0_dp)
1113 WRITE (*, *)
'nao=', nao,
' k=', k,
' ncol=', ncol,
' my_alpha=', my_alpha
1114 WRITE (*, *)
'PRESENT (matrix_g)',
PRESENT(matrix_g)
1116 WRITE (*, *)
'norm(sm+alpha*v*g^t - fm+alpha*v*g^t)/n=', norm/real(nao,
dp)
1124 CALL timestop(timing_handle)
1144 INTEGER,
DIMENSION(:),
POINTER :: col_blk_size_right_in, row_blk_size
1152 CALL dbcsr_create(matrix,
"D", dist_right_in, dbcsr_type_no_symmetry, &
1153 row_blk_size, col_blk_size_right_in)
1156 DEALLOCATE (col_blk_size_right_in)
1173 TYPE(
dbcsr_type),
INTENT(INOUT) :: matrix, template
1174 INTEGER,
INTENT(IN) :: m, n
1175 CHARACTER,
INTENT(IN),
OPTIONAL :: sym
1178 INTEGER :: npcols, nprows
1179 INTEGER,
DIMENSION(:),
POINTER :: col_blk_size, col_dist, row_blk_size, &
1183 CALL dbcsr_get_info(template, matrix_type=mysym, distribution=tmpl_dist)
1185 IF (
PRESENT(sym)) mysym = sym
1187 NULLIFY (row_dist, col_dist)
1188 NULLIFY (row_blk_size, col_blk_size)
1192 CALL create_bl_distribution(row_dist, row_blk_size, m, nprows)
1193 CALL create_bl_distribution(col_dist, col_blk_size, n, npcols)
1195 row_dist=row_dist, col_dist=col_dist, &
1197 reuse_arrays=.true.)
1199 CALL dbcsr_create(matrix,
"m_n_template", dist_m_n, mysym, &
1200 row_blk_size, col_blk_size, reuse_arrays=.true.)
1216 TYPE(
dbcsr_type),
INTENT(INOUT) :: matrix, template
1218 CHARACTER,
OPTIONAL :: sym
1222 INTEGER,
DIMENSION(:),
POINTER :: col_blk_size, col_dist, row_blk_size, &
1227 IF (
PRESENT(sym)) mysym = sym
1234 NULLIFY (col_dist, col_blk_size)
1235 CALL create_bl_distribution(col_dist, col_blk_size, n, npcols)
1237 row_dist=row_dist, col_dist=col_dist)
1240 CALL dbcsr_create(matrix,
"m_n_template", dist_m_n, mysym, row_blk_size, col_blk_size)
1242 DEALLOCATE (col_dist, col_blk_size)
1257 SUBROUTINE create_bl_distribution(block_distribution, &
1258 block_size, nelements, nbins)
1259 INTEGER,
DIMENSION(:),
INTENT(OUT),
POINTER :: block_distribution, block_size
1260 INTEGER,
INTENT(IN) :: nelements, nbins
1262 CHARACTER(len=*),
PARAMETER :: routinen =
'create_bl_distribution', &
1263 routinep = modulen//
':'//routinen
1265 INTEGER :: bin, blk_layer, element_stack, els, &
1266 estimated_blocks, max_blocks_per_bin, &
1267 nblks, nblocks, stat
1268 INTEGER,
DIMENSION(:),
POINTER :: blk_dist, blk_sizes
1272 NULLIFY (block_distribution)
1273 NULLIFY (block_size)
1275 IF (nelements > 0)
THEN
1278 max_blocks_per_bin = ceiling(real(nblocks, kind=
dp)/real(nbins, kind=
dp))
1281 WRITE (*,
'(1X,A,1X,A,I7,A,I7,A)') routinep,
"For", nelements, &
1282 " elements and", nbins,
" bins"
1283 WRITE (*,
'(1X,A,1X,A,I7,A)') routinep,
"There are", &
1285 WRITE (*,
'(1X,A,1X,A,I7,A)') routinep,
"There are", &
1287 WRITE (*,
'(1X,A,1X,A,I7,A)') routinep,
"There are", &
1288 max_blocks_per_bin,
" max blocks/bin"
1291 estimated_blocks = max_blocks_per_bin*nbins
1292 ALLOCATE (blk_dist(estimated_blocks), stat=stat)
1296 ALLOCATE (blk_sizes(estimated_blocks), stat=stat)
1298 cpabort(
"blk_sizes")
1302 DO blk_layer = 1, max_blocks_per_bin
1303 DO bin = 0, nbins - 1
1306 element_stack = element_stack + els
1308 blk_dist(nblks) = bin
1309 blk_sizes(nblks) = els
1310 IF (debug_mod)
WRITE (*,
'(1X,A,I5,A,I5,A,I5)') routinep//
" Assigning", &
1311 els,
" elements as block", nblks,
" to bin", bin
1316 IF (nblks == estimated_blocks)
THEN
1317 block_distribution => blk_dist
1318 block_size => blk_sizes
1320 ALLOCATE (block_distribution(nblks), stat=stat)
1324 block_distribution(:) = blk_dist(1:nblks)
1325 DEALLOCATE (blk_dist)
1326 ALLOCATE (block_size(nblks), stat=stat)
1328 cpabort(
"blk_sizes")
1330 block_size(:) = blk_sizes(1:nblks)
1331 DEALLOCATE (blk_sizes)
1334 ALLOCATE (block_distribution(0), stat=stat)
1338 ALLOCATE (block_size(0), stat=stat)
1340 cpabort(
"blk_sizes")
13431579
FORMAT(i5, 1x, i5, 1x, i5, 1x, i5, 1x, i5, 1x, i5, 1x, i5, 1x, i5, 1x, i5, 1x, i5)
1345 WRITE (*,
'(1X,A,A)') routinep//
" Distribution"
1346 WRITE (*, 1579) block_distribution(:)
1347 WRITE (*,
'(1X,A,A)') routinep//
" Sizes"
1348 WRITE (*, 1579) block_size(:)
1350 END SUBROUTINE create_bl_distribution
1364 right_col_blk_sizes)
1367 INTEGER,
INTENT(IN) :: ncolumns
1368 INTEGER,
DIMENSION(:),
INTENT(OUT),
POINTER :: right_col_blk_sizes
1370 INTEGER :: multiplicity, ncols, nimages, npcols, &
1372 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: tmp_images
1373 INTEGER,
DIMENSION(:),
POINTER :: old_col_dist, right_col_dist, &
1378 col_dist=old_col_dist, &
1383 CALL create_bl_distribution(right_col_dist, right_col_blk_sizes, ncolumns, npcols)
1385 ALLOCATE (right_row_dist(ncols), tmp_images(ncols))
1386 nimages =
lcm(nprows, npcols)/nprows
1387 multiplicity = nprows/
gcd(nprows, npcols)
1388 CALL rebin_distribution(right_row_dist, tmp_images, old_col_dist, nprows, multiplicity, nimages)
1391 template=dist_left, &
1392 row_dist=right_row_dist, &
1393 col_dist=right_col_dist, &
1396 reuse_arrays=.true.)
1397 DEALLOCATE (tmp_images)
1433 SUBROUTINE rebin_distribution(new_bins, images, source_bins, &
1434 nbins, multiplicity, nimages)
1435 INTEGER,
DIMENSION(:),
INTENT(OUT) :: new_bins, images
1436 INTEGER,
DIMENSION(:),
INTENT(IN) :: source_bins
1437 INTEGER,
INTENT(IN) :: nbins, multiplicity, nimages
1439 INTEGER :: bin, i, old_nbins, virtual_bin
1440 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: bin_multiplier
1444 IF (mod(nbins*nimages, multiplicity) /= 0)
THEN
1445 cpwarn(
"mulitplicity is not divisor of new process grid coordinate")
1447 old_nbins = (nbins*nimages)/multiplicity
1448 ALLOCATE (bin_multiplier(0:old_nbins - 1))
1449 bin_multiplier(:) = 0
1450 DO i = 1,
SIZE(new_bins)
1451 IF (i <=
SIZE(source_bins))
THEN
1452 bin = source_bins(i)
1455 bin = mod(i, old_nbins)
1457 virtual_bin = bin*multiplicity + bin_multiplier(bin)
1458 new_bins(i) = virtual_bin/nimages
1459 images(i) = 1 + mod(virtual_bin, nimages)
1460 bin_multiplier(bin) = bin_multiplier(bin) + 1
1461 IF (bin_multiplier(bin) >= multiplicity)
THEN
1462 bin_multiplier(bin) = 0
1465 END SUBROUTINE rebin_distribution
1482 SUBROUTINE dbcsr_create_dist_block_cyclic(dist, nrows, ncolumns, &
1483 nrow_block, ncol_block, group_handle, pgrid, row_blk_sizes, col_blk_sizes)
1485 INTEGER,
INTENT(IN) :: nrows, ncolumns, nrow_block, ncol_block, &
1487 INTEGER,
DIMENSION(:, :),
POINTER :: pgrid
1488 INTEGER,
DIMENSION(:),
INTENT(OUT),
POINTER :: row_blk_sizes, col_blk_sizes
1490 CHARACTER(len=*),
PARAMETER :: routinen =
'dbcsr_create_dist_block_cyclic'
1492 INTEGER :: nblkcols, nblkrows, npcols, nprows, &
1494 INTEGER,
DIMENSION(:),
POINTER :: cd_data, rd_data
1497 IF (nrow_block == 0)
THEN
1501 nblkrows = nrows/nrow_block
1502 sz = mod(nrows, nrow_block)
1504 IF (sz > 0) nblkrows = nblkrows + 1
1505 ALLOCATE (row_blk_sizes(nblkrows), rd_data(nblkrows))
1506 row_blk_sizes = nrow_block
1507 IF (sz /= 0) row_blk_sizes(nblkrows) = sz
1510 IF (ncol_block == 0)
THEN
1514 nblkcols = ncolumns/ncol_block
1515 sz = mod(ncolumns, ncol_block)
1517 IF (sz > 0) nblkcols = nblkcols + 1
1518 ALLOCATE (col_blk_sizes(nblkcols), cd_data(nblkcols))
1519 col_blk_sizes = ncol_block
1520 IF (sz /= 0) col_blk_sizes(nblkcols) = sz
1523 WRITE (*, *) routinen//
" nrows,nrow_block,nblkrows=", &
1524 nrows, nrow_block, nblkrows
1525 WRITE (*, *) routinen//
" ncols,ncol_block,nblkcols=", &
1526 ncolumns, ncol_block, nblkcols
1529 nprows =
SIZE(pgrid, 1)
1530 DO pdim = 0, min(nprows - 1, nblkrows - 1)
1531 rd_data(1 + pdim:nblkrows:nprows) = pdim
1534 npcols =
SIZE(pgrid, 2)
1535 DO pdim = 0, min(npcols - 1, nblkcols - 1)
1536 cd_data(1 + pdim:nblkcols:npcols) = pdim
1540 WRITE (*, *) routinen//
" row_dist", &
1542 WRITE (*, *) routinen//
" col_dist", &
1547 group=group_handle, pgrid=pgrid, &
1550 reuse_arrays=.true.)
1552 END SUBROUTINE dbcsr_create_dist_block_cyclic
1561 SUBROUTINE allocate_dbcsr_matrix_set_1d(matrix_set, nmatrix)
1562 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_set
1563 INTEGER,
INTENT(IN) :: nmatrix
1568 ALLOCATE (matrix_set(nmatrix))
1569 DO imatrix = 1, nmatrix
1570 NULLIFY (matrix_set(imatrix)%matrix)
1572 END SUBROUTINE allocate_dbcsr_matrix_set_1d
1582 SUBROUTINE allocate_dbcsr_matrix_set_2d(matrix_set, nmatrix, mmatrix)
1583 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_set
1584 INTEGER,
INTENT(IN) :: nmatrix, mmatrix
1586 INTEGER :: imatrix, jmatrix
1589 ALLOCATE (matrix_set(nmatrix, mmatrix))
1590 DO jmatrix = 1, mmatrix
1591 DO imatrix = 1, nmatrix
1592 NULLIFY (matrix_set(imatrix, jmatrix)%matrix)
1595 END SUBROUTINE allocate_dbcsr_matrix_set_2d
1606 SUBROUTINE allocate_dbcsr_matrix_set_3d(matrix_set, nmatrix, mmatrix, pmatrix)
1607 TYPE(
dbcsr_p_type),
DIMENSION(:, :, :),
POINTER :: matrix_set
1608 INTEGER,
INTENT(IN) :: nmatrix, mmatrix, pmatrix
1610 INTEGER :: imatrix, jmatrix, kmatrix
1613 ALLOCATE (matrix_set(nmatrix, mmatrix, pmatrix))
1614 DO kmatrix = 1, pmatrix
1615 DO jmatrix = 1, mmatrix
1616 DO imatrix = 1, nmatrix
1617 NULLIFY (matrix_set(imatrix, jmatrix, kmatrix)%matrix)
1621 END SUBROUTINE allocate_dbcsr_matrix_set_3d
1633 SUBROUTINE allocate_dbcsr_matrix_set_4d(matrix_set, nmatrix, mmatrix, pmatrix, qmatrix)
1634 TYPE(
dbcsr_p_type),
DIMENSION(:, :, :, :),
POINTER :: matrix_set
1635 INTEGER,
INTENT(IN) :: nmatrix, mmatrix, pmatrix, qmatrix
1637 INTEGER :: imatrix, jmatrix, kmatrix, lmatrix
1640 ALLOCATE (matrix_set(nmatrix, mmatrix, pmatrix, qmatrix))
1641 DO lmatrix = 1, qmatrix
1642 DO kmatrix = 1, pmatrix
1643 DO jmatrix = 1, mmatrix
1644 DO imatrix = 1, nmatrix
1645 NULLIFY (matrix_set(imatrix, jmatrix, kmatrix, lmatrix)%matrix)
1650 END SUBROUTINE allocate_dbcsr_matrix_set_4d
1663 SUBROUTINE allocate_dbcsr_matrix_set_5d(matrix_set, nmatrix, mmatrix, pmatrix, qmatrix, smatrix)
1665 POINTER :: matrix_set
1666 INTEGER,
INTENT(IN) :: nmatrix, mmatrix, pmatrix, qmatrix, &
1669 INTEGER :: hmatrix, imatrix, jmatrix, kmatrix, &
1673 ALLOCATE (matrix_set(nmatrix, mmatrix, pmatrix, qmatrix, smatrix))
1674 DO hmatrix = 1, smatrix
1675 DO lmatrix = 1, qmatrix
1676 DO kmatrix = 1, pmatrix
1677 DO jmatrix = 1, mmatrix
1678 DO imatrix = 1, nmatrix
1679 NULLIFY (matrix_set(imatrix, jmatrix, kmatrix, lmatrix, hmatrix)%matrix)
1685 END SUBROUTINE allocate_dbcsr_matrix_set_5d
1693 SUBROUTINE deallocate_dbcsr_matrix_set_1d(matrix_set)
1695 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_set
1699 IF (
ASSOCIATED(matrix_set))
THEN
1700 DO imatrix = lbound(matrix_set, 1), ubound(matrix_set, 1)
1703 DEALLOCATE (matrix_set)
1706 END SUBROUTINE deallocate_dbcsr_matrix_set_1d
1714 SUBROUTINE deallocate_dbcsr_matrix_set_2d(matrix_set)
1716 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_set
1718 INTEGER :: imatrix, jmatrix
1720 IF (
ASSOCIATED(matrix_set))
THEN
1721 DO jmatrix = lbound(matrix_set, 2), ubound(matrix_set, 2)
1722 DO imatrix = lbound(matrix_set, 1), ubound(matrix_set, 1)
1726 DEALLOCATE (matrix_set)
1728 END SUBROUTINE deallocate_dbcsr_matrix_set_2d
1736 SUBROUTINE deallocate_dbcsr_matrix_set_3d(matrix_set)
1738 TYPE(
dbcsr_p_type),
DIMENSION(:, :, :),
POINTER :: matrix_set
1740 INTEGER :: imatrix, jmatrix, kmatrix
1742 IF (
ASSOCIATED(matrix_set))
THEN
1743 DO kmatrix = lbound(matrix_set, 3), ubound(matrix_set, 3)
1744 DO jmatrix = lbound(matrix_set, 2), ubound(matrix_set, 2)
1745 DO imatrix = lbound(matrix_set, 1), ubound(matrix_set, 1)
1750 DEALLOCATE (matrix_set)
1752 END SUBROUTINE deallocate_dbcsr_matrix_set_3d
1760 SUBROUTINE deallocate_dbcsr_matrix_set_4d(matrix_set)
1762 TYPE(
dbcsr_p_type),
DIMENSION(:, :, :, :),
POINTER :: matrix_set
1764 INTEGER :: imatrix, jmatrix, kmatrix, lmatrix
1766 IF (
ASSOCIATED(matrix_set))
THEN
1767 DO lmatrix = lbound(matrix_set, 4), ubound(matrix_set, 4)
1768 DO kmatrix = lbound(matrix_set, 3), ubound(matrix_set, 3)
1769 DO jmatrix = lbound(matrix_set, 2), ubound(matrix_set, 2)
1770 DO imatrix = lbound(matrix_set, 1), ubound(matrix_set, 1)
1776 DEALLOCATE (matrix_set)
1778 END SUBROUTINE deallocate_dbcsr_matrix_set_4d
1786 SUBROUTINE deallocate_dbcsr_matrix_set_5d(matrix_set)
1789 POINTER :: matrix_set
1791 INTEGER :: hmatrix, imatrix, jmatrix, kmatrix, &
1794 IF (
ASSOCIATED(matrix_set))
THEN
1795 DO hmatrix = lbound(matrix_set, 5), ubound(matrix_set, 5)
1796 DO lmatrix = lbound(matrix_set, 4), ubound(matrix_set, 4)
1797 DO kmatrix = lbound(matrix_set, 3), ubound(matrix_set, 3)
1798 DO jmatrix = lbound(matrix_set, 2), ubound(matrix_set, 2)
1799 DO imatrix = lbound(matrix_set, 1), ubound(matrix_set, 1)
1806 DEALLOCATE (matrix_set)
1808 END SUBROUTINE deallocate_dbcsr_matrix_set_5d
static void dgemm(const char transa, const char transb, const int m, const int n, const int k, const double alpha, const double *a, const int lda, const double *b, const int ldb, const double beta, double *c, const int ldc)
Convenient wrapper to hide Fortran nature of dgemm_, swapping a and b.
methods related to the blacs parallel environment
subroutine, public dbcsr_verify_matrix(matrix, verbosity, local)
...
subroutine, public dbcsr_distribution_release(dist)
...
subroutine, public dbcsr_scale(matrix, alpha_scalar)
...
subroutine, public dbcsr_distribution_new(dist, template, group, pgrid, row_dist, col_dist, reuse_arrays)
...
subroutine, public dbcsr_deallocate_matrix(matrix)
...
character function, public dbcsr_get_matrix_type(matrix)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
logical function, public dbcsr_valid_index(matrix)
...
subroutine, public dbcsr_desymmetrize(matrix_a, matrix_b)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_multiply(transa, transb, alpha, matrix_a, matrix_b, beta, matrix_c, first_row, last_row, first_column, last_column, first_k, last_k, retain_sparsity, filter_eps, flop)
...
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset, transposed)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_complete_redistribute(matrix, redist)
...
subroutine, public dbcsr_iterator_readonly_start(iterator, matrix, shared, dynamic, dynamic_byrows)
Like dbcsr_iterator_start() but with matrix being INTENT(IN). When invoking this routine,...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
subroutine, public dbcsr_distribution_get(dist, row_dist, col_dist, nrows, ncols, has_threads, group, mynode, numnodes, nprows, npcols, myprow, mypcol, pgrid, subgroups_defined, prow_group, pcol_group)
...
subroutine, public dbcsr_reserve_all_blocks(matrix)
Reserves all blocks.
real(dp) function, public dbcsr_frobenius_norm(matrix)
Compute the frobenius norm of a dbcsr matrix.
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_sm_fm_multiply(matrix, fm_in, fm_out, ncol, alpha, beta)
multiply a dbcsr with a fm matrix
integer, save, public max_elements_per_block
subroutine, public copy_dbcsr_to_fm(matrix, fm, plan, check_plan)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public dbcsr_create_dist_r_unrot(dist_right, dist_left, ncolumns, right_col_blk_sizes)
Creates a new distribution for the right matrix in a matrix multiplication with unrotated grid.
subroutine, public dbcsr_multiply_local(matrix_a, vec_b, vec_c, ncol, alpha)
multiply a dbcsr with a replicated array c = alpha_scalar * A (dbscr) * b + c
subroutine, public cp_dbcsr_dist2d_to_dist(dist2d, dist)
Creates a DBCSR distribution from a distribution_2d.
subroutine, public copy_fm_to_dbcsr_bc(fm, bc_mat)
Copy a BLACS matrix to a dbcsr matrix with a special block-cyclic distribution, which requires no com...
subroutine, public copy_dbcsr_to_fm_bc(bc_mat, fm)
Copy a DBCSR_BLACS matrix to a BLACS matrix.
subroutine, public cp_fm_to_dbcsr_row_template(matrix, fm_in, template)
Utility function to copy a specially shaped fm to dbcsr_matrix The result matrix will be the matrix i...
subroutine, public cp_dbcsr_m_by_n_from_row_template(matrix, template, n, sym)
Utility function to create dbcsr matrix, m x n matrix (n arbitrary) with the same processor grid and ...
subroutine, public cp_dbcsr_plus_fm_fm_t(sparse_matrix, matrix_v, matrix_g, ncol, alpha, keep_sparsity, symmetry_mode)
performs the multiplication sparse_matrix+dense_mat*dens_mat^T if matrix_g is not explicitly given,...
subroutine, public cp_dbcsr_m_by_n_from_template(matrix, template, m, n, sym)
Utility function to create an arbitrary shaped dbcsr matrix with the same processor grid as the templ...
subroutine, public dbcsr_copy_columns_hack(matrix_b, matrix_a, ncol, source_start, target_start, para_env, blacs_env)
hack for dbcsr_copy_columns
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_gemm(transa, transb, m, n, k, alpha, matrix_a, matrix_b, beta, matrix_c, a_first_col, a_first_row, b_first_col, b_first_row, c_first_col, c_first_row)
computes matrix_c = beta * matrix_c + alpha * ( matrix_a ** transa ) * ( matrix_b ** transb )
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
stores a mapping of 2D info (e.g. matrix) on a 2D processor distribution (i.e. blacs grid) where cpus...
subroutine, public distribution_2d_get(distribution_2d, row_distribution, col_distribution, n_row_distribution, n_col_distribution, n_local_rows, n_local_cols, local_rows, local_cols, flat_local_rows, flat_local_cols, n_flat_local_rows, n_flat_local_cols, blacs_env)
returns various attributes about the distribution_2d
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
integer, parameter, public default_string_length
Collection of simple mathematical functions and subroutines.
elemental integer function, public lcm(a, b)
computes the least common multiplier of two numbers
elemental integer function, public gcd(a, b)
computes the greatest common divisor of two number
Interface to the message passing library MPI.
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
keeps the information about the structure of a full matrix
distributes pairs on a 2d grid of processors
stores all the informations relevant to an mpi environment