Example #1
0
    def __init__(self, dsk_type):
        Jinja2FileTemplate.__init__(self, "PerTraceArrayFunction.tpl.c")

        reqtags_dsk = self.requireTags(
            dsk_type, {
                "gen_tag": tags.dsk.tomem.GeneratePerTraceArrayFunction,
                "tomem_tag": aftermath.tags.dsk.tomem.ConversionFunction
            })

        gen_tag = reqtags_dsk["gen_tag"]
        tomem_tag = reqtags_dsk["tomem_tag"]

        reqtags_mem = self.requireTags(tomem_tag.getMemType(), {
            "store_tag":
            aftermath.tags.mem.store.pertracearray.AppendFunction
        })

        FunctionTemplate.__init__(
            self,
            function_name=gen_tag.getFunctionName(),
            return_type=aftermath.types.builtin.int,
            inline=True,
            arglist=FieldList([
                Field(name="ctx",
                      field_type=aftermath.types.aux.am_io_context,
                      is_pointer=True),
                Field(name="dsk", field_type=dsk_type, is_pointer=True)
            ]))

        self.addDefaultArguments(dsk_type=dsk_type)
        self.addDefaultArguments(**reqtags_dsk)
        self.addDefaultArguments(**reqtags_mem)
Example #2
0
    def __init__(self, dsk_type):
        Jinja2FileTemplate.__init__(self, "WriteFunction.tpl.c")

        reqtags = self.requireTags(dsk_type,
                                   {"gen_tag": tags.dsk.GenerateWriteFunction})

        if reqtags["gen_tag"].hasTypeParam():
            tp = [
                Field(name="type_id",
                      field_type=aftermath.types.builtin.uint32_t)
            ]
        else:
            tp = []

        FunctionTemplate.__init__(
            self,
            function_name=reqtags["gen_tag"].getFunctionName(),
            return_type=aftermath.types.builtin.int,
            arglist=FieldList([
                Field(name="ctx",
                      field_type=aftermath.types.aux.am_io_context,
                      is_pointer=True)
            ] + tp + [
                Field(name="dsk",
                      field_type=dsk_type,
                      is_pointer=True,
                      is_const=True)
            ]))

        self.addDefaultArguments(dsk_type=dsk_type, **reqtags)
Example #3
0
    def __init__(self, dsk_type):
        Jinja2FileTemplate.__init__(
            self, "WriteToBufferWithDefaultIDFunction.tpl.c")

        reqtags = self.requireTags(
            dsk_type, {
                "gen_tag": tags.dsk.GenerateWriteToBufferWithDefaultIDFunction,
                "wtb_tag": tags.dsk.WriteToBufferFunction
            })

        FunctionTemplate.__init__(
            self,
            function_name=reqtags["gen_tag"].getFunctionName(),
            return_type=aftermath.types.builtin.int,
            inline=True,
            arglist=FieldList([
                Field(name="wb",
                      field_type=aftermath.types.aux.am_write_buffer,
                      is_pointer=True),
                Field(name="e",
                      field_type=dsk_type,
                      is_pointer=True,
                      is_const=True)
            ]))

        self.addDefaultArguments(dsk_type=dsk_type, **reqtags)
Example #4
0
    def __init__(self, tpl_file, reqtags, mem_type):
        Jinja2FileTemplate.__init__(self, tpl_file)

        tag = reqtags["tag"]
        gen_tag = reqtags["gen_tag"]

        FunctionTemplate.__init__(
            self,
            function_name=tag.getFunctionName(),
            return_type=aftermath.types.builtin.int,
            inline=True,
            arglist=FieldList([
                Field(name="ctx",
                      field_type=aftermath.types.aux.am_io_context,
                      is_pointer=True),
                Field(name="e", field_type=mem_type, is_pointer=True)
            ]))

        if gen_tag.getTraceArrayIdent():
            trace_array_ident = gen_tag.getTraceArrayIdent()
        else:
            trace_array_ident = mem_type.getIdent()

        if gen_tag.getTraceArrayStructName():
            trace_array_struct_name = gen_tag.getEventArrayStructName()
        else:
            trace_array_struct_name = mem_type.getName() + "_array"

        self.addDefaultArguments( \
            mem_type = mem_type, \
            trace_array_ident = trace_array_ident, \
            trace_array_struct_name = trace_array_struct_name, \
            **reqtags)
