17 integer(I4B),
private :: nr_stages
18 integer(I4B),
private :: nr_msg_types
36 subroutine cc_init(this, nr_stages, nr_msg_types)
38 integer(I4B) :: nr_stages
39 integer(I4B) :: nr_msg_types
41 this%nr_stages = nr_stages
42 this%nr_msg_types = nr_msg_types
43 call this%cached_ranks%init()
44 call this%cached_messages%init()
54 integer(I4B) :: msg_id
57 integer(I4B) :: msg_idx
60 msg_idx = this%get_msg_index(rank, stage, msg_id)
62 mpi_type = this%cached_messages%at(msg_idx)
70 subroutine cc_cache(this, rank, stage, msg_id, mpi_type)
74 integer(I4B) :: msg_id
77 integer(I4B) :: msg_idx
80 if (.not. this%is_rank_cached(rank))
then
81 call this%add_rank_cache(rank)
86 msg_idx = this%get_msg_index(rank, stage, msg_id)
87 call this%cached_messages%set(msg_idx, mpi_type)
94 logical(LGP) :: in_cache
96 in_cache = this%cached_ranks%contains(rank)
106 call this%cached_ranks%push_back(rank)
107 do i = 1, this%nr_stages
108 do j = 1, this%nr_msg_types
120 integer(I4B) :: rank_index
122 rank_index = this%cached_ranks%get_index(rank)
131 integer(I4B) :: stage
132 integer(I4B) :: msg_id
133 integer(I4B) :: msg_index
135 integer(I4B) :: rank_idx
136 integer(I4B) :: rank_offset, stage_offset
139 rank_idx = this%get_rank_index(rank)
140 if (rank_idx < 1)
return
142 rank_offset = (rank_idx - 1) * (this%nr_stages * this%nr_msg_types)
143 stage_offset = (stage - 1) * this%nr_msg_types
144 msg_index = rank_offset + stage_offset + msg_id
154 integer :: mpi_type, ierr
156 do i = 1, this%cached_messages%size
157 mpi_type = this%cached_messages%at(i)
159 call mpi_type_free(mpi_type, ierr)
163 call this%cached_messages%clear()
172 call this%cached_ranks%destroy()
173 call this%cached_messages%destroy()
This module defines variable data types.
subroutine clear(this, destroy)
Deallocate all items in list.
subroutine cc_destroy(this)
Destroy unit cache.
integer(i4b) function get_msg_index(this, rank, stage, msg_id)
@Brief returns -1 when not present
subroutine add_rank_cache(this, rank)
logical(lgp) function is_rank_cached(this, rank)
subroutine cc_init(this, nr_stages, nr_msg_types)
Initialize the unit cache.
subroutine cc_clear(this)
Clear the cache: free MPI types.
integer(i4b), parameter, public no_cached_value
subroutine cc_cache(this, rank, stage, msg_id, mpi_type)
Cache the mpi datatype for this particular rank and stage. The datatype should be committed.
integer function cc_get_cached(this, rank, stage, msg_id)
Get the cached mpi type for this rank and.
integer(i4b) function get_rank_index(this, rank)
@Brief returns -1 when not present
subroutine, public check_mpi(mpi_error_code)
Check the MPI error code, report, and.
integer(i4b), parameter, public nr_sim_stages
before exchange formulate (per solution)