How to use the deprecated.compiler.lib.lcomp.types.is_region 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 / type_check.py View on Github external
index_type))

        # Check whether the index expression is a compile-time
        # constant value. Add disjointness constraints for the
        # subregion if and only if the the index is constant.
        if isinstance(node.index_expr, ast.ExprConstInt):
            index = node.index_expr.value
            subregion_type = array_type.static_subregion(index, cx)
        else:
            index_expr = node.index_expr
            subregion_type = array_type.dynamic_subregion(index_expr, cx)

        return subregion_type

    # Handle array slicing:
    if types.is_region(array_type) and types.is_ispace(index_type):
        if array_type.kind.ispace is None:
            raise types.TypeError(node, 'Type mismatch in array slice: expected an array but got %s' % (
                    array_type))
        # Check constraints for the index space to make sure it is
        # a subset of the index space of the array.
        success, failed_request = types.check_constraints(
            [types.Constraint(lhs = index_type, op = types.Constraint.SUBREGION, rhs = array_type.kind.ispace)],
            cx.constraints)
        if not success:
            raise types.TypeError(node, 'Invalid constraint %s requested in array slice' % (
                '%s <= %s' % (index_type, array_type.kind.ispace)))

        array_kind = types.RegionKind(index_type, array_type.kind.contains_type)
        subarray_type = types.Region('%s[%s]' % (array_type, index_type), array_kind)
        cx.region_forest.union(subarray_type, array_type)
github StanfordLegion / legion / deprecated / compiler / lib / lcomp / trans.py View on Github external
def trans_for(node, cx):
    cx = cx.new_block_scope()

    index_name = mangle(node, cx)
    index_type = cx.type_map[node.indices.indices[0]]
    for index in node.indices.indices:
        cx.env.insert(index.name, Value(node, Expr(index_name, []), index_type))

    ll_index_type = trans_type(index_type, cx)
    region = cx.env.lookup(node.regions.regions[0].name)
    region_type = region.type
    ll_region = region.read(cx)

    ll_ispace = ll_region
    if types.is_region(region_type):
        ll_ispace = Expr(region.ispace, ll_region.actions)

    temp_domain = mangle_temp()
    temp_iterator = mangle_temp()
    block = (
        ll_ispace.actions +
        ['Domain %s = runtime->get_index_space_domain(ctx, %s);' % (
                temp_domain, ll_ispace.value),
         'for (Domain::DomainPointIterator %s(%s); %s; %s++) {' % (
                temp_iterator, temp_domain, temp_iterator, temp_iterator),
         Block(['%s %s(%s.p.get_index());' % (
                        ll_index_type,
                        index_name,
                        temp_iterator),
                trans_node(node.block, cx)]),
         '}'])
github StanfordLegion / legion / deprecated / compiler / lib / lcomp / type_check.py View on Github external
def _(node, cx):
    coloring_type = type_check_node(node.coloring_expr, cx).check_read(node.coloring_expr, cx)
    pointer_type = type_check_node(node.pointer_expr, cx).check_read(node.pointer_expr, cx)
    color_type = type_check_node(node.color_expr, cx).check_read(node.color_expr, cx)

    if not types.is_coloring(coloring_type):
        raise types.TypeError(node, 'Type mismatch for argument %s in call to task %s: expected %s but got %s' % (
            0, 'color', 'a coloring', coloring_type))
    if types.is_region(coloring_type.region):
        expected_pointer_type = types.Pointer(
            coloring_type.region.kind.contains_type,
            [coloring_type.region])
    elif types.is_ispace(coloring_type.region):
        expected_pointer_type = coloring_type.region.kind.index_type
    else:
        assert False
    if pointer_type != expected_pointer_type:
        raise types.TypeError(node, 'Type mismatch for argument %s in call to task %s: expected %s but got %s' % (
            1, 'color', expected_pointer_type, pointer_type))
    if not types.is_int(color_type):
        raise types.TypeError(node, 'Type mismatch for argument %s in call to task %s: expected %s but got %s' % (
            2, 'color', types.Int(), color_type))
    return coloring_type
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'
    if types.is_foreign_context(t):
        return 'Context'
    if types.is_foreign_pointer(t):
        return 'ptr_t'
    if types.is_foreign_region(t):