Example #5
0
    def __init__(self, dsk_type):
        Jinja2FileTemplate.__init__(self, "ArrayReadFunction.tpl.c")

        reqtags = self.requireTags(dsk_type,
                                   {"tag": tags.dsk.GenerateArrayReadFunction})

        tag = dsk_type.getTag(tags.dsk.GenerateArrayReadFunction)

        if not isinstance(tag.getNumElementsField().getType(),
                          aftermath.types.FixedWidthIntegerType):
            raise Exception("Field with number of elements must be an integer "
                            "with a fixed number of bits")

        FunctionTemplate.__init__(
            self,
            function_name=reqtags["tag"].getFunctionName(),
            return_type=aftermath.types.builtin.int,
            inline=True,
            arglist=FieldList([
                Field(name="ctx",
                      field_type=aftermath.types.aux.am_io_context,
                      is_pointer=True),
                Field(name="dsk", field_type=dsk_type, is_pointer=True)
            ]))
        self.addDefaultArguments(dsk_type=dsk_type, **reqtags)
Example #6
0
    def __init__(self, dsk_type):
        Jinja2FileTemplate.__init__(self,
                                    "AddToAllMetaStructArraysFunction.tpl.c")

        reqtags = self.requireTags(
            dsk_type, {
                "gen_tag":
                tags.dsk.tomem.GenerateAddToAllMetaStructArraysFunction,
                "dsktometa_tag": tags.dsk.tomem.join.DskToMetaSources
            })

        gen_tag = reqtags["gen_tag"]

        FunctionTemplate.__init__(
            self,
            function_name=reqtags["gen_tag"].getFunctionName(),
            return_type=aftermath.types.builtin.int,
            inline=True,
            arglist=FieldList([
                Field(name="ctx",
                      field_type=aftermath.types.aux.am_io_context,
                      is_pointer=True),
                Field(name="dsk",
                      field_type=gen_tag.getDskType(),
                      is_pointer=True),
                Field(name="mem",
                      field_type=gen_tag.getMemType(),
                      is_pointer=True)
            ]))
        self.addDefaultArguments(**reqtags)
Example #7
0
    def __init__(self, dsk_type):
        Jinja2FileTemplate.__init__(self, "PostConversionFunction.tpl.c")

        reqtags = self.requireTags(
            dsk_type, {
                "gen_tag": tags.dsk.tomem.GeneratePostConversionFunction,
                "conversion_tag": tags.dsk.tomem.ConversionFunction
            })

        tag = reqtags["gen_tag"]
        conversion_tag = reqtags["conversion_tag"]
        mem_type = conversion_tag.getMemType()

        FunctionTemplate.__init__(
            self,
            function_name=tag.getFunctionName(),
            return_type=aftermath.types.builtin.int,
            inline=True,
            arglist=FieldList([
                Field(name="ctx",
                      field_type=aftermath.types.aux.am_io_context,
                      is_pointer=True),
                Field(name="dsk", field_type=dsk_type, is_pointer=True),
                Field(name="mem",
                      field_type=conversion_tag.getMemType(),
                      is_pointer=True)
            ]))

        self.addDefaultArguments(mem_type = mem_type, \
                                 dsk_type = dsk_type, \
                                 **reqtags)
Example #8
0
    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))
Example #9
0
def gen_function_file_template_class_int_ctx(*args, **kwargs):
    """Same as `gen_function_file_template_class`, but sets the return type of
    the function to int and specifies a single parameter ctx that is an
    am_io_context pointer
    """

    return gen_function_file_template_class(
        return_type=aftermath.types.builtin.int,
        arglist=FieldList([
            Field(name="ctx",
                  field_type=aftermath.types.aux.am_io_context,
                  is_pointer=True)
        ]),
        *args,
        **kwargs)
