10from .AMRLogic
import add_dynamic_mesh_refinement_and_particle_resorting
11from .ParticleSortingAndStorage
import (
12 ParticleSortingAndStorage,
13 AddAdditionalDummySweep,
15from .SpeciesStepOrdering
import concatenate_steps_of_species
17 does_one_species_require_gather,
22from .Sequential
import (
23 map_onto_separate_mesh_traversals,
24 map_onto_separate_mesh_traversals_with_generic_mapper,
26from .TaskGraph
import add_clear_task_number_to_very_first_initialisation_step
33 alter_particle_position,
34 use_continuous_particles_sequences,
40 Actual translation of one step per particle species onto a task graph construction
42 We basically forward to exaparty.api.graphcompiler.TaskGraph.translate_one_step_of_species_into_mesh_traversal()
43 but we set the flag synchronise_task_graph_after_each_mesh_sweep() to
44 false. This does not mean that the arising task graph is bare of all
45 synchronisation. It just means that we don't immediately synchronise
48 All the wrappers have implicitly built in some synchronisation: A vertex
49 issues a task with a number. If this number is already tied to an existing
50 task, this creates an in-out dependency. However, we have three types of
51 task numbers per species:
53 - touch vertex first task numbers
54 - touch cell first task numbers
55 - touch vertex last task numbers
57 Each observer will create vertex first-vertex first-cell-vertex last chains
58 of tasks with an arbitrary number of first and last instances. The important thing
59 to keep things correct therefore is that we establish vertex last-vertex first
60 relations here which ensure that one chain does not mangle into the chain of the
63 This is the added thing here. Global syncs will automatically be added where
64 they are necessary (cmp. translate_one_step_of_species_into_mesh_traversal()
65 and the variable synchronise_after_each_mesh_traversal therein).
67 SynchroniseVerticesWithPreviousMeshSweep
71 - nix in touch cell last
78 alter_particle_position,
79 use_continuous_particles_sequences,
82 synchronise_task_graph_after_each_mesh_sweep=
False,
86 len(mesh_traversals) > 0
87 ),
"at least one step has to be added after translate_one_step_of_species_into_mesh_traversal() has terminated"
89 glue_two_mesh_sweeps_together = (
94 glue_two_mesh_sweeps_together.descend_invocation_order = (
95 mesh_traversals[-1].lowest_descend_invocation_order() - 1
97 glue_two_mesh_sweeps_together.parallel =
False
98 mesh_traversals[-1].add_action_set(glue_two_mesh_sweeps_together)
102 "GRAPH COMPILER DEBUG [translate_one_step_of_species_into_mesh_traversal]: step no {} ({}) on particle {} uses exaparty.api.actionsets.SynchroniseVerticesWithPreviousMeshSweep".format(
103 len(mesh_traversals),
105 current_species_set.particle_model.name,
112 particle_sorting_and_storage: ParticleSortingAndStorage,
118 Forward to map_onto_separate_mesh_traversals_with_generic_mapper().
119 Consult implementation in TaskGraph.py for further information.
121 The bespoke logic here is injected by the functor
122 translate_one_step_of_species_into_mesh_traversal() pointing to
123 another routine in this file.
126 return map_onto_separate_mesh_traversals_with_generic_mapper(
128 particle_sorting_and_storage,
131 translate_one_step_of_species_into_mesh_traversal,
145def initialisation_steps_onto_multisweep_task_graph_multiscale_sort_scattered_memory(
151 @see map_onto_separate_mesh_traversals()
153 @param concatenate_steps_of_species: [Species]
154 Sequence of particle species to be handled.
156 @param verbose: {True, False}
160 sequence_of_steps=concatenate_steps_of_species(species_sets,
True),
161 particle_sorting_and_storage=ParticleSortingAndStorage.SORT_WITH_LIFTS_AND_DROPS_SCATTERED_PARTICLE_STORAGE,
162 step_type=StepType.INITIALISATION,
165 add_clear_task_number_to_very_first_initialisation_step(
166 result, species_sets, verbose
171def initialisation_steps_onto_multisweep_task_graph_bucket_sort_scattered_memory(
177 @see map_onto_separate_mesh_traversals()
179 @param concatenate_steps_of_species: [Species]
180 Sequence of particle species to be handled.
182 @param verbose: {True, False}
186 sequence_of_steps=concatenate_steps_of_species(species_sets,
True),
187 particle_sorting_and_storage=ParticleSortingAndStorage.SORT_ON_THE_FLY_SCATTERED_PARTICLE_STORAGE,
188 step_type=StepType.INITIALISATION,
191 add_clear_task_number_to_very_first_initialisation_step(
192 result, species_sets, verbose
197def initialisation_steps_onto_multisweep_task_graph_multiscale_sort_coalesced_memory(
203 @see map_onto_separate_mesh_traversals()
205 @param concatenate_steps_of_species: [Species]
206 Sequence of particle species to be handled.
208 @param verbose: {True, False}
212 sequence_of_steps=concatenate_steps_of_species(species_sets,
True),
213 particle_sorting_and_storage=ParticleSortingAndStorage.SORT_WITH_LIFTS_AND_DROPS_COALESCED_PARTICLE_STORAGE,
214 step_type=StepType.INITIALISATION,
217 add_clear_task_number_to_very_first_initialisation_step(
218 result, species_sets, verbose
223def initialisation_steps_onto_multisweep_task_graph_bucket_sort_coalesced_memory(
229 @see map_onto_separate_mesh_traversals()
231 @param concatenate_steps_of_species: [Species]
232 Sequence of particle species to be handled.
234 @param verbose: {True, False}
238 sequence_of_steps=concatenate_steps_of_species(species_sets,
True),
239 particle_sorting_and_storage=ParticleSortingAndStorage.SORT_ON_THE_FLY_COALESCED_PARTICLE_STORAGE,
240 step_type=StepType.INITIALISATION,
243 add_clear_task_number_to_very_first_initialisation_step(
244 result, species_sets, verbose
249def particle_steps_onto_multisweep_task_graph_multiscale_sort_scattered_memory(
255 For a sequential ordering, i.e. 1:1 mapping of steps per species onto
256 traversals, it makes no real difference how we order the progress through
257 the individual steps. So I just concatenate the steps per species.
259 @see map_onto_separate_mesh_traversals()
261 @param concatenate_steps_of_species: [Species]
262 Sequence of particle species to be handled.
264 @param verbose: {True, False}
268 sequence_of_steps=concatenate_steps_of_species(species_sets,
False),
269 particle_sorting_and_storage=ParticleSortingAndStorage.SORT_WITH_LIFTS_AND_DROPS_SCATTERED_PARTICLE_STORAGE,
270 step_type=StepType.TIME_STEP,
275def particle_steps_onto_multisweep_task_graph_bucket_sort_scattered_memory(
281 For a sequential ordering, i.e. 1:1 mapping of steps per species onto
282 traversals, it makes no real difference how we order the progress through
283 the individual steps. So I just concatenate the steps per species.
285 @see map_onto_separate_mesh_traversals()
287 @param concatenate_steps_of_species: [Species]
288 Sequence of particle species to be handled.
290 @param verbose: {True, False}
294 sequence_of_steps=concatenate_steps_of_species(species_sets,
False),
295 particle_sorting_and_storage=ParticleSortingAndStorage.SORT_ON_THE_FLY_SCATTERED_PARTICLE_STORAGE,
296 step_type=StepType.TIME_STEP,
301def particle_steps_onto_multisweep_task_graph_multiscale_sort_coalesced_memory(
307 For a sequential ordering, i.e. 1:1 mapping of steps per species onto
308 traversals, it makes no real difference how we order the progress through
309 the individual steps. So I just concatenate the steps per species.
311 @see map_onto_separate_mesh_traversals()
313 @param concatenate_steps_of_species: [Species]
314 Sequence of particle species to be handled.
316 @param verbose: {True, False}
320 sequence_of_steps=concatenate_steps_of_species(species_sets,
False),
321 particle_sorting_and_storage=ParticleSortingAndStorage.SORT_WITH_LIFTS_AND_DROPS_COALESCED_PARTICLE_STORAGE,
322 step_type=StepType.TIME_STEP,
327def particle_steps_onto_multisweep_task_graph_bucket_sort_coalesced_memory(
333 For a sequential ordering, i.e. 1:1 mapping of steps per species onto
334 traversals, it makes no real difference how we order the progress through
335 the individual steps. So I just concatenate the steps per species.
337 @see map_onto_separate_mesh_traversals()
339 @param concatenate_steps_of_species: [Species]
340 Sequence of particle species to be handled.
342 @param verbose: {True, False}
346 sequence_of_steps=concatenate_steps_of_species(species_sets,
False),
347 particle_sorting_and_storage=ParticleSortingAndStorage.SORT_ON_THE_FLY_COALESCED_PARTICLE_STORAGE,
348 step_type=StepType.TIME_STEP,
map_onto_separate_mesh_traversals_constructing_task_graph(sequence_of_steps, ParticleSortingAndStorage particle_sorting_and_storage, StepType step_type, verbose)
Forward to map_onto_separate_mesh_traversals_with_generic_mapper().
translate_one_step_of_species_into_mesh_traversal(step, current_species_set, mesh_traversals, alter_particle_position, use_continuous_particles_sequences, StepType step_type, verbose)
Actual translation of one step per particle species onto a task graph construction.
translate_one_step_of_species_into_mesh_traversal(step, current_species_set, mesh_traversals, alter_particle_position, use_continuous_particles_sequences, StepType step_type, verbose, synchronise_task_graph_after_each_mesh_sweep=True)
Translate one step of species into mesh traversal.