How to use the deprecated.compiler.lib.lcomp.types function in Deprecated

To help you get started, we’ve selected a few Deprecated examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github StanfordLegion / legion / deprecated / compiler / lib / lcomp / trans.py View on Github external
'struct %s {' % mangle_type(t, cx),
                 Block(['ptr_t pointer;',
                        'uint32_t region;']),
                 '};'])
            return Value(
                t,
                Expr(mangle_type(t, cx), struct_definition),
                types.Kind(t))
        assert False
    if types.is_struct_instance(t):
        return None
    if types.is_struct(t):
        # For types defined in foreign modules, define nothing and return
        # the foreign type.
        if types.contains_key(cx.foreign_types, t):
            t = types.find_key(cx.foreign_types, t)
            return Value(t, Expr(t.name, []), types.Kind(t))
        struct_definition = (
            ['// type def for %s' % t.pretty(),
             'struct %s {' % mangle_type(t, cx),
             Block(['%s %s;' % (trans_type(region, cx), region.name)
                    for region in t.regions] +
                   ['%s %s;' % (trans_type(field_type, cx), field_name)
                    for field_name, field_type in t.field_map.iteritems()]),
             '};'])
        return Value(
            t,
            Expr(mangle_type(t, cx), struct_definition),
            types.Kind(t))
    return None
github StanfordLegion / legion / deprecated / compiler / lib / lcomp / trans.py View on Github external
['// type def for multi-region pointers',
                 'struct %s {' % mangle_type(t, cx),
                 Block(['ptr_t pointer;',
                        'uint32_t region;']),
                 '};'])
            return Value(
                t,
                Expr(mangle_type(t, cx), struct_definition),
                types.Kind(t))
        assert False
    if types.is_struct_instance(t):
        return None
    if types.is_struct(t):
        # For types defined in foreign modules, define nothing and return
        # the foreign type.
        if types.contains_key(cx.foreign_types, t):
            t = types.find_key(cx.foreign_types, t)
            return Value(t, Expr(t.name, []), types.Kind(t))
        struct_definition = (
            ['// type def for %s' % t.pretty(),
             'struct %s {' % mangle_type(t, cx),
             Block(['%s %s;' % (trans_type(region, cx), region.name)
                    for region in t.regions] +
                   ['%s %s;' % (trans_type(field_type, cx), field_name)
                    for field_name, field_type in t.field_map.iteritems()]),
             '};'])
        return Value(
            t,
            Expr(mangle_type(t, cx), struct_definition),
            types.Kind(t))
    return None
github StanfordLegion / legion / deprecated / compiler / lib / lcomp / trans.py View on Github external
def trans_type(t, cx):
    # Translate simple types:
    if types.is_POD(t):
        return types.type_name(t)
    if types.is_void(t):
        return types.type_name(t)
    if types.is_ispace(t):
        return 'IndexSpace'
    if types.is_region(t):
        return 'LogicalRegion'
    if types.is_coloring(t):
        return 'Coloring'
    if types.is_pointer(t) and len(t.regions) == 1:
        return 'ptr_t'
    if types.is_reference(t):
        return trans_type(t.as_read(), cx)

    # Translate foreign types:
    if types.is_foreign_coloring(t):
        return 'Coloring'