Example #10
0
    def __init__(self, dsk_type):
        Jinja2FileTemplate.__init__(self, "ReadFunction.tpl.c")

        reqtags = self.requireTags(dsk_type,
                                   {"tag": tags.dsk.GenerateReadFunction})

        FunctionTemplate.__init__(
            self,
            function_name=reqtags["tag"].getFunctionName(),
            return_type=aftermath.types.builtin.int,
            inline=True,
            arglist=FieldList([
                Field(name="ctx",
                      field_type=aftermath.types.aux.am_io_context,
                      is_pointer=True),
                Field(name="dsk", field_type=dsk_type, is_pointer=True)
            ]))
        self.addDefaultArguments(dsk_type=dsk_type, **reqtags)
Example #11
0
    def __init__(self, tpl_file, reqtags, mem_type):
        Jinja2FileTemplate.__init__(self, tpl_file)

        tag = reqtags["tag"]
        gen_tag = reqtags["gen_tag"]

        FunctionTemplate.__init__(
            self,
            function_name=tag.getFunctionName(),
            return_type=aftermath.types.builtin.int,
            inline=True,
            arglist=FieldList([
                Field(name="ctx",
                      field_type=aftermath.types.aux.am_io_context,
                      is_pointer=True),
                Field(
                    name="ecoll_id",
                    field_type=aftermath.types.base.am_event_collection_id_t),
                Field(name="sub_id", field_type=gen_tag.getSubArrayIDType()),
                Field(name="e", field_type=mem_type, is_pointer=True)
            ]))

        if gen_tag.getEventCollectionArrayStructName():
            ecoll_array_struct_name = gen_tag.getEventCollectionArrayStructName(
            )
        else:
            ecoll_array_struct_name = mem_type.getName() + "_array"

        if gen_tag.getEventArrayStructName():
            event_array_struct_name = gen_tag.getEventArrayStructName()
        else:
            event_array_struct_name = mem_type.getName() + "_array"

        if gen_tag.getEventArrayIdent():
            event_array_ident = gen_tag.getEventArrayIdent()
        else:
            event_array_ident = mem_type.getIdent()

        self.addDefaultArguments(
            mem_type=mem_type,
            ecoll_array_struct_name=ecoll_array_struct_name,
            event_array_struct_name=event_array_struct_name,
            event_array_ident=event_array_ident,
            **reqtags)
Example #12
0
    def __init__(self, dsk_type):
        Jinja2FileTemplate.__init__(
            self, "GenerateProcessCollectSourcesFunction.tpl.c")

        reqtags = self.requireTags(dsk_type, {
            "gen_tag":
            tags.mem.collect.GenerateProcessCollectSourcesFunction,
        })

        gen_tag = reqtags["gen_tag"]

        FunctionTemplate.__init__(
            self,
            function_name=reqtags["gen_tag"].getFunctionName(),
            return_type=aftermath.types.builtin.int,
            inline=True,
            arglist=FieldList([
                Field(name="ctx",
                      field_type=aftermath.types.aux.am_io_context,
                      is_pointer=True)
            ]))
        self.addDefaultArguments(**reqtags)
Example #13
0
    def __init__(self, t):
        Jinja2FileTemplate.__init__(self, "AssertFunction.tpl.c")

        reqtags = self.requireTags(t, {
            "gen_tag" : tags.assertion.GenerateAssertFunction,
        })

        FunctionTemplate.__init__(
            self,
            function_name = reqtags["gen_tag"].getFunctionName(),
            return_type = aftermath.types.builtin.int,
            inline = True,
            arglist = FieldList([
                Field(name = "ctx",
                      field_type = aftermath.types.aux.am_io_context,
                      is_pointer = True),
                Field(name = "e",
                      field_type = t,
                      is_pointer = True,
                      is_const = True)
            ]))
        self.addDefaultArguments(t = t, **reqtags)
Example #14
0
    def __init__(self, t):
        Jinja2FileTemplate.__init__(self,
                                    "TraceMinMaxTimestampCompoundScan.tpl.c")

        enforce_type(t, aftermath.types.CompoundType)

        reqtags = self.requireTags(
            t,
            {"gen_tag": tags.process.GenerateTraceMinMaxTimestampCompoundScan})

        FunctionTemplate.__init__(
            self,
            function_name=reqtags["gen_tag"].getFunctionName(),
            return_type=aftermath.types.builtin.int,
            inline=True,
            arglist=FieldList([
                Field(name="ctx",
                      field_type=aftermath.types.aux.am_io_context,
                      is_pointer=True),
                Field(name="e", field_type=t, is_pointer=True)
            ]))

        self.addDefaultArguments(t=t, **reqtags)
