MONC
allreduction-inter-io.F90
Go to the documentation of this file.
1 
14  implicit none
15 
16 #ifndef TEST_MODE
17  private
18 #endif
19 
21  integer :: root
22  procedure(handle_completion), pointer, nopass :: completion_procedure
23  end type allreduce_type
24 
25  logical, volatile :: initialised=.false.
26 
27  integer, volatile :: allreduce_rwlock
28  type(hashmap_type), volatile :: allreduce_types
29 
32 contains
33 
36  subroutine init_allreduction_inter_io(io_configuration)
37  type(io_configuration_type), intent(inout) :: io_configuration
38 
39  if (.not. initialised) then
40  initialised=.true.
42  end if
43  call init_reduction_inter_io(io_configuration)
44  call init_broadcast_inter_io(io_configuration)
45  end subroutine init_allreduction_inter_io
46 
49  subroutine finalise_allreduction_inter_io(io_configuration)
50  type(io_configuration_type), intent(inout) :: io_configuration
51 
52  if (initialised) then
53  initialised=.false.
55  end if
56  call finalise_reduction_inter_io(io_configuration)
58  end subroutine finalise_allreduction_inter_io
59 
63  logical function check_allreduction_inter_io_for_completion(io_configuration)
64  type(io_configuration_type), intent(inout) :: io_configuration
65 
70 
80  subroutine perform_inter_io_allreduction(io_configuration, field_values, field_size, field_name, reduction_op, root, &
81  timestep, completion_procedure)
82  type(io_configuration_type), intent(inout) :: io_configuration
83  real(kind=double_precision), dimension(:) :: field_values
84  integer, intent(in) :: field_size, reduction_op, root, timestep
85  character(len=*), intent(in) :: field_name
86  procedure(handle_completion) :: completion_procedure
87 
88  if (io_configuration%my_io_rank .eq. root) then
89  call add_allreduce_information_if_needed(field_name, timestep, root, completion_procedure)
90  end if
91  call perform_inter_io_reduction(io_configuration, field_values, field_size, field_name, reduction_op, &
93  if (io_configuration%my_io_rank .ne. root) then
94  ! None root processes issue a broadcast
95  call perform_inter_io_broadcast(io_configuration, field_values, size(field_values), field_name, root, &
96  timestep, completion_procedure)
97  end if
98  end subroutine perform_inter_io_allreduction
99 
105  subroutine internal_reduction_completion_procedure(io_configuration, values, field_name, timestep)
106  type(io_configuration_type), intent(inout) :: io_configuration
107  real(DEFAULT_PRECISION), dimension(:) :: values
108  character(len=*) :: field_name
109  integer :: timestep
110 
111  type(allreduce_type), pointer :: allreduce_information
112 
113  allreduce_information=>find_allreduce_information(field_name, timestep, .true.)
114  call perform_inter_io_broadcast(io_configuration, values, size(values), field_name, &
115  allreduce_information%root, timestep, allreduce_information%completion_procedure)
116  call remove_allreduce_information(field_name, timestep, .true.)
118 
124  subroutine add_allreduce_information_if_needed(field_name, timestep, root, completion_procedure)
125  character(len=*), intent(in) :: field_name
126  integer, intent(in) :: timestep, root
127  procedure(handle_completion) :: completion_procedure
128 
129  type(allreduce_type), pointer :: allreduce_information
130  class(*), pointer :: generic
131 
132  allreduce_information=>find_allreduce_information(field_name, timestep, .true.)
133  if (.not. associated(allreduce_information)) then
135  allreduce_information=>find_allreduce_information(field_name, timestep, .false.)
136  if (.not. associated(allreduce_information)) then
137  allocate(allreduce_information)
138  allreduce_information%completion_procedure=>completion_procedure
139  allreduce_information%root=root
140  generic=>allreduce_information
141  call c_put_generic(allreduce_types, trim(field_name)//"#"//conv_to_string(timestep), generic, .true.)
142  end if
144  end if
146 
152  function find_allreduce_information(field_name, timestep, dolock)
153  character(len=*), intent(in) :: field_name
154  integer, intent(in) :: timestep
155  logical, intent(in) :: dolock
157 
158  class(*), pointer :: generic
159 
161  generic=>c_get_generic(allreduce_types, trim(field_name)//"#"//conv_to_string(timestep))
163 
164  if (associated(generic)) then
165  select type(generic)
166  type is (allreduce_type)
168  end select
169  else
171  end if
172  end function find_allreduce_information
173 
178  subroutine remove_allreduce_information(field_name, timestep, dolock)
179  character(len=*), intent(in) :: field_name
180  integer, intent(in) :: timestep
181  logical, intent(in) :: dolock
182 
184  call c_remove(allreduce_types, trim(field_name)//"#"//conv_to_string(timestep))
186  end subroutine remove_allreduce_information
187 end module allreduction_inter_io_mod
conversions_mod
Conversion between common inbuilt FORTRAN data types.
Definition: conversions.F90:5
collections_mod::c_is_empty
Returns whether a collection is empty.
Definition: collections.F90:437
reduction_inter_io_mod::init_reduction_inter_io
subroutine, public init_reduction_inter_io(io_configuration)
Initialises the reduction action.
Definition: reduction-inter-io.F90:51
collections_mod::c_put_generic
Puts a generic key-value pair into the map.
Definition: collections.F90:305
broadcast_inter_io_mod
Broadcast inter IO communication which sends a value from one IO server to all others....
Definition: broadcast-inter-io.F90:3
reduction_inter_io_mod::check_reduction_inter_io_for_completion
logical function, public check_reduction_inter_io_for_completion(io_configuration)
Checks this action for completion, when all are completed then the IO server can shutdown as this is ...
Definition: reduction-inter-io.F90:83
allreduction_inter_io_mod::add_allreduce_information_if_needed
subroutine add_allreduce_information_if_needed(field_name, timestep, root, completion_procedure)
Adds an all reduce information to the status if it does not exist.
Definition: allreduction-inter-io.F90:125
collections_mod
Collection data structures.
Definition: collections.F90:7
reduction_inter_io_mod::perform_inter_io_reduction
subroutine, public perform_inter_io_reduction(io_configuration, field_values, field_size, reduction_field_name, reduction_op, root, timestep, completion_procedure)
Actually handles the processing for this data wrt the vertical reduction.
Definition: reduction-inter-io.F90:127
collections_mod::hashmap_type
A hashmap structure, the same as a map but uses hashing for greatly improved performance when storing...
Definition: collections.F90:94
forthread_mod
Definition: forthread.F90:1
inter_io_specifics_mod
Inter IO server communication specific functionality. This manages all of the communication that migh...
Definition: inter-io-specifics.F90:3
forthread_mod::forthread_rwlock_destroy
integer function forthread_rwlock_destroy(rwlock_id)
Definition: forthread.F90:495
allreduction_inter_io_mod::initialised
logical, volatile initialised
Definition: allreduction-inter-io.F90:25
collections_mod::c_get_generic
Gets a specific generic element out of the list, stack, queue or map with the corresponding key.
Definition: collections.F90:367
allreduction_inter_io_mod::finalise_allreduction_inter_io
subroutine, public finalise_allreduction_inter_io(io_configuration)
Finalises the all reduction inter IO functionality.
Definition: allreduction-inter-io.F90:50
allreduction_inter_io_mod::allreduce_rwlock
integer, volatile allreduce_rwlock
Definition: allreduction-inter-io.F90:27
allreduction_inter_io_mod::allreduce_type
Definition: allreduction-inter-io.F90:20
broadcast_inter_io_mod::perform_inter_io_broadcast
subroutine, public perform_inter_io_broadcast(io_configuration, field_values, field_size, field_name, root, timestep, completion_procedure)
Performs an inter IO broadcast of data from the root to all other IO servers. Note that this is on th...
Definition: broadcast-inter-io.F90:176
allreduction_inter_io_mod::internal_reduction_completion_procedure
subroutine internal_reduction_completion_procedure(io_configuration, values, field_name, timestep)
Internal completion, called after the reduce has completed (on root) and calls out to broadcast.
Definition: allreduction-inter-io.F90:106
allreduction_inter_io_mod::init_allreduction_inter_io
subroutine, public init_allreduction_inter_io(io_configuration)
Initialises the all reduction inter IO functionality.
Definition: allreduction-inter-io.F90:37
threadpool_mod
This is a thread pool and the single management "main" thread will spawn out free threads in the pool...
Definition: threadpool.F90:5
threadpool_mod::check_thread_status
subroutine, public check_thread_status(ierr)
Checks the error status of any thread operation and reports an error if it failed.
Definition: threadpool.F90:229
conversions_mod::conv_to_string
Converts data types to strings.
Definition: conversions.F90:38
reduction_inter_io_mod
Reduction inter IO action which will perform reductions between IO servers. This is not as trivial as...
Definition: reduction-inter-io.F90:4
broadcast_inter_io_mod::finalise_broadcast_inter_io
subroutine, public finalise_broadcast_inter_io()
Finalises the broadcast inter IO functionality.
Definition: broadcast-inter-io.F90:77
forthread_mod::forthread_rwlock_init
integer function forthread_rwlock_init(rwlock_id, attr_id)
Definition: forthread.F90:504
configuration_parser_mod::io_configuration_type
Overall IO configuration.
Definition: configurationparser.F90:104
allreduction_inter_io_mod
All reduction, which does a reduce and then broadcasts the data to all IO servers.
Definition: allreduction-inter-io.F90:2
allreduction_inter_io_mod::check_allreduction_inter_io_for_completion
logical function, public check_allreduction_inter_io_for_completion(io_configuration)
Determines whether this all reduction inter IO functionality has completed or not.
Definition: allreduction-inter-io.F90:64
datadefn_mod::double_precision
integer, parameter, public double_precision
Double precision (64 bit) kind.
Definition: datadefn.F90:14
allreduction_inter_io_mod::remove_allreduce_information
subroutine remove_allreduce_information(field_name, timestep, dolock)
Removes an all reduce status information based on the field name and timestep.
Definition: allreduction-inter-io.F90:179
datadefn_mod
Contains common definitions for the data and datatypes used by MONC.
Definition: datadefn.F90:2
reduction_inter_io_mod::finalise_reduction_inter_io
subroutine, public finalise_reduction_inter_io(io_configuration)
Finalises the reduction action, waiting for all outstanding requests and then freeing data.
Definition: reduction-inter-io.F90:91
datadefn_mod::string_length
integer, parameter, public string_length
Default length of strings.
Definition: datadefn.F90:10
allreduction_inter_io_mod::allreduce_types
type(hashmap_type), volatile allreduce_types
Definition: allreduction-inter-io.F90:28
broadcast_inter_io_mod::init_broadcast_inter_io
subroutine, public init_broadcast_inter_io(io_configuration)
Initialises the broadcast inter IO functionality.
Definition: broadcast-inter-io.F90:58
allreduction_inter_io_mod::perform_inter_io_allreduction
subroutine, public perform_inter_io_allreduction(io_configuration, field_values, field_size, field_name, reduction_op, root, timestep, completion_procedure)
Performs the all reduction inter IO reduction.
Definition: allreduction-inter-io.F90:82
allreduction_inter_io_mod::find_allreduce_information
type(allreduce_type) function, pointer find_allreduce_information(field_name, timestep, dolock)
Finds an all reduce status information based on the field name and timestep, or returns null if none ...
Definition: allreduction-inter-io.F90:153
collections_mod::c_remove
Removes a specific element from the list or map.
Definition: collections.F90:419
forthread_mod::forthread_rwlock_wrlock
integer function forthread_rwlock_wrlock(lock_id)
Definition: forthread.F90:532
forthread_mod::forthread_rwlock_rdlock
integer function forthread_rwlock_rdlock(lock_id)
Definition: forthread.F90:514
reduction_inter_io_mod::get_reduction_operator
integer function, public get_reduction_operator(op_string)
Given the map of action attributes this procedure will identify the reduction operator that has been ...
Definition: reduction-inter-io.F90:488
configuration_parser_mod
Parses the XML configuration file to produce the io configuration description which contains the data...
Definition: configurationparser.F90:3
forthread_mod::forthread_rwlock_unlock
integer function forthread_rwlock_unlock(lock_id)
Definition: forthread.F90:550
inter_io_specifics_mod::handle_completion
Definition: inter-io-specifics.F90:18
datadefn_mod::default_precision
integer, parameter, public default_precision
MPI communication type which we use for the prognostic and calculation data.
Definition: datadefn.F90:17