bem_mpi Module

MPIの初期化・集約を抽象化し、非MPIビルドでは単一ランク動作へフォールバックする。


Uses

  • module~~bem_mpi~~UsesGraph module~bem_mpi bem_mpi module~bem_kinds bem_kinds module~bem_mpi->module~bem_kinds iso_fortran_env iso_fortran_env module~bem_kinds->iso_fortran_env

Used by

  • module~~bem_mpi~~UsedByGraph module~bem_mpi bem_mpi module~bem_app_config_particle_runtime bem_app_config_particle_runtime module~bem_app_config_particle_runtime->module~bem_mpi module~bem_electrostatic_snapshot bem_electrostatic_snapshot module~bem_app_config_particle_runtime->module~bem_electrostatic_snapshot module~bem_app_config_potential_runtime bem_app_config_potential_runtime module~bem_app_config_particle_runtime->module~bem_app_config_potential_runtime module~bem_coulomb_fmm_core bem_coulomb_fmm_core module~bem_coulomb_fmm_core->module~bem_mpi module~bem_coulomb_fmm_types bem_coulomb_fmm_types module~bem_coulomb_fmm_core->module~bem_coulomb_fmm_types module~bem_coulomb_fmm_periodic_root_ops bem_coulomb_fmm_periodic_root_ops module~bem_coulomb_fmm_periodic_root_ops->module~bem_mpi module~bem_coulomb_fmm_periodic_root_ops->module~bem_coulomb_fmm_types module~bem_coulomb_fmm_basis bem_coulomb_fmm_basis module~bem_coulomb_fmm_periodic_root_ops->module~bem_coulomb_fmm_basis module~bem_coulomb_fmm_periodic bem_coulomb_fmm_periodic module~bem_coulomb_fmm_periodic_root_ops->module~bem_coulomb_fmm_periodic module~bem_coulomb_fmm_periodic_cell_cache bem_coulomb_fmm_periodic_cell_cache module~bem_coulomb_fmm_periodic_root_ops->module~bem_coulomb_fmm_periodic_cell_cache module~bem_coulomb_fmm_periodic_ewald bem_coulomb_fmm_periodic_ewald module~bem_coulomb_fmm_periodic_root_ops->module~bem_coulomb_fmm_periodic_ewald module~bem_coulomb_fmm_state_ops bem_coulomb_fmm_state_ops module~bem_coulomb_fmm_state_ops->module~bem_mpi module~bem_coulomb_fmm_state_ops->module~bem_coulomb_fmm_types module~bem_coulomb_fmm_tree_utils bem_coulomb_fmm_tree_utils module~bem_coulomb_fmm_state_ops->module~bem_coulomb_fmm_tree_utils module~bem_coulomb_fmm_types->module~bem_mpi module~bem_electrostatic_snapshot->module~bem_mpi module~bem_field_solver bem_field_solver module~bem_electrostatic_snapshot->module~bem_field_solver module~bem_field_solver->module~bem_mpi module~bem_field_solver->module~bem_coulomb_fmm_core module~bem_performance_profile bem_performance_profile module~bem_performance_profile->module~bem_mpi module~bem_periodic_checkpoint bem_periodic_checkpoint module~bem_periodic_checkpoint->module~bem_mpi module~bem_restart bem_restart module~bem_periodic_checkpoint->module~bem_restart module~bem_output_writer bem_output_writer module~bem_periodic_checkpoint->module~bem_output_writer module~bem_restart->module~bem_mpi module~bem_restart_injection bem_restart_injection module~bem_restart_injection->module~bem_mpi module~bem_restart_injection->module~bem_restart module~bem_simulator bem_simulator module~bem_simulator->module~bem_mpi module~bem_simulator->module~bem_electrostatic_snapshot module~bem_app_config_runtime bem_app_config_runtime module~bem_simulator->module~bem_app_config_runtime module~bem_simulator->module~bem_output_writer module~bem_particle_stepper bem_particle_stepper module~bem_simulator->module~bem_particle_stepper module~bem_run_outputs bem_run_outputs module~bem_simulator->module~bem_run_outputs module~bem_surface_models bem_surface_models module~bem_simulator->module~bem_surface_models module~bem_app_config bem_app_config module~bem_simulator->module~bem_app_config module~bem_simulator_loop bem_simulator_loop module~bem_simulator_loop->module~bem_mpi module~bem_simulator_loop->module~bem_performance_profile module~bem_simulator_loop->module~bem_periodic_checkpoint module~bem_simulator_loop->module~bem_simulator module~bem_zhao_outflow_refresh bem_zhao_outflow_refresh module~bem_simulator_loop->module~bem_zhao_outflow_refresh module~bem_simulator_loop->module~bem_app_config_runtime module~bem_simulator_loop->module~bem_output_writer module~bem_simulator_loop->module~bem_run_outputs module~bem_zhao_outflow_refresh->module~bem_mpi module~bem_zhao_outflow_refresh->module~bem_app_config program~main main program~main->module~bem_mpi program~main->module~bem_electrostatic_snapshot program~main->module~bem_performance_profile program~main->module~bem_periodic_checkpoint program~main->module~bem_restart program~main->module~bem_simulator program~main->module~bem_output_writer program~main->module~bem_run_outputs program~main->module~bem_app_config module~bem_app_config_particle_runtime_batch bem_app_config_particle_runtime_batch module~bem_app_config_particle_runtime_batch->module~bem_app_config_particle_runtime module~bem_app_config_particle_runtime_sampling bem_app_config_particle_runtime_sampling module~bem_app_config_particle_runtime_sampling->module~bem_app_config_particle_runtime module~bem_app_config_particle_runtime_slots bem_app_config_particle_runtime_slots module~bem_app_config_particle_runtime_slots->module~bem_app_config_particle_runtime module~bem_app_config_potential_runtime->module~bem_electrostatic_snapshot module~bem_app_config_runtime->module~bem_app_config_particle_runtime module~bem_app_config_runtime->module~bem_app_config_potential_runtime module~bem_coulomb_fmm_basis->module~bem_coulomb_fmm_types module~bem_coulomb_fmm_core_build bem_coulomb_fmm_core_build module~bem_coulomb_fmm_core_build->module~bem_coulomb_fmm_core module~bem_coulomb_fmm_plan_ops bem_coulomb_fmm_plan_ops module~bem_coulomb_fmm_core_build->module~bem_coulomb_fmm_plan_ops module~bem_coulomb_fmm_core_eval bem_coulomb_fmm_core_eval module~bem_coulomb_fmm_core_eval->module~bem_coulomb_fmm_core module~bem_coulomb_fmm_eval_ops bem_coulomb_fmm_eval_ops module~bem_coulomb_fmm_core_eval->module~bem_coulomb_fmm_eval_ops module~bem_coulomb_fmm_core_state bem_coulomb_fmm_core_state module~bem_coulomb_fmm_core_state->module~bem_coulomb_fmm_core module~bem_coulomb_fmm_core_state->module~bem_coulomb_fmm_state_ops module~bem_coulomb_fmm_eval_ops->module~bem_coulomb_fmm_types module~bem_coulomb_fmm_eval_ops->module~bem_coulomb_fmm_basis module~bem_coulomb_fmm_eval_ops->module~bem_coulomb_fmm_periodic module~bem_coulomb_fmm_eval_ops->module~bem_coulomb_fmm_tree_utils module~bem_coulomb_fmm_periodic->module~bem_coulomb_fmm_types module~bem_coulomb_fmm_periodic_cell_cache->module~bem_coulomb_fmm_types module~bem_coulomb_fmm_periodic_ewald->module~bem_coulomb_fmm_types module~bem_coulomb_fmm_periodic_ewald->module~bem_coulomb_fmm_periodic module~bem_coulomb_fmm_plan_ops->module~bem_coulomb_fmm_periodic_root_ops module~bem_coulomb_fmm_plan_ops->module~bem_coulomb_fmm_types module~bem_coulomb_fmm_plan_ops->module~bem_coulomb_fmm_basis module~bem_coulomb_fmm_plan_ops->module~bem_coulomb_fmm_periodic module~bem_coulomb_fmm_plan_ops->module~bem_coulomb_fmm_periodic_ewald module~bem_coulomb_fmm_plan_ops->module~bem_coulomb_fmm_tree_utils module~bem_coulomb_fmm_tree_utils->module~bem_coulomb_fmm_types module~bem_coulomb_fmm_tree_utils->module~bem_coulomb_fmm_periodic module~bem_electrostatic_snapshot_eval bem_electrostatic_snapshot_eval module~bem_electrostatic_snapshot_eval->module~bem_electrostatic_snapshot module~bem_electrostatic_snapshot_upper_fourier bem_electrostatic_snapshot_upper_fourier module~bem_electrostatic_snapshot_upper_fourier->module~bem_electrostatic_snapshot module~bem_field_kernel_c bem_field_kernel_c module~bem_field_kernel_c->module~bem_coulomb_fmm_core module~bem_field_solver_config bem_field_solver_config module~bem_field_solver_config->module~bem_coulomb_fmm_core module~bem_field_solver_config->module~bem_field_solver module~bem_field_solver_eval bem_field_solver_eval module~bem_field_solver_eval->module~bem_coulomb_fmm_core module~bem_field_solver_eval->module~bem_field_solver module~bem_field_solver_fmm bem_field_solver_fmm module~bem_field_solver_fmm->module~bem_coulomb_fmm_core module~bem_field_solver_fmm->module~bem_field_solver module~bem_field_solver_tree bem_field_solver_tree module~bem_field_solver_tree->module~bem_field_solver module~bem_output_writer->module~bem_electrostatic_snapshot module~bem_output_writer_history bem_output_writer_history module~bem_output_writer_history->module~bem_performance_profile module~bem_output_writer_history->module~bem_output_writer module~bem_output_writer_summary bem_output_writer_summary module~bem_output_writer_summary->module~bem_field_solver module~bem_output_writer_summary->module~bem_output_writer module~bem_particle_stepper->module~bem_electrostatic_snapshot module~bem_restart_contract bem_restart_contract module~bem_restart_contract->module~bem_restart module~bem_restart_records bem_restart_records module~bem_restart_records->module~bem_restart module~bem_run_outputs->module~bem_periodic_checkpoint module~bem_run_outputs->module~bem_output_writer module~bem_simulator_charge bem_simulator_charge module~bem_simulator_charge->module~bem_simulator module~bem_simulator_io bem_simulator_io module~bem_simulator_io->module~bem_simulator module~bem_simulator_io->module~bem_app_config_runtime module~bem_simulator_io->module~bem_output_writer module~bem_simulator_particles bem_simulator_particles module~bem_simulator_particles->module~bem_simulator module~bem_simulator_particles->module~bem_particle_stepper module~bem_simulator_stats bem_simulator_stats module~bem_simulator_stats->module~bem_simulator module~bem_surface_models->module~bem_electrostatic_snapshot module~bem_app_config->module~bem_app_config_runtime module~bem_output_writer_files bem_output_writer_files module~bem_output_writer_files->module~bem_output_writer module~bem_surface_models_conductor bem_surface_models_conductor module~bem_surface_models_conductor->module~bem_surface_models

