482 Build the Peano4 project
484 The main job of this routine is to add all the action sets et al that you
485 require to run this ExaHyPE2 application.
487 This routine generates a Peano project, i.e. the domain-specific ExaHyPE
488 view is translated into a Peano model. Once you have called this routine,
489 any changes to the ExaHyPE 2 configuration do not propagate into the Peano
490 setup anymore. If you alter the ExaHyPE setup, you have to call
491 generate_Peano4_project() again to get a new snapshot/version of the
497 The initial grid will be a regular one, spanned through
499 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
500 action_set_create_regular_grid = peano4.toolbox.CreateRegularGrid(...)
501 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
503 According to the documentation of peano4.toolbox.CreateRegularGrid,
504 the action set will produce a mesh that is just finer than the mesh
505 width passed, so we meet the max mesh width, but do not create a
506 mesh that is significantly finer.
508 As we insert particles in SPH, we have therefore to make this initial
509 resolution three times coarser than what we allow, as we only insert
510 particles into the finest mesh.
514 ## Task graph compiler
516 The core contribution of the generation is the task graph compiler which
517 really is a mapping of algorithm steps per particle species onto grid
518 sweeps. The actual mapping is outsourced into the function represented
519 by self.task_graph_compiler. This way, users can switch the translator's
520 behaviour. This function returns a sequence of mesh traversals. On top
521 of that, we have the default traversals to create a grid, to plot it,
522 to initialise the setup, and to clean up after we're done.
524 Once we have our three default steps plus a sequence of algorithmic steps
525 per time step, we run through the following steps:
527 - Create a particle set around each species and add it to the project as
528 global variable. This is the global container administering these guys.
529 - Tell each algorithmic step to use this particle set. An exception could be
530 the grid creation. At this point, we don't have particles yet. We add
531 the data structure nevertheless. It ensures that we have all the data
532 in place, and it we also then can be sure that everything is properly
533 initialised. The actual particle set will be empty at this point of the
535 - Ensure that plotting and initialisation use the update particle-grid
536 association properly. The plot has to update it, as previous steps
537 might have started a resort yet might not have finished it.
538 - Add all the algorithmic steps, including the default ones, to
542 ## Particle initialisation and proper sorting
544 The particle initialisation might end up with an invalid association of
545 particles to vertices. The graph compiler might make the first step of a
546 time step sequence sort if and only if the last one has altered the
547 particles' position. Consequently, we might end up with an initialisation
548 which yields an inconsistent data association. We therefore make it sort
549 the particles, but we need another grid sweep to finalise this sort in
550 case we have to do some global rearrangements. This is our rationale why
551 we realise the initialisation in two steps.
599 self.
_project.datamodel.add_global_object(
600 current_species_set.particle_model
602 self.
_project.datamodel.add_vertex(current_species_set)
613 cell_marker_for_statistics = (
614 DynamicMeshRefinementAnalysis.create_cell_marker(
615 current_species_set.name
618 cell_marker_for_tasks = (
620 current_species_set.name
623 vertex_marker_for_tasks = (
625 task_name=current_species_set.name,
626 full_qualified_enumerator_type=
"::swift2::TaskEnumerator",
627 enumerator_include=
""" #include "swift2/TaskEnumerator.h" """,
632 self.
_project.datamodel.add_cell(cell_marker_for_statistics)
633 self.
_project.datamodel.add_cell(cell_marker_for_tasks)
634 self.
_project.datamodel.add_vertex(vertex_marker_for_tasks)
652 for solverstep
in solver_steps:
653 solverstep.use_vertex(current_species_set)
654 solverstep.use_vertex(vertex_marker_for_tasks)
655 solverstep.use_cell(cell_marker_for_statistics)
656 solverstep.use_cell(cell_marker_for_tasks)
658 for solverstep
in initialisation_steps:
659 solverstep.use_vertex(current_species_set)
660 solverstep.use_vertex(vertex_marker_for_tasks)
661 solverstep.use_cell(cell_marker_for_statistics)
662 solverstep.use_cell(cell_marker_for_tasks)
664 action_set_plot_grid = peano4.toolbox.PlotGridInPeanoBlockFormat(
666 time_stamp_evaluation=
"repositories::getMinTimeStamp()",
667 additional_includes=
"""
668#include "repositories/GlobalState.h"
671 action_set_plot_grid.descend_invocation_order = (
674 action_set_plot_grid.parallel =
True
681 action_set_create_regular_grid.descend_invocation_order = (
684 action_set_create_regular_grid.parallel =
True
692 for solverstep
in solver_steps:
694 solverstep.add_action_set(action_set)
695 self.
_project.solversteps.add_step(solverstep)
697 for initialisation_step
in initialisation_steps:
698 self.
_project.solversteps.add_step(initialisation_step)
701 self.
_project, initialisation_steps, solver_steps
705 self.
_project.output.makefile.parse_configure_script_outcome(
716 parallelisation=Parallelisation_DomainDecomposition,
717 storage=Storage_Scattered,
718 sorting=Sorting_MultiscaleSort,
719 kernel_optimisation=KernelOptimisation_NoOptimisation,
722 Specify the realisation of the project: Select
723 - which parallelisation method to use
724 (domain-decomposition, task-graph, multisweep-task-graph)
725 - which storage strategy to use
726 (scattered, continuous-per-vertex, global-continuous)
727 - which particle sorting strategy to use
728 (multiscale-sort, bucket-sort)
729 - which kernel optimisation to use
730 (no-optimisation, vectorise-all, vectorise-distance-checks-preamble)
732 Available options for all these are kept in ./ProjectRealisation.py.
734 Only call this function after adding particle species to the project via self.add_particle_species().
745 "No particle species recorded. Call this function only after adding particle sets to project."
749 if parallelisation
not in ParallelisationVariants:
751 f
"parallelisation variant '{parallelisation}' unknown; available options are",
752 ParallelisationVariants,
754 if storage
not in StorageVariants:
756 f
"storage variant '{storage}' unknown; available options are",
759 if sorting
not in SortingVariants:
761 f
"sorting variant '{sorting}' unknown; available options are",
764 if kernel_optimisation
not in AllKernelOptimisationVariants:
766 f
"sorting variant '{kernel_optimisation}' unknown; available options are",
767 AllKernelOptimisationVariants,
772 storage == Storage_Scattered
773 and kernel_optimisation
not in BasicKernelOptimisationVariants
776 "Can't use kernel optimisation '{kernel_optimisation}' with scattered storage."
783 if parallelisation == Parallelisation_DomainDecomposition:
784 if storage == Storage_Scattered:
785 if sorting == Sorting_MultiscaleSort:
787 swift2.api.graphcompiler.particle_steps_onto_separate_mesh_traversals_multiscale_sort_scattered_memory
790 swift2.api.graphcompiler.initialisation_steps_onto_separate_mesh_traversals_multiscale_sort_scattered_memory
792 elif sorting == Sorting_BucketSort:
794 swift2.api.graphcompiler.particle_steps_onto_separate_mesh_traversals_bucket_sort_scattered_memory
797 swift2.api.graphcompiler.initialisation_steps_onto_separate_mesh_traversals_bucket_sort_scattered_memory
800 raise NotImplementedError()
803 storage == Storage_ContinuousPerVertex
804 or storage == Storage_GlobalContinuous
806 if sorting == Sorting_MultiscaleSort:
808 swift2.api.graphcompiler.particle_steps_onto_separate_mesh_traversals_multiscale_sort_coalesced_memory
811 swift2.api.graphcompiler.initialisation_steps_onto_separate_mesh_traversals_multiscale_sort_coalesced_memory
813 elif sorting == Sorting_BucketSort:
815 swift2.api.graphcompiler.particle_steps_onto_separate_mesh_traversals_bucket_sort_coalesced_memory
818 swift2.api.graphcompiler.initialisation_steps_onto_separate_mesh_traversals_bucket_sort_coalesced_memory
821 raise NotImplementedError()
824 raise NotImplementedError()
826 elif parallelisation == Parallelisation_MultisweepTaskGraph:
827 if storage == Storage_Scattered:
828 if sorting == Sorting_MultiscaleSort:
830 swift2.api.graphcompiler.particle_steps_onto_multisweep_task_graph_multiscale_sort_scattered_memory
833 swift2.api.graphcompiler.initialisation_steps_onto_multisweep_task_graph_multiscale_sort_scattered_memory
835 elif sorting == Sorting_BucketSort:
837 swift2.api.graphcompiler.particle_steps_onto_multisweep_task_graph_bucket_sort_scattered_memory
840 swift2.api.graphcompiler.initialisation_steps_onto_multisweep_task_graph_bucket_sort_scattered_memory
843 raise NotImplementedError()
846 storage == Storage_ContinuousPerVertex
847 or storage == Storage_GlobalContinuous
849 if sorting == Sorting_MultiscaleSort:
851 swift2.api.graphcompiler.particle_steps_onto_multisweep_task_graph_multiscale_sort_coalesced_memory
854 swift2.api.graphcompiler.initialisation_steps_onto_multisweep_task_graph_multiscale_sort_coalesced_memory
856 elif sorting == Sorting_BucketSort:
858 swift2.api.graphcompiler.particle_steps_onto_multisweep_task_graph_bucket_sort_coalesced_memory
861 swift2.api.graphcompiler.initialisation_steps_onto_multisweep_task_graph_bucket_sort_coalesced_memory
864 raise NotImplementedError()
866 raise NotImplementedError()
868 elif parallelisation == Parallelisation_TaskGraph:
869 if storage == Storage_Scattered:
870 if sorting == Sorting_MultiscaleSort:
872 swift2.api.graphcompiler.particle_steps_onto_task_graph_multiscale_sort_scattered_memory
875 swift2.api.graphcompiler.initialisation_steps_onto_task_graph_multiscale_sort_scattered_memory
877 elif sorting == Sorting_BucketSort:
879 swift2.api.graphcompiler.particle_steps_onto_task_graph_bucket_sort_scattered_memory
882 swift2.api.graphcompiler.initialisation_steps_onto_task_graph_bucket_sort_scattered_memory
885 raise NotImplementedError()
888 storage == Storage_ContinuousPerVertex
889 or storage == Storage_GlobalContinuous
891 if sorting == Sorting_MultiscaleSort:
893 swift2.api.graphcompiler.particle_steps_onto_task_graph_multiscale_sort_coalesced_memory
896 swift2.api.graphcompiler.initialisation_steps_onto_task_graph_multiscale_sort_coalesced_memory
898 elif sorting == Sorting_BucketSort:
900 swift2.api.graphcompiler.particle_steps_onto_task_graph_bucket_sort_coalesced_memory
903 swift2.api.graphcompiler.initialisation_steps_onto_task_graph_bucket_sort_coalesced_memory
906 raise NotImplementedError()
908 raise NotImplementedError()
910 raise NotImplementedError()
914 raise ValueError(
"No task graph compiler selected?")
916 raise ValueError(
"No initialisation stpe task graph compiler selected?")
919 new_particlelist = []
924 newp = copy.deepcopy(p)
926 if kernel_optimisation == KernelOptimisation_NoOptimisation:
928 elif kernel_optimisation == KernelOptimisation_VectoriseAll:
929 newp.switch_namespace_of_all_particle_iterators(
930 "::swift2::kernels::coalesced::"
932 elif kernel_optimisation == KernelOptimisation_VectoriseDistanceChecks:
933 newp.switch_namespace_of_all_particle_iterators(
934 "::swift2::kernels::coalesced::prefixcheck::"
937 raise NotImplementedError()
939 new_particlelist.append(newp)
943 new_particlesetlist = []
947 newps = copy.deepcopy(ps)
949 if storage == Storage_ContinuousPerVertex:
955 elif storage == Storage_GlobalContinuous:
961 elif storage == Storage_Scattered:
966 raise NotImplementedError()
968 new_particlesetlist.append(newps)