def __init__(self, *args, **kwargs): CompoundType.__init__(self, *args, **kwargs) # By default check if an update of the minimum and maximum timestamp for # the trace is needed self.addTag( tags.process.CheckGenerateTraceMinMaxTimestampCompoundScan())
def __buildMetaType(self): # Build source meta type # # struct <mem_source_t>__meta_<pointer_name> { # <dsk_source_field> id; # }; # self.__meta_type = CompoundType( name = self.getMemType().getName() + "__meta_join_src_" + self.getDskField().getName(), entity = "Meta type for " + self.getDskType().getName(), comment = "Meta type for " + self.getMemType().getName() + " for " + "pointer '" + self.getMemField().getName() + "'", ident = self.getMemType().getIdent() + ":::meta::join::src::" + self.__dsk_field.getName(), fields = FieldList([ Field( name = "id", field_type = self.__dsk_field.getType(), comment = "Value from " + self.getDskType().getName() + \ "." + self.__dsk_field.getName()) ])) if self.getMemType().getTagInheriting( aftermath.tags.mem.store.pertracearray.AppendFunction): self.__meta_type.addTags(aftermath.tags.mem.store.pertracearray. GenerateAppendFunction()) daf = aftermath.tags.mem.store.pertracearray.GenerateDestroyAllArraysFunction( ) elif self.getMemType().getTagInheriting( aftermath.tags.mem.store.pereventcollectionarray.AppendFunction ): self.__meta_type.addTags( aftermath.tags.mem.store.pereventcollectionarray. GenerateAppendFunction()) daf = aftermath.tags.mem.store.pereventcollectionarray.GenerateDestroyAllArraysFunction( ) elif self.getMemType().getTagInheriting( aftermath.tags.mem.store.pereventcollectionsubarray. AppendFunction): self.__meta_type.addTags( aftermath.tags.mem.store.pereventcollectionsubarray. GenerateAppendFunction()) daf = aftermath.tags.mem.store.pereventcollectionsubarray.GenerateDestroyAllArraysFunction( ) else: raise Exception("Unknown storage class") self.__meta_type.addTags(daf) tdf = self.getMemType().getOrAddTagInheriting( aftermath.tags.teardown.GenerateTeardownFunction) tdf.addStep(FunctionTagStep(daf))
def finalize(self): CompoundType.finalize(self) # Check update of minimum and maximum timestamp for the trace is desired # and needed if self.hasTag( tags.process.CheckGenerateTraceMinMaxTimestampCompoundScan): if self.referencesType(aftermath.types.base.am_timestamp_t): scan_tag = tags.process.GenerateTraceMinMaxTimestampCompoundScan( ) self.addTags(scan_tag) process_tag = self.getOrAddTagInheriting( tags.process.GenerateProcessFunction) process_tag.addStep(tags.FunctionTagStep(scan_tag))
class JoinSource(DskToMetaSource): """A single source for a join (@see aftermath.relations.join.make_join).""" def __init__(self, dsk_field, mem_field, null_allowed): """`dsk_field` is the field of the on-disk data structure associated to the join's source data structure that contains the value that is to be matched with the on-disk data structure associated to the target data structure. The Field instance `mem_field` is the field of the actual data structure that points to the target data structure. If `null_allowed` is true, the code matching the data structures does not fail if for a source data structure no target is found. """ enforce_type(dsk_field, Field) enforce_type(mem_field, Field) enforce_type(null_allowed, bool) self.__dsk_field = dsk_field self.__mem_field = mem_field self.__meta_type = None self.__associated_join_target = None self.__null_allowed = null_allowed def getMemField(self): return self.__mem_field def getMemType(self): return self.__mem_field.getCompoundType() def getDskField(self): return self.__dsk_field def getDskType(self): return self.__dsk_field.getCompoundType() def getMetaType(self): if self.__meta_type is None: self.__buildMetaType() return self.__meta_type def getAssociatedJoinTarget(self): return self.__associated_join_target def setAssociatedJoinTarget(self, tgt): enforce_type(tgt, JoinTarget) self.__associated_join_target = tgt def nullAllowed(self): return self.__null_allowed def __buildMetaType(self): # Build source meta type # # struct <mem_source_t>__meta_<pointer_name> { # <dsk_source_field> id; # }; # self.__meta_type = CompoundType( name = self.getMemType().getName() + "__meta_join_src_" + self.getDskField().getName(), entity = "Meta type for " + self.getDskType().getName(), comment = "Meta type for " + self.getMemType().getName() + " for " + "pointer '" + self.getMemField().getName() + "'", ident = self.getMemType().getIdent() + ":::meta::join::src::" + self.__dsk_field.getName(), fields = FieldList([ Field( name = "id", field_type = self.__dsk_field.getType(), comment = "Value from " + self.getDskType().getName() + \ "." + self.__dsk_field.getName()) ])) if self.getMemType().getTagInheriting( aftermath.tags.mem.store.pertracearray.AppendFunction): self.__meta_type.addTags(aftermath.tags.mem.store.pertracearray. GenerateAppendFunction()) daf = aftermath.tags.mem.store.pertracearray.GenerateDestroyAllArraysFunction( ) elif self.getMemType().getTagInheriting( aftermath.tags.mem.store.pereventcollectionarray.AppendFunction ): self.__meta_type.addTags( aftermath.tags.mem.store.pereventcollectionarray. GenerateAppendFunction()) daf = aftermath.tags.mem.store.pereventcollectionarray.GenerateDestroyAllArraysFunction( ) elif self.getMemType().getTagInheriting( aftermath.tags.mem.store.pereventcollectionsubarray. AppendFunction): self.__meta_type.addTags( aftermath.tags.mem.store.pereventcollectionsubarray. GenerateAppendFunction()) daf = aftermath.tags.mem.store.pereventcollectionsubarray.GenerateDestroyAllArraysFunction( ) else: raise Exception("Unknown storage class") self.__meta_type.addTags(daf) tdf = self.getMemType().getOrAddTagInheriting( aftermath.tags.teardown.GenerateTeardownFunction) tdf.addStep(FunctionTagStep(daf))
def __buildMetaType(self): # Build target meta type # # struct <mem_source_t>__meta_<pointer_name> { # <dsk_source_field> id; # size_t idx; # }; # meta_sort_tag = GenerateSortMetaStructArrayFunction() self.__meta_type = CompoundType( name = self.getMemType().getName() + "__meta_join_tgt_" + self.getDskField().getName(), entity = "Meta type for " + self.getDskType().getName(), comment = "Meta type for " + self.getMemType().getName() + " for " + "field '" + self.getDskField().getName() + "' of the " + "corresponding on-disk data structure "+ "'"+ self.getDskType().getName()+"'", ident = self.getMemType().getIdent() + ":::meta::join::tgt::" + self.__dsk_field.getName(), fields = FieldList([ Field( name = "id", field_type = self.__dsk_field.getType(), comment = "Value from " + self.getDskType().getName() + \ "." + self.__dsk_field.getName()), Field( name = "idx", field_type = aftermath.types.builtin.size_t, comment = "Array index of the target structure associated " + "to the value") ]), tags = [ meta_sort_tag, GeneratePostprocessFunction(steps = [ FunctionTagStep(meta_sort_tag) ]) ]) if self.getMemType().getTagInheriting( aftermath.tags.mem.store.pertracearray.AppendFunction): self.__meta_type.addTags(aftermath.tags.mem.store.pertracearray. GenerateAppendAndSetIndexFunction()) daf = aftermath.tags.mem.store.pertracearray.GenerateDestroyAllArraysFunction( ) elif self.getMemType().getTagInheriting( aftermath.tags.mem.store.pereventcollectionarray.AppendFunction ): self.__meta_type.addTags( aftermath.tags.mem.store.pereventcollectionarray. GenerateAppendAndSetIndexFunction()) daf = aftermath.tags.mem.store.pereventcollectionarray.GenerateDestroyAllArraysFunction( ) elif self.getMemType().getTagInheriting( aftermath.tags.mem.store.pereventcollectionsubarray. AppendFunction): self.__meta_type.addTags( aftermath.tags.mem.store.pereventcollectionsubarray. GenerateAppendFunction()) daf = aftermath.tags.mem.store.pereventcollectionsubarray.GenerateDestroyAllArraysFunction( ) else: raise Exception("Unknown storage class") self.__meta_type.addTags(daf) tdf = self.getMemType().getOrAddTagInheriting( aftermath.tags.teardown.GenerateTeardownFunction) tdf.addStep(FunctionTagStep(daf))
class JoinTarget(DskToMetaSource): """A single target for a join (@see aftermath.relations.join.make_join).""" def __init__(self, dsk_field, mem_type): """`dsk_field` is the field of the on-disk data structure associated to the join's target data structure that contains the value that is to be matched with the on-disk data structure associated to the source data structure. The Field instance `mem_type` is the type of actual data structure targeted by the join (which is pointed to by the pointer field of the source data structure). """ enforce_type(dsk_field, Field) enforce_type(mem_type, Type) self.__dsk_field = dsk_field self.__mem_type = mem_type self.__meta_type = None self.__associated_join_source = None def getMemType(self): return self.__mem_type def getDskField(self): return self.__dsk_field def getDskType(self): return self.__dsk_field.getCompoundType() def getMetaType(self): if self.__meta_type is None: self.__buildMetaType() return self.__meta_type def getAssociatedJoinSource(self): return self.__associated_join_source def setAssociatedJoinSource(self, src): enforce_type(src, JoinSource) self.__associated_join_source = src def __buildMetaType(self): # Build target meta type # # struct <mem_source_t>__meta_<pointer_name> { # <dsk_source_field> id; # size_t idx; # }; # meta_sort_tag = GenerateSortMetaStructArrayFunction() self.__meta_type = CompoundType( name = self.getMemType().getName() + "__meta_join_tgt_" + self.getDskField().getName(), entity = "Meta type for " + self.getDskType().getName(), comment = "Meta type for " + self.getMemType().getName() + " for " + "field '" + self.getDskField().getName() + "' of the " + "corresponding on-disk data structure "+ "'"+ self.getDskType().getName()+"'", ident = self.getMemType().getIdent() + ":::meta::join::tgt::" + self.__dsk_field.getName(), fields = FieldList([ Field( name = "id", field_type = self.__dsk_field.getType(), comment = "Value from " + self.getDskType().getName() + \ "." + self.__dsk_field.getName()), Field( name = "idx", field_type = aftermath.types.builtin.size_t, comment = "Array index of the target structure associated " + "to the value") ]), tags = [ meta_sort_tag, GeneratePostprocessFunction(steps = [ FunctionTagStep(meta_sort_tag) ]) ]) if self.getMemType().getTagInheriting( aftermath.tags.mem.store.pertracearray.AppendFunction): self.__meta_type.addTags(aftermath.tags.mem.store.pertracearray. GenerateAppendAndSetIndexFunction()) daf = aftermath.tags.mem.store.pertracearray.GenerateDestroyAllArraysFunction( ) elif self.getMemType().getTagInheriting( aftermath.tags.mem.store.pereventcollectionarray.AppendFunction ): self.__meta_type.addTags( aftermath.tags.mem.store.pereventcollectionarray. GenerateAppendAndSetIndexFunction()) daf = aftermath.tags.mem.store.pereventcollectionarray.GenerateDestroyAllArraysFunction( ) elif self.getMemType().getTagInheriting( aftermath.tags.mem.store.pereventcollectionsubarray. AppendFunction): self.__meta_type.addTags( aftermath.tags.mem.store.pereventcollectionsubarray. GenerateAppendFunction()) daf = aftermath.tags.mem.store.pereventcollectionsubarray.GenerateDestroyAllArraysFunction( ) else: raise Exception("Unknown storage class") self.__meta_type.addTags(daf) tdf = self.getMemType().getOrAddTagInheriting( aftermath.tags.teardown.GenerateTeardownFunction) tdf.addStep(FunctionTagStep(daf))
# Author: Andi Drebes <*****@*****.**> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, # USA. from aftermath.types import CompoundType, FieldList # Dummy types aliasing types declared somehwere else and that are only # referenced by address am_io_context = CompoundType(name="am_io_context", entity=None, fields=FieldList([]), comment=None) am_write_buffer = CompoundType(name="am_write_buffer", entity=None, fields=FieldList([]), comment=None)