Peano
Loading...
Searching...
No Matches
DaStGen2.py
Go to the documentation of this file.
1# This file is part of the Peano project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3from .DaStGenToLegacyTool import DaStGenToLegacyTool
4from .DoF import DoF
5
6import dastgen2
7
9
10class DaStGen2Generator(object):
11 """!
12
13 Simple generator mapping a DaStGen2 object onto a plain C++ class
14
15 """
16 def __init__(self,data):
17 self._data = data
18
19
21 return "peano4::stacks::STDVectorStack< " + self._data.get_full_qualified_type() + " >";
22
23
25 return "#include \"peano4/stacks/STDVectorStack.h\" \n \
26 #include \"" + self._data.namespace[-1] + "/" + self._data.name + ".h\""
27
28
29 def construct_output(self,output):
30 """
31 Pass in a version of output. It is important that external tools are used
32 first before we start any compile or so. So I add them first.
33 """
34 full_qualified_name = ""
35 for i in self._data.namespace:
36 full_qualified_name += i
37 full_qualified_name += "::"
38 full_qualified_name += self._data.name
39 self._data.data.set_full_qualified_name(full_qualified_name)
40
41 self._data.data.write_header_file( self._data.subdirectory + self._data.namespace[-1] + "/" + self._data.name + ".h" )
42 self._data.data.write_implementation_file( self._data.subdirectory + self._data.namespace[-1] + "/" + self._data.name + ".cpp" )
43 output.makefile.add_cpp_file( self._data.subdirectory + self._data.namespace[-1] + "/" + self._data.name + ".cpp", generated=True )
44
45
46
48 """!
49
50 Default superclass for any data model in Peano which is stored within the grid
51
52 A DaStGen2 data type generator. To add fields to this object, just
53 use the DaStGen2 instance data of this field, i.e. data.add_attribute().
54
55
56 ## Attributes
57
58 data: dastgen2.DataModel
59 Add elements to this guy to enrich your data model.
60
61 peano4_mpi_and_storage_aspect: peano4.dastgen2.MPIAndStorageAspect
62 This aspect adds the Peano-specific MPI routines to the data type,
63 i.e. routines used for boundary and re-balancing exchange. Modify
64 this one if you want to control certain data exchange or merge
65 patterns.
66
67
68 ## Data storage
69
70 I can control when to store data through the peano4_mpi_and_storage_aspect.
71
72
73 ## MPI
74
75 If you want to add your own MPI merge implementation, you have to
76 alter the attribute peano4_mpi_and_storage_aspect.
77
78 ## Arguments
79
80 name: String
81 Name (unqualified)
82
83
84
85 """
86
87
88 readme_descriptor = """
89"""
90
91
92 readme_package_descriptor = """
93### Data structure modelling
94
95Peano models its data structures via a tool called DaStGen. The actual DaStGen
96version in use is the second generation of DaStGen which is integrated into
97LLVM, e.g. The first generation of DaStGen has been a stand-alone Java tool
98which serves as a precompiler. As DaStGen 2 is not published yet, we appreciate
99a citation of the two original DaStGen papers when you discuss the memory needs:
100
101
102 @InProceedings{Bungartz:2008:DaStGen,
103 author={Bungartz, Hans--Joachim and Eckhardt, Wolfgang and Mehl, Miriam and Weinzierl, Tobias}, "
104 editor={Bubak, Marian and van Albada, Geert Dick and Dongarra, Jack and Sloot, Peter M. A.},
105 title={DaStGen---A Data Structure Generator for Parallel C++ HPC Software},
106 booktitle={Computational Science -- ICCS 2008},
107 year=2008,
108 publisher={Springer Berlin Heidelberg},
109 address={Berlin, Heidelberg}, "
110 pages={213--222},
111 isbn={978-3-540-69389-5}
112 }
113
114
115 @article{Bungartz:2010:DaStGen,
116 title = {A precompiler to reduce the memory footprint of multiscale PDE solvers in C++},
117 journal = {Future Generation Computer Systems},"
118 volume = {26},
119 number = {1},
120 pages = {175-182},
121 year = {2010},
122 issn = {0167-739X},
123 doi = {https://doi.org/10.1016/j.future.2009.05.011},
124 url = {https://www.sciencedirect.com/science/article/pii/S0167739X09000673},
125 author = {H.-J. Bungartz and W. Eckhardt and T. Weinzierl and C. Zenger},
126 keywords = {Data compaction and compression, Code generation, Multigrid and multilevel methods},
127 abstract = {A PDE solver's value is increasingly co-determined by its memory footprint, as the increase of computational multicore power overtakes the memory access speed, and as memory restricts the maximum experiment size. Tailoring a code to require less memory is technical challenging, error-prone, and hardware-dependent. Object-oriented code typically consumes much memory, though developers favour such high-level languages offering meaningful models and good maintainability. We augment the language C++ with new keywords branding records to be memory-critical. Our precompiler DaStGen then transforms this augmented specification into plain C++ optimised for low memory requirements. Hereby, it encodes multiple attributes with fixed range within one variable, and it reduces the number of bits per floating point value. The tool also generates one user-defined MPI data type per class and, thus, facilitates the construction of parallel codes with small messages.}
128 }
129"""
130
131
132 def __init__(self, name):
133 super(DaStGen2, self).__init__(name)
135
137
138 self.data.add_attribute( peano4.dastgen2.Peano4DoubleArray( "debugX", "Dimensions", ifdefs=["PeanoDebug>0"] ) )
139 self.data.add_attribute( peano4.dastgen2.Peano4DoubleArray( "debugH", "Dimensions", ifdefs=["PeanoDebug>0"] ) )
140
141 self.peano4_mpi_and_storage_aspect = peano4.dastgen2.MPIAndStorageAspect(peano4.datamodel.DoFAssociation.Undef)
142
143 self.data.add_aspect( self.peano4_mpi_and_storage_aspect )
144
145
146 def configure(self, namespace, association, subdirectory=""):
147 """
148
149 I always need the MPI aspect, but I can't add the right one before I don't
150 know whether this DaStGen model is used for vertices, faces or cells. To I
151 hook into this routine. In theory, I could add the DaStGen2 MPI aspect
152 straightaway (in the constructor), but I decided to do so in one place.
153
154
155 Implementation detail
156
157 It is important that we add the aspect once when we initialise the code and
158 then reconfigure it. I had the commented out version before, but that one
159 adds an aspect everytime configure() is called and thus causes issues as
160 aspects might be added multiple times.
161
162 """
163 super(DaStGen2, self).configure(namespace,association,subdirectory)
164 self.peano4_mpi_and_storage_aspect.dof_association = association
165
166
167 @property
172 @additional_load_and_store_arguments.setter
173 def additional_load_and_store_arguments(self,new_arguments):
174 self.peano4_mpi_and_storage_aspect.additional_load_and_store_arguments = [ (x[1],x[2]) for x in new_arguments]
175 for new_argument in new_arguments:
176 self.peano4_mpi_and_storage_aspect.includes.append( """
177#include \"""" + new_argument[1].replace("::","/") + """.h"
178""")
180
Represents on DaStGen2 object, i.e.
Definition DataModel.py:7
Represents Peano's MPI and storage aspect injected into a DaStGen model.
Specialisation of dastgen2.attributes.DoubleArray which relies on Peano's tarch.
Simple generator mapping a DaStGen2 object onto a plain C++ class.
Definition DaStGen2.py:10
construct_output(self, output)
Pass in a version of output.
Definition DaStGen2.py:29
Default superclass for any data model in Peano which is stored within the grid.
Definition DaStGen2.py:47
__init__(self, name)
Both the association and the namespace are not to be set directly, but through the operation configur...
Definition DaStGen2.py:132
configure(self, namespace, association, subdirectory="")
I always need the MPI aspect, but I can't add the right one before I don't know whether this DaStGen ...
Definition DaStGen2.py:146
_additional_load_and_store_arguments
Definition DoF.py:96