Derived Types

type, public ::  mpi_context

Components

Type Visibility Attributes Name Initial
integer(kind=i32), public :: rank = 0_i32
integer(kind=i32), public :: size = 1_i32
logical, public :: enabled = .false.
integer(kind=i32), public :: thread_level = 0_i32

MPI_Init_thread が返した thread support level(非 MPI build では 0)。

type, public ::  mpi_shared_counter_type

rank 0 が保持する 64 bit カウンタを全 rank が fetch-and-add で取り合う、バッチ粒子 slot pool の claim 窓口。 claim は OpenMP の critical 区間から呼ぶ前提で、MPI は MPI_THREAD_SERIALIZED 以上を要求する。 非 MPI build や 1 rank では rank 内のカウンタに落ちる。

Components

Type Visibility Attributes Name Initial
logical, public :: active = .false.
logical, public :: distributed = .false.
logical, public :: hosts_window = .false.

この rank が窓を持つ(rank 0)。remote の fetch-and-add は窓を持つ rank の MPI 進行で処理される。

logical, public :: prefetch_pending = .false.

次の chunk の fetch-and-add を先に発行してある(結果は prefetch_result)。

integer(kind=i64), public :: local_value = 0_i64

Type-Bound Procedures

procedure, public :: init => shared_counter_init
procedure, public :: reset => shared_counter_reset
procedure, public :: claim => shared_counter_claim
procedure, public :: progress => shared_counter_progress
procedure, public :: complete_prefetch => shared_counter_complete_prefetch
procedure, public :: destroy => shared_counter_destroy

