Skip to content

Commit

Permalink
Limit the number of parallel communication channels to reduce the mem…
Browse files Browse the repository at this point in the history
…ory footprint

The used estimate does not consider overhead from MPI which may lead to an out-of-memory event.
  • Loading branch information
Frederick Stein authored and fstein93 committed Dec 12, 2022
1 parent d8f3624 commit 904a2ce
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/input_cp2k_mp2.F
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,17 @@ SUBROUTINE create_canonical_gradients(section)
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)

CALL keyword_create( &
keyword, __LOCATION__, &
name="MAX_PARALLEL_COMM", &
description="Sets the maximum number of parallel communication steps of the non-blocking communication scheme. "// &
"The number of channels is determined from the available memory. If set to a value smaller than one, "// &
"CP2K will use all memory for communication. A value of one enforces the blocking communication scheme "// &
"increasing the communication costs.", &
default_i_val=2)
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)

END SUBROUTINE create_canonical_gradients

! **************************************************************************************************
Expand Down
1 change: 1 addition & 0 deletions src/mp2_setup.F
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ SUBROUTINE read_mp2_section(input, mp2_env)
CALL section_vals_val_get(mp2_section, "CANONICAL_GRADIENTS%EPS_CANONICAL", r_val=mp2_env%ri_grad%eps_canonical)
CALL section_vals_val_get(mp2_section, "CANONICAL_GRADIENTS%USE_OLD_GRADIENT_CODE", l_val=mp2_env%ri_grad%use_old_grad)
CALL section_vals_val_get(mp2_section, "CANONICAL_GRADIENTS%DOT_PRODUCT_BLKSIZE", i_val=mp2_env%ri_grad%dot_blksize)
CALL section_vals_val_get(mp2_section, "CANONICAL_GRADIENTS%MAX_PARALLEL_COMM", i_val=mp2_env%ri_grad%max_parallel_comm)
cphf_section => section_vals_get_subs_vals(mp2_section, "CANONICAL_GRADIENTS%CPHF")
IF (ASSOCIATED(cphf_section)) THEN
CALL section_vals_val_get(cphf_section, "MAX_ITER", i_val=mp2_env%ri_grad%cphf_max_num_iter)
Expand Down
1 change: 1 addition & 0 deletions src/mp2_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ MODULE mp2_types
LOGICAL :: free_hfx_buffer
LOGICAL :: use_old_grad
INTEGER :: dot_blksize
INTEGER :: max_parallel_comm
END TYPE

TYPE mp2_type
Expand Down
2 changes: 2 additions & 0 deletions src/rpa_grad.F
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,8 @@ SUBROUTINE calc_P_rpa(mat_S_1D, mat_work_iaP_3D, gd_homo, gd_virtual, grid, mepo
mem_per_block = REAL(number_of_elements_per_blk, KIND=dp)*8.0_dp
number_of_parallel_channels = MAX(1, MIN(MAXVAL(grid) - 1, FLOOR(mem_real/mem_per_block)))
CALL mp_min(number_of_parallel_channels, para_env%group)
IF (mp2_env%ri_grad%max_parallel_comm > 0) &
number_of_parallel_channels = MIN(number_of_parallel_channels, mp2_env%ri_grad%max_parallel_comm)
IF (unit_nr > 0) THEN
WRITE (unit_nr, '(T3,A,T75,I6)') 'GRAD_INFO| Number of parallel communication channels:', number_of_parallel_channels
Expand Down

0 comments on commit 904a2ce

Please sign in to comment.