16 integer(I4B),
private :: nr_stages
17 integer(I4B),
private :: nr_msg_types
34 subroutine cc_init(this, nr_stages, nr_msg_types)
36 integer(I4B) :: nr_stages
37 integer(I4B) :: nr_msg_types
39 this%nr_stages = nr_stages
40 this%nr_msg_types = nr_msg_types
41 call this%cached_ranks%init()
42 call this%cached_messages%init()
52 integer(I4B) :: msg_id
55 integer(I4B) :: msg_idx
58 msg_idx = this%get_msg_index(rank, stage, msg_id)
60 mpi_type = this%cached_messages%at(msg_idx)
68 subroutine mc_cache(this, rank, stage, msg_id, mpi_type)
72 integer(I4B) :: msg_id
75 integer(I4B) :: msg_idx
78 if (.not. this%is_rank_cached(rank))
then
79 call this%add_rank_cache(rank)
84 msg_idx = this%get_msg_index(rank, stage, msg_id)
85 call this%cached_messages%set(msg_idx, mpi_type)
92 logical(LGP) :: in_cache
94 in_cache = this%cached_ranks%contains(rank)
104 call this%cached_ranks%push_back(rank)
105 do i = 1, this%nr_stages
106 do j = 1, this%nr_msg_types
118 integer(I4B) :: rank_index
120 rank_index = this%cached_ranks%get_index(rank)
129 integer(I4B) :: stage
130 integer(I4B) :: msg_id
131 integer(I4B) :: msg_index
133 integer(I4B) :: rank_idx
134 integer(I4B) :: rank_offset, stage_offset
137 rank_idx = this%get_rank_index(rank)
138 if (rank_idx < 1)
return
140 rank_offset = (rank_idx - 1) * (this%nr_stages * this%nr_msg_types)
141 stage_offset = (stage - 1) * this%nr_msg_types
142 msg_index = rank_offset + stage_offset + msg_id
152 integer :: mpi_type, ierr
154 do i = 1, this%cached_messages%size
155 mpi_type = this%cached_messages%at(i)
157 call mpi_type_free(mpi_type, ierr)
161 call this%cached_ranks%destroy()
162 call this%cached_messages%destroy()
This module defines variable data types.
subroutine cc_destroy(this)
Clean up the 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 mc_cache(this, rank, stage, msg_id, mpi_type)
Cache the mpi datatype for this particular rank and stage. The datatype should be committed.
integer(i4b), parameter, public no_cached_value
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
integer(i4b), parameter, public nr_sim_stages
before exchange formulate (per solution)