github StanfordLegion / legion / deprecated / compiler / lib / lcomp / trans.py View on Github external
parent_region = cx.env.lookup(node.region_type.name)
    parent_region_expr = parent_region.read(cx)
    coloring_expr = trans_node(node.coloring_expr, cx).read(cx)
    temp_coloring_name = mangle_temp()
    index_partition = mangle_temp()
    logical_partition = mangle_temp()

    subregions = partition_type.static_subregions

    ll_regions = [mangle_temp() for region in subregions]
    ispaces = [mangle_temp() for region in subregions]
    allocators = [mangle_temp() for region in subregions]
    region_types = [region_type for region_type in subregions.itervalues()]

    # Handle index spaces:
    if types.is_ispace(partition_type.kind.region):
        create_partition = (
            parent_region_expr.actions +
            coloring_expr.actions +
            ['Coloring %s = %s;' % (temp_coloring_name, coloring_expr.value)] +
            ['%s[%s];' % (temp_coloring_name, color)
             for color in subregions.keys()] +
            ['IndexPartition %s = runtime->create_index_partition(ctx, %s, %s, %s);' % (
                    index_partition, parent_region_expr.value, temp_coloring_name,
                    'true' if partition_type.kind.mode == types.Partition.DISJOINT else 'false')] +
            ['IndexSpace %s = runtime->get_index_subspace(ctx, %s, Color(%s));' % (
                    ispace,
                    index_partition,
                    color)
             for ispace, color in zip(ispaces, subregions.keys())] +
            ['IndexAllocator %s = runtime->create_index_allocator(ctx, %s);' % (
                    ispace_alloc, ispace)
github StanfordLegion / legion / deprecated / compiler / lib / lcomp / trans.py View on Github external
subregions = partition_type.static_subregions

    ll_regions = [mangle_temp() for region in subregions]
    ispaces = [mangle_temp() for region in subregions]
    allocators = [mangle_temp() for region in subregions]
    region_types = [region_type for region_type in subregions.itervalues()]

    create_partition = (
        parent_region_expr.actions +
        coloring_expr.actions +
        ['Coloring %s = %s;' % (temp_coloring_name, coloring_expr.value)] +
        ['%s[%s];' % (temp_coloring_name, color)
         for color in subregions.keys()] +
        ['IndexPartition %s = runtime->create_index_partition(ctx, %s, %s, %s);' % (
                index_partition, parent_region.ispace, temp_coloring_name,
                'true' if partition_type.kind.mode == types.Partition.DISJOINT else 'false'),
         'LogicalPartition %s = runtime->get_logical_partition(ctx, %s, %s);' % (
                logical_partition, parent_region_expr.value, index_partition)] +
        ['LogicalRegion %s = runtime->get_logical_subregion_by_color(ctx, %s, Color(%s));' % (
                ll_region,
                logical_partition,
                color)
         for ll_region, color in zip(ll_regions, subregions.keys())] +
        ['IndexSpace %s = %s.get_index_space();' % (ispace, ll_region)
         for ispace, ll_region in zip(ispaces, ll_regions)] +
        ['IndexAllocator %s = runtime->create_index_allocator(ctx, %s);' % (
                ispace_alloc, ispace)
         for ispace_alloc, ispace in zip(allocators, ispaces)])

    partition_value = Partition(
        node = node,
        expr = Expr(logical_partition, []),
github StanfordLegion / legion / deprecated / compiler / lib / lcomp / trans.py View on Github external
def trans_type(t, cx):
    # Translate simple types:
    if types.is_POD(t):
        return types.type_name(t)
    if types.is_void(t):
        return types.type_name(t)
    if types.is_ispace(t):
        return 'IndexSpace'
    if types.is_region(t):
        return 'LogicalRegion'
    if types.is_coloring(t):
        return 'Coloring'
    if types.is_pointer(t) and len(t.regions) == 1:
        return 'ptr_t'
    if types.is_reference(t):
        return trans_type(t.as_read(), cx)

    # Translate foreign types:
    if types.is_foreign_coloring(t):
github StanfordLegion / legion / deprecated / compiler / lib / lcomp / trans.py View on Github external
def trans_array_access(node, cx):
    array_value = trans_node(node.array_expr, cx)
    array_expr = array_value.read(cx)
    array_type = array_value.type.as_read()
    index_value = trans_node(node.index_expr, cx)
    index_expr = index_value.read(cx)
    index_type = index_value.type.as_read()

    # Handle partitions:
    if types.is_partition(array_type):
        region_type = cx.type_map[node]

        # If the subregion already exists (e.g. because it is static),
        # reuse it.
        if region_type in cx.regions:
            return cx.regions[region_type]

        # Otherwise generate a fresh subregion.
        parent_region = array_value.region

        ll_region = mangle_temp()
        ispace = mangle_temp()
        allocator = mangle_temp()

        # Handle index spaces:
        if types.is_ispace(array_type.kind.region):
github StanfordLegion / legion / deprecated / compiler / lib / lcomp / trans.py View on Github external
def trans_program(node, cx):
    cx = cx.new_global_scope()
    defs = node.definitions.definitions
    type_list = [
        d for d in defs if types.is_kind(cx.type_map[d])]
    import_list = [
        d for d in defs
        if not types.is_kind(cx.type_map[d]) and isinstance(d, ast.Import)]
    other_list = [
        d for d in defs
        if not types.is_kind(cx.type_map[d]) and not isinstance(d, ast.Import)]
    task_list = [d for d in defs if isinstance(d, ast.Function)]

    type_defs = trans_type_defs(type_list, cx)
    reduction_op_defs = trans_reduction_ops(task_list, cx)
    import_defs = [trans_node(definition, cx) for definition in import_list]
    other_defs = [trans_node(definition, cx) for definition in other_list]

    top_level_task = check_top_level_task(task_list, cx)

    task_prototypes = [trans_function_prototype(task, cx) for task in task_list]
github StanfordLegion / legion / deprecated / compiler / lib / lcomp / type_check.py View on Github external
def is_eq(t): return types.is_POD(t) or types.is_pointer(t)
def returns_same_type(*ts): return ts[0]
def returns_bool(*_ignored): return types.Bool()
unary_operator_table = {
    '-': (types.is_numeric, returns_same_type),
    '!': (types.is_bool, returns_bool),
    '~': (types.is_integral, returns_same_type),
}
binary_operator_table = {
    '*':  (types.is_numeric, returns_same_type),
    '/':  (types.is_numeric, returns_same_type),
    '%':  (types.is_integral, returns_same_type),
    '+':  (types.is_numeric, returns_same_type),
    '-':  (types.is_numeric, returns_same_type),
    '>>': (types.is_integral, returns_same_type),
    '<<': (types.is_integral, returns_same_type),
    '<':  (types.is_numeric, returns_bool),
    '<=': (types.is_numeric, returns_bool),
    '>':  (types.is_numeric, returns_bool),
    '>=': (types.is_numeric, returns_bool),
    '==': (is_eq, returns_bool),
    '!=': (is_eq, returns_bool),
    '&':  (types.is_integral, returns_same_type),
    '^':  (types.is_integral, returns_same_type),
    '|':  (types.is_integral, returns_same_type),
    '&&': (types.is_bool, returns_bool),
    '||': (types.is_bool, returns_bool),
}
reduce_operator_table = {
    '*':  types.is_numeric,
    '/':  types.is_numeric,
github StanfordLegion / legion / deprecated / compiler / lib / lcomp / trans.py View on Github external
def trans_return_type(t, cx):
    # Some types need to be passed via wrapper objects. These types
    # are listed below.
    if types.is_coloring(t):
        return 'ColoringSerializer'
    if types.is_foreign_coloring(t):
        return 'ColoringSerializer'

    return trans_type(t, cx)