Functions

public function mpi_is_root(ctx)

root rank (rank=0) かどうかを返す。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in) :: ctx

Return Value logical

public function mpi_world_size(ctx)

MPI world size を返す(size<=0 は 1 へ補正)。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in), optional :: ctx

Return Value integer(kind=i32)

public function mpi_split_count(total_count, rank, size) result(local_count)

総数 total_count をrankへ均等分割したときの局所個数を返す。

Arguments

Type IntentOptional Attributes Name
integer(kind=i32), intent(in) :: total_count
integer(kind=i32), intent(in) :: rank
integer(kind=i32), intent(in) :: size

Return Value integer(kind=i32)


Subroutines

public subroutine mpi_initialize(ctx)

MPIを初期化して rank / size を取得する。非MPIビルドでは単一ランクを返す。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(out) :: ctx

public subroutine mpi_shutdown(ctx)

mpi_initialize が実際に初期化した場合のみ MPI_Finalize を呼ぶ。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(inout) :: ctx

public subroutine mpi_get_rank_size(rank, size, ctx)

mpi_context から rank/size を取得する。未指定時は単一rank(0/1)。

Arguments

Type IntentOptional Attributes Name
integer(kind=i32), intent(out) :: rank
integer(kind=i32), intent(out) :: size
type(mpi_context), intent(in), optional :: ctx