Example #15
0
# USA.

from aftermath.types import TypeList, Field, FieldList
from aftermath.types.in_memory import InMemoryCompoundType
from aftermath import tags
import aftermath.types.base

am_openmp_for_loop_type = InMemoryCompoundType(
    name = "am_openmp_for_loop_type",
    entity = "OpenMP for loop type",
    comment = "An OpenMP for loop type",
    ident = "am::openmp::for_loop_type",

    fields = FieldList([
        Field(
            name = "source",
            field_type = aftermath.types.in_memory.am_source_location,
            comment = "Location of the source code for this for loop type")]))

################################################################################

am_openmp_for_loop_instance = InMemoryCompoundType(
    name = "am_openmp_for_loop_instance",
    entity = "OpenMP for loop instance",
    comment = "An OpenMP for loop instance",
    ident = "am::openmp::for_loop_instance",

    fields = FieldList([
        Field(
            name = "loop_type",
            field_type = am_openmp_for_loop_type,
Example #16
0
from aftermath import tags
from aftermath.types.on_disk import Frame, EventFrame
import aftermath.types.on_disk

am_dsk_openmp_for_loop_type = Frame(
    name="am_dsk_openmp_for_loop_type",
    entity="on-disk OpenMP for loop",
    comment="An OpenMP for loop type",
    fields=FieldList([
        Field(name="type_id",
              field_type=aftermath.types.builtin.uint64_t,
              comment="Numerical ID of this loop type"),
        Field(name="source",
              field_type=aftermath.types.on_disk.am_dsk_source_location,
              comment="Location of the source code for this for loop type"),
        Field(
            name="addr",
            field_type=aftermath.types.builtin.uint64_t,
            comment="Address of the first instruction of the outlined loop body"
        ),
        Field(name="flags",
              field_type=aftermath.types.builtin.uint32_t,
              comment="Flags for this loop type")
    ]))

tags.dsk.tomem.add_per_trace_array_tags(
    am_dsk_openmp_for_loop_type,
    aftermath.types.openmp.in_memory.am_openmp_for_loop_type)

################################################################################

am_dsk_openmp_for_loop_instance = Frame(
Example #17
0
        EnumVariant("AM_OMPT_CANCEL_DETECTED", 0x20, "Cancel detected"),
        EnumVariant("AM_OMPT_CANCEL_DISCARDED_TASK", 0x40,
                    "Cancel discarded task")
    ])

################################################################################

am_ompt_thread = InMemoryCompoundType(
    name="am_ompt_thread",
    entity="An OpenMP thread execution interval",
    comment="An OpenMP thread execution interval",
    ident="am::ompt::thread",
    fields=FieldList([
        Field(name="kind",
              field_type=am_ompt_thread_t,
              comment="Type of the thread"),
        Field(name="interval",
              field_type=aftermath.types.in_memory.am_interval,
              comment="Interval of the execution")
    ]))

################################################################################

am_ompt_parallel = InMemoryCompoundType(
    name="am_ompt_parallel",
    entity="An OpenMP parallel section execution interval",
    comment="An OpenMP parallel section execution interval",
    ident="am::ompt::parallel",
    fields=FieldList([
        Field(name="requested_parallelism",
              field_type=aftermath.types.builtin.uint32_t,
              comment="Number of threads or teams in the region"),
Example #18
0
from aftermath.types import TypeList, Field, FieldList
from aftermath import relations
from aftermath import tags
from aftermath.types.on_disk import Frame, EventFrame
import aftermath.types.on_disk

am_dsk_openstream_task_type = Frame(
    name="am_dsk_openstream_task_type",
    entity="on-disk OpenStream task type",
    comment="An OpenStream task type",
    fields=FieldList([
        Field(name="type_id",
              field_type=aftermath.types.builtin.uint64_t,
              comment="Numerical ID of this task type"),
        Field(name="name",
              field_type=aftermath.types.on_disk.am_dsk_string,
              comment="Name of this task (e.g., symbol in the executable)"),
        Field(name="source",
              field_type=aftermath.types.on_disk.am_dsk_source_location,
              comment="Location of the source code for this task type")
    ]))

tags.dsk.tomem.add_per_trace_array_tags(
    am_dsk_openstream_task_type,
    aftermath.types.openstream.in_memory.am_openstream_task_type)

################################################################################

am_dsk_openstream_task_instance = Frame(
    name="am_dsk_openstream_task_instance",
    entity="on-disk OpenStream task instance",
Example #19
0
# 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)
Example #20
0
    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))
Example #21
0
 fields = FieldList([
     Field(
         name = "id",
         field_type = aftermath.types.builtin.uint64_t,
         comment = "ID of this candidate"),
     Field(
         name = "parent_id",
         field_type = aftermath.types.builtin.uint64_t,
         comment = "ID of the parent of this candidate"),
     Field(
         name = "discovery_time",
         field_type = aftermath.types.builtin.uint64_t,
         comment = "Timestamp when the candidate was discovered "),
     Field(
         name = "internal_time",
         field_type = aftermath.types.builtin.uint64_t,
         comment = "Timestamp when the candidate was declared an internal " +
         "node (if applicable)"),
     Field(
         name = "rollout_time",
         field_type = aftermath.types.builtin.uint64_t,
         comment = "Timestamp when the candidate was first encountered " +
         "as a rollout node (if applicable)"),
     Field(
         name = "implementation_time",
         field_type = aftermath.types.builtin.uint64_t,
         comment = "Timestamp when the candidate was marked as an " +
         "implementation (if applicable)"),
     Field(
         name = "deadend_time",
         field_type = aftermath.types.builtin.uint64_t,
         comment = "Timestamp when the candidate was first identified as " +
         "a deadend (if applicable)"),
     Field(
         name = "flags",
         field_type = aftermath.types.builtin.uint32_t,
         comment = "Flags (e.g., deadend, etc.)"),
     Field(
         name = "perfmodel_bound",
         field_type = aftermath.types.builtin.double,
         comment = "Lower bound as calculated by the performance model"),
     Field(
         name = "score",
         field_type = aftermath.types.builtin.double,
         comment = "Score from evaluation"),
     Field(
         name = "action",
         field_type = aftermath.types.on_disk.am_dsk_string,
         comment = "Action for this candidate wrt its parent")
 ]))
Example #22
0
                    tags.process.GenerateProcessFunction)
                process_tag.addStep(tags.FunctionTagStep(scan_tag))


#################################################################################

am_counter_event = InMemoryCompoundType(
    name="am_counter_event",
    entity="counter event",
    comment="A counter event",
    ident="am::core::counter_event",
    tags=[tags.mem.dfg.DeclareConstPointerType()],
    fields=FieldList([
        Field(name="time",
              field_type=aftermath.types.base.am_timestamp_t,
              comment="Timestamp of the counter interval"),
        Field(name="value",
              field_type=aftermath.types.base.am_counter_value_t,
              comment="Value of the counter event")
    ]))

#################################################################################

am_interval = InMemoryCompoundType(
    name="am_interval",
    entity="interval",
    comment="An interval with a start and end timestamp.",
    ident="am::core::interval",
    fields=FieldList([
        Field(name="start",
              field_type=aftermath.types.base.am_timestamp_t,
              comment="Start of the interval"),
Example #23
0
# USA.

from aftermath.types import TypeList, Field, FieldList
from aftermath.types.in_memory import InMemoryCompoundType
from aftermath import tags
import aftermath.types.base

am_tensorflow_node = InMemoryCompoundType(
    name="am_tensorflow_node",
    entity="Tensorflow node",
    comment="A tensorflow node (e.g., an operation or a constant)",
    ident="am::tensorflow::node",
    tags=[tags.mem.dfg.DeclareConstPointerType()],
    fields=FieldList([
        Field(name="name",
              field_type=aftermath.types.base.am_string,
              comment="Name of this node")
    ]))

################################################################################

am_tensorflow_node_execution = InMemoryCompoundType(
    name="am_tensorflow_node_execution",
    entity="on-disk Tensorflow node execution",
    comment="An Tensorflow node execution",
    ident="am::tensorflow::node_execution",
    tags=[
        tags.mem.dfg.DeclareConstPointerType(),
        tags.mem.dfg.DeclareEventMappingOverlappingIntervalExtractionNode(
            stripname_plural="tensorflow_node_exectutions",
            port_name="node executions",
Example #24
0
    def __init__(self, type):
        enforce_type(type, CompoundType)

        if not type.hasTag(tags.Destructor):
            raise Exception("Destructor template requires destructor tag")

        dtag = type.getTag(tags.Destructor)

        FunctionTemplate.__init__(self,
                                  function_name=dtag.getFunctionName(),
                                  return_type=aftermath.types.builtin.void,
                                  arglist=FieldList([
                                      Field(name="e",
                                            field_type=type,
                                            is_pointer=dtag.takesAddress())
                                  ]))

        template_content = trimlws("""
        /* Destroys a {{ t.getEntity() }} */
        {{template.getSignature()}}
        {
        	{%- for field in t.getFields() -%}
        	{%- if field.hasCustomDestructor() %}
        	{%- if field.isPointer() %}
        	{{field.getCustomDestructorName()}}(e->{{field.getName()}});
        	{%- else %}
        	{{field.getCustomDestructorName()}}(&e->{{field.getName()}});
        	{%- endif %}
        	{%- else %}
        	{%- if field.isArray() %}

        	{%- if field.getType().hasDestructor() %}
        	{%- set dtag = field.getType().getTag(aftermath.tags.Destructor) %}
        	for(size_t i = 0; i < e->{{field.getArrayNumElementsFieldName()}}; i++) {
        		{%- if not dtag.takesAddress()%}
        		{{dtag.getFunctionName()}}(e->{{field.getName()}}[i]);
        		{%- else %}
        		{{dtag.getFunctionName()}}(&e->{{field.getName()}}[i]);
        		{%- endif -%}
        	}
        	{%- endif %}
        	free(e->{{field.getName()}});
        	{%- else %}
        	{%- if field.getType().hasDestructor() %}
        	{%- set dtag = field.getType().getTag(aftermath.tags.Destructor) %}

        	{%- if not field.isPointer() or field.isOwned() %}
        	{%- if field.isPointer() or not dtag.takesAddress()%}
        	{{dtag.getFunctionName()}}(e->{{field.getName()}});
        	{%- else %}
        	{{dtag.getFunctionName()}}(&e->{{field.getName()}});
        	{%- endif -%}
        	{%- endif -%}
        	{%- endif -%}
        	{%- endif -%}
        	{%- endif -%}
        	{%- endfor -%}
        {# #}
        }""")

        Jinja2StringTemplate.__init__(self, template_content)
        self.addDefaultArguments(t=type)
Example #25
0
# USA.

from aftermath.types import TypeList, Field, FieldList
from aftermath import relations
from aftermath import tags
from aftermath.types.on_disk import Frame, EventFrame
import aftermath.types.on_disk

am_dsk_tensorflow_node = Frame(
    name="am_dsk_tensorflow_node",
    entity="on-disk Tensorflow node",
    comment="An Tensorflow node",
    fields=FieldList([
        Field(name="id",
              field_type=aftermath.types.builtin.uint64_t,
              comment="Numerical ID of this node"),
        Field(name="name",
              field_type=aftermath.types.on_disk.am_dsk_string,
              comment="Name of this node")
    ]))

tags.dsk.tomem.add_per_trace_array_tags(
    am_dsk_tensorflow_node,
    aftermath.types.tensorflow.in_memory.am_tensorflow_node)

################################################################################

am_dsk_tensorflow_node_execution = EventFrame(
    name="am_dsk_tensorflow_node_execution",
    entity="on-disk Tensorflow node execution",
    comment="An Tensorflow node execution",
    fields=FieldList([
Example #26
0
    def __init__(self, type):
        enforce_type(type, CompoundType)

        if not type.hasTag(tags.DefaultConstructor):
            raise Exception("Default constructor template requires " +
                            "default constructor tag")

        ctag = type.getTag(tags.DefaultConstructor)
        gen_tag = type.getTag(tags.GenerateDefaultConstructor)

        FunctionTemplate.__init__(self,
                                  function_name=ctag.getFunctionName(),
                                  return_type=aftermath.types.builtin.int,
                                  arglist=FieldList([
                                      Field(name="e",
                                            field_type=type,
                                            is_pointer=True)
                                  ]))

        template_content = trimlws("""
        {%- set can_fail = {"value" : False} -%}
        /* Initializes a {{ t.getEntity() }} with default values*/
        {{template.getSignature()}}
        {
        	{%- for field in t.getFields() -%}
        	{%- if not field.isPointer() and field.getType().hasDefaultConstructor() %}
        	{%- set ctag = field.getType().getTag(aftermath.tags.DefaultConstructor) %}
        	if({{ctag.getFunctionName()}}(&e->{{field.getName()}}))
        		goto out_err_{{field.getName()}};

        	{%- if can_fail.update({"value": True}) %}{% endif %}
        	{%- endif %}
        	{%- endfor %}

        	{%- for (fieldname, val) in gen_tag.getFieldValues() %}
        	e->{{fieldname}} = {{val}};
        	{%- endfor %}

        	return 0;

        {%- if can_fail.value %}
        	{%- set is_first = True -%}
        	{%- for field in t.getFields()|reverse -%}
        	{%- if field.hasCustomDestructor() %}
        	{%- if field.isPointer() %}
        	{{field.getCustomDestructorName()}}(e->{{field.getName()}});
        	{%- else -%}
        	{{field.getCustomDestructorName()}}(&e->{{field.getName()}});
        	{%- endif -%}
        	{%- elif field.getType().hasDestructor() %}
        	{%- set dtag = field.getType().getTag(aftermath.tags.Destructor) %}
         out_err_{{field.getName()}}:
        	{% if not is_first %}
        	{% if not field.isPointer() or field.isOwned() %}
        	{%- if field.isPointer() or not dtag.takesAddress() %}
        	{{dtag.getFunctionName()}}(e->{{field.getName()}});
        	{%- else %}
        	{{dtag.getFunctionName()}}(&e->{{field.getName()}});
        	{%- endif -%}
        	{%- endif -%}
        	{%- endif -%}
        	{%- endif -%}
        	{% set is_first = False -%}
        	{%- endfor -%}
        	return 1;
        {%- endif %}
        {# #}
        }""")

        Jinja2StringTemplate.__init__(self, template_content)
        self.addDefaultArguments(t=type, gen_tag=gen_tag)
Example #27
0
            name = "collection_id",
            field_type = aftermath.types.builtin.uint32_t,
            comment = "ID of the event collection this event belongs to"),
        0)

#################################################################################

am_dsk_interval = OnDiskCompoundType(
    name = "am_dsk_interval",
    entity = "on-disk interval",
    comment = "An interval with a start and end timestamp",
    fields = FieldList([
        Field(
            name = "start",
            field_type = aftermath.types.builtin.uint64_t,
            comment = "Start of the interval"),
        Field(
            name = "end",
            field_type = aftermath.types.builtin.uint64_t,
            comment = "End of the interval")]))

am_dsk_interval.addTags(
    tags.assertion.GenerateAssertFunction(steps = [
        tags.assertion.AssertStep("{{start}} <= {{end}}",
                                  "Interval cannot end before it starts")
    ]),

    tags.dsk.tomem.GenerateConversionFunction(
        am_dsk_interval,
        aftermath.types.in_memory.am_interval))
Example #28
0
# USA.

from aftermath.types import TypeList, Field, FieldList
from aftermath.types.in_memory import InMemoryCompoundType
from aftermath import tags
import aftermath.types.base

am_openstream_task_type = InMemoryCompoundType(
    name="am_openstream_task_type",
    entity="OpenStream task type",
    comment="An OpenStream task type",
    ident="am::openstream::task_type",
    fields=FieldList([
        Field(name="name",
              field_type=aftermath.types.base.am_string,
              comment="Name of this task (e.g., symbol in the executable)"),
        Field(name="source",
              field_type=aftermath.types.in_memory.am_source_location,
              comment="Location of the source code for this task type")
    ]))

################################################################################

am_openstream_task_instance = InMemoryCompoundType(
    name="am_openstream_task_instance",
    entity="OpenStream task instance",
    comment="An OpenStream task instance",
    ident="am::openstream::task_instance",
    fields=FieldList([
        Field(name="task_type",
              field_type=am_openstream_task_type,
              is_pointer=True,