rank 0 が保持する 64 bit カウンタを全 rank が fetch-and-add で取り合う、バッチ粒子 slot pool の claim 窓口。
claim は OpenMP の critical 区間から呼ぶ前提で、MPI は MPI_THREAD_SERIALIZED 以上を要求する。
非 MPI build や 1 rank では rank 内のカウンタに落ちる。
| 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 を先に発行してある(結果は |
|
| integer(kind=i64), | public | :: | local_value | = | 0_i64 |
rank 0 に 1 要素の RMA 窓を作り、全 rank で passive-target lock を張る(collective)。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(mpi_shared_counter_type), | intent(inout) | :: | self | |||
| type(mpi_context), | intent(in) | :: | ctx |
カウンタを 0 に戻す(collective)。前バッチの claim が全て終わってから呼ぶ。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(mpi_shared_counter_type), | intent(inout) | :: | self | |||
| type(mpi_context), | intent(in) | :: | ctx |
count 個を確保し、確保前のカウンタ値(0 始まりの先頭 slot)を返す。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(mpi_shared_counter_type), | intent(inout) | :: | self | |||
| integer(kind=i64), | intent(in) | :: | count | |||
| integer(kind=i64), | intent(out) | :: | first |
窓を持つ rank が MPI の進行エンジンを回し、他 rank から届いた fetch-and-add を処理する。 passive-target RMA は target が MPI を呼ばないと進まないので、rank 0 の粒子ループから定期的に呼ぶ。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(mpi_shared_counter_type), | intent(inout) | :: | self |
先行発行した fetch-and-add があれば完了させて捨てる(barrier の前に呼ぶ)。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(mpi_shared_counter_type), | intent(inout) | :: | self |
RMA 窓を解放する(collective。init した全 rank が呼ぶ)。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(mpi_shared_counter_type), | intent(inout) | :: | self |
type, public :: mpi_shared_counter_type logical :: active = .false. logical :: distributed = .false. !> この rank が窓を持つ(rank 0)。remote の fetch-and-add は窓を持つ rank の MPI 進行で処理される。 logical :: hosts_window = .false. !> 次の chunk の fetch-and-add を先に発行してある(結果は `prefetch_result`)。 logical :: prefetch_pending = .false. integer(i64) :: local_value = 0_i64 #ifdef USE_MPI integer :: win = MPI_WIN_NULL #endif contains procedure :: init => shared_counter_init procedure :: reset => shared_counter_reset procedure :: claim => shared_counter_claim procedure :: progress => shared_counter_progress procedure :: complete_prefetch => shared_counter_complete_prefetch procedure :: destroy => shared_counter_destroy end type mpi_shared_counter_type