public subroutine mpi_select_lowest_rank_i32_values(ctx, local_present, local_values, selected_rank, selected_values)

Select values supplied by the lowest MPI rank whose local flag is true.

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in) :: ctx
logical, intent(in) :: local_present
integer(kind=i32), intent(in) :: local_values(:)
integer(kind=i32), intent(out) :: selected_rank
integer(kind=i32), intent(out) :: selected_values(:)

public subroutine mpi_allreduce_sum_real_dp_array(ctx, values)

倍精度配列の総和Allreduceをin-placeで実行する。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in) :: ctx
real(kind=dp), intent(inout) :: values(:)

public subroutine mpi_allreduce_sum_real_dp_scalar(ctx, value)

倍精度スカラの総和Allreduceをin-placeで実行する。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in) :: ctx
real(kind=dp), intent(inout) :: value

public subroutine mpi_allreduce_min_real_dp_array(ctx, values)

倍精度配列の最小値Allreduceをin-placeで実行する。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in) :: ctx
real(kind=dp), intent(inout) :: values(:)

public subroutine mpi_allreduce_max_real_dp_array(ctx, values)

倍精度配列の最大値Allreduceをin-placeで実行する。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in) :: ctx
real(kind=dp), intent(inout) :: values(:)

public subroutine mpi_allreduce_sum_i32_array(ctx, values)

32bit整数配列の総和Allreduceをin-placeで実行する。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in) :: ctx
integer(kind=i32), intent(inout) :: values(:)

public subroutine mpi_allreduce_sum_i64_array(ctx, values)

64bit整数配列の総和Allreduceをin-placeで実行する。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in) :: ctx
integer(kind=i64), intent(inout) :: values(:)

public subroutine mpi_allreduce_sum_i32_scalar(ctx, value)

32bit整数スカラの総和Allreduceをin-placeで実行する。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in) :: ctx
integer(kind=i32), intent(inout) :: value

public subroutine mpi_allreduce_min_i32_scalar(ctx, value)

32bit整数スカラの最小値Allreduceをin-placeで実行する。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in) :: ctx
integer(kind=i32), intent(inout) :: value

public subroutine mpi_allreduce_max_i32_scalar(ctx, value)

32bit整数スカラの最大値Allreduceをin-placeで実行する。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in) :: ctx
integer(kind=i32), intent(inout) :: value

public subroutine mpi_bcast_i32_array(ctx, values, root)

root rankの32bit整数配列を全rankへbroadcastする。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in) :: ctx
integer(kind=i32), intent(inout) :: values(:)
integer(kind=i32), intent(in) :: root

public subroutine mpi_bcast_real_dp_array(ctx, values, root)

root rankの倍精度配列を全rankへbroadcastする。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in) :: ctx
real(kind=dp), intent(inout) :: values(:)
integer(kind=i32), intent(in) :: root

public subroutine mpi_gatherv_real_dp_array(ctx, local_values, global_values, root)

各rankの可変長倍精度配列をrootへrank順に連結する。

Read more…

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in) :: ctx
real(kind=dp), intent(in) :: local_values(:)
real(kind=dp), intent(out), allocatable :: global_values(:)
integer(kind=i32), intent(in) :: root

public subroutine mpi_allgatherv_inplace_real_dp(ctx, values, counts, displacements)

各rankが values の自分の区間 (displacements(rank+1)+1 から counts(rank+1) 要素) を持ち寄り、 全rankで values の全区間を揃える。非MPIまたは単一rankでは何もしない。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in) :: ctx
real(kind=dp), intent(inout) :: values(*)
integer(kind=i32), intent(in) :: counts(:)
integer(kind=i32), intent(in) :: displacements(:)

public subroutine mpi_allgatherv_inplace_i32(ctx, values, counts, displacements)

mpi_allgatherv_inplace_real_dp の 32 bit 整数版。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in) :: ctx
integer(kind=i32), intent(inout) :: values(*)
integer(kind=i32), intent(in) :: counts(:)
integer(kind=i32), intent(in) :: displacements(:)

public subroutine mpi_world_barrier(ctx)

全rankの同期ポイント。

Arguments

Type IntentOptional Attributes Name
type(mpi_context), intent(in) :: ctx