github StanfordLegion / legion / deprecated / compiler / lib / lcomp / trans.py View on Github external
'const Task *task',
        'const std::vector ®ions',
        'Context ctx',
        'HighLevelRuntime *runtime',
        ])
    task_type = cx.type_map[task]
    ll_return_type = trans_return_type(task_type.return_type, cx)

    # Normal parameters are passed via TaskArgument.
    params = [mangle(param, cx) for param in task.params.params]
    param_types = [param_type.as_read() for param_type in task_type.param_types]

    # Region parameters are passed via RegionRequirement.
    all_region_nodes = [
        param for param, param_type in zip(task.params.params, task_type.param_types)
        if types.is_region(param_type)]
    all_region_types = [
        param_type for param_type in task_type.param_types
        if types.is_region(param_type)]
    all_regions = [
        param
        for param, param_type in zip(params, param_types)
        if types.is_region(param_type)]

    # Each task has zero or more regions.
    # Each region has zero or more physical regions.
    # Each physical region has one or more accessors.
    # Each accessor has exactly one field.
    #
    # Consider a region r on a struct a with fields x, y, z, w.
    #
    #     task f(r: region<a>)</a>
github StanfordLegion / legion / deprecated / compiler / lib / lcomp / trans.py View on Github external
def trans_copy_helper(node, name, cx):
    copy_value = trans_node(node.expr, cx)
    copy_expr = copy_value.read(cx)
    copy_type = copy_value.type.as_read()
    ll_copy_type = trans_type(copy_type, cx)

    if types.is_region(copy_value.type):
        region_type = cx.type_map[node]
        region_value = Region(
            node = node,
            expr = Expr(name, []),
            type = region_type,
            region_root = copy_value.region_root,
            physical_regions = [],
            physical_region_accessors = [],
            physical_region_privileges = [],
            ispace = copy_value.ispace,
            fspace = copy_value.fspace,
            field_map = copy_value.field_map,
            field_type_map = copy_value.field_type_map,
            allocator = copy_value.allocator,
            accessor_map = copy_value.accessor_map,
            privilege_map = copy_value.privilege_map)
github StanfordLegion / legion / deprecated / compiler / lib / lcomp / type_check.py View on Github external
# Hack: Rather full type inference, which gets ugly fast, just
    # implement "auto-style" inference by using the expression
    # type if no type declaration is provided.
    if declared_type is None:
        if types.is_region(expr_type):
            declared_type = types.Region(node.name, expr_type.kind)
            cx.region_forest.add(declared_type)
        else:
            declared_type = expr_type

    if not types.is_concrete(declared_type):
        raise types.TypeError(node, 'Let bound expressions are not allowed to contain wildcards')
    if types.is_void(declared_type):
        raise types.TypeError(node, 'Let bound expressions are not allowed to be void')
    if types.is_region(expr_type) and types.is_region(declared_type):
        if expr_type.kind != declared_type.kind:
            raise types.TypeError(node, 'Let bound expression of type %s does not match declared type %s' % (
                    expr_type.kind, declared_type.kind))
    else:
        if expr_type != declared_type:
            raise types.TypeError(node, 'Let bound expression of type %s does not match declared type %s' % (
                    expr_type, declared_type))
    cx.insert(node, node.name, declared_type, shadow = True)
    if types.is_region(expr_type):
        cx.region_forest.union(declared_type, expr_type)
        cx.constraints.add(
            types.Constraint(lhs = expr_type, op = types.Constraint.SUBREGION, rhs = declared_type))
        cx.constraints.add(
            types.Constraint(lhs = declared_type, op = types.Constraint.SUBREGION, rhs = expr_type))

    return declared_type
github StanfordLegion / legion / deprecated / compiler / lib / lcomp / type_check.py View on Github external
def _(node, cx):
    arg = cx.lookup(node, node.name)
    if not types.is_region(arg):
        raise types.TypeError(node, 'Type mismatch in type %s: expected a region but got %s' % (
                node.name, arg))
    return arg
github StanfordLegion / legion / deprecated / compiler / lib / lcomp / trans.py View on Github external
assert len(params) == len(args)

    # Region parameters are passed via RegionRequirement.
    region_param_types = [
        param_type
        for param_type in task.type.param_types
        if types.is_region(param_type)]

    region_arg_types = [
        cx.type_map[arg_node]
        for arg_node in node.args.args
        if types.is_region(cx.type_map[arg_node])]
    region_args = [
        arg
        for arg_node, arg in zip(node.args.args, all_args)
        if types.is_region(cx.type_map[arg_node])]
    assert len(region_arg_types) == len(region_args)

    region_roots = [
        cx.regions[cx.regions[region_type].region_root]
        for region_type in region_arg_types]

    # For regions with no privileges requested, do not pass a
    # RegionRequirement.
    privileges_requested = [
        trans_privilege_mode(region_type, task.type.privileges, cx)
        for region_type in region_param_types]

    field_privileges = [
        OrderedDict(
            (field, privilege)
            for privilege, fields in privileges.iteritems()