loopy/schedule/device_mapping.py
def augment_domain_for_temporary_promotion(
        kernel, domain, promoted_temporary, mode, name_gen):
    """
    Add new axes to the domain corresponding to the dimensions of
    `promoted_temporary`.
    """
    import islpy as isl

    orig_temporary = promoted_temporary.orig_temporary
    orig_dim = domain.dim(isl.dim_type.set)
    dims_to_insert = len(orig_temporary.shape)

    iname_to_tag = {}

    # Add dimension-dependent inames.
    dim_inames = []

    domain = domain.add(isl.dim_type.set, dims_to_insert)
    for t_idx in range(len(orig_temporary.shape)):
        new_iname = name_gen("{name}_{mode}_dim_{dim}".
            format(name=orig_temporary.name,
                   mode=mode,
                   dim=orig_dim + t_idx))
        domain = domain.set_dim_name(
            isl.dim_type.set, orig_dim + t_idx, new_iname)
        #from loopy.kernel.data import auto
        #iname_to_tag[new_iname] = auto
        dim_inames.append(new_iname)

        # Add size information.
        aff = isl.affs_from_space(domain.space)
        domain &= aff[0].le_set(aff[new_iname])
        size = orig_temporary.shape[t_idx]
        from loopy.symbolic import aff_from_expr
        domain &= aff[new_iname].le_set(aff_from_expr(domain.space, size))

    hw_inames = []

    # Add hardware inames duplicates.
    for t_idx, hw_iname in enumerate(promoted_temporary.hw_inames):
        new_iname = name_gen("{name}_{mode}_hw_dim_{dim}".
            format(name=orig_temporary.name,
                   mode=mode,
                   dim=t_idx))
        hw_inames.append(new_iname)
        iname_to_tag[new_iname] = kernel.iname_to_tag[hw_iname]

    from loopy.isl_helpers import duplicate_axes
    domain = duplicate_axes(
        domain, promoted_temporary.hw_inames, hw_inames)

    # The operations on the domain above return a Set object, but the
    # underlying domain should be expressible as a single BasicSet.
    domain_list = domain.get_basic_set_list()
    assert domain_list.n_basic_set() == 1
    domain = domain_list.get_basic_set(0)
    return domain, hw_inames, dim_inames, iname_to_tag

    Add new axes to the domain corresponding to the dimensions of
    `promoted_temporary`.
    
Add new axes to the domain corresponding to the dimensions of
`promoted_temporary`.
Add new axes to the domain corresponding to the dimensions of ` promoted_temporary ` .
def augment_domain_for_temporary_promotion(
        kernel, domain, promoted_temporary, mode, name_gen):
    import islpy as isl
    orig_temporary = promoted_temporary.orig_temporary
    orig_dim = domain.dim(isl.dim_type.set)
    dims_to_insert = len(orig_temporary.shape)
    iname_to_tag = {}
    dim_inames = []
    domain = domain.add(isl.dim_type.set, dims_to_insert)
    for t_idx in range(len(orig_temporary.shape)):
        new_iname = name_gen("{name}_{mode}_dim_{dim}".
            format(name=orig_temporary.name,
                   mode=mode,
                   dim=orig_dim + t_idx))
        domain = domain.set_dim_name(
            isl.dim_type.set, orig_dim + t_idx, new_iname)
        dim_inames.append(new_iname)
        aff = isl.affs_from_space(domain.space)
        domain &= aff[0].le_set(aff[new_iname])
        size = orig_temporary.shape[t_idx]
        from loopy.symbolic import aff_from_expr
        domain &= aff[new_iname].le_set(aff_from_expr(domain.space, size))
    hw_inames = []
    for t_idx, hw_iname in enumerate(promoted_temporary.hw_inames):
        new_iname = name_gen("{name}_{mode}_hw_dim_{dim}".
            format(name=orig_temporary.name,
                   mode=mode,
                   dim=t_idx))
        hw_inames.append(new_iname)
        iname_to_tag[new_iname] = kernel.iname_to_tag[hw_iname]
    from loopy.isl_helpers import duplicate_axes
    domain = duplicate_axes(
        domain, promoted_temporary.hw_inames, hw_inames)
    domain_list = domain.get_basic_set_list()
    assert domain_list.n_basic_set() == 1
    domain = domain_list.get_basic_set(0)
    return domain, hw_inames, dim_inames, iname_to_tag
def augment_domain_for_temporary_promotion ( kernel , domain , promoted_temporary , mode , name_gen ) : import islpy as isl orig_temporary = promoted_temporary . orig_temporary orig_dim = domain . dim ( isl . dim_type . set ) dims_to_insert = len ( orig_temporary . shape ) iname_to_tag = { } dim_inames = [ ] domain = domain . add ( isl . dim_type . set , dims_to_insert ) for t_idx in range ( len ( orig_temporary . shape ) ) : new_iname = name_gen ( "{name}_{mode}_dim_{dim}" . format ( name = orig_temporary . name , mode = mode , dim = orig_dim + t_idx ) ) domain = domain . set_dim_name ( isl . dim_type . set , orig_dim + t_idx , new_iname ) dim_inames . append ( new_iname ) aff = isl . affs_from_space ( domain . space ) domain &= aff [ 0 ] . le_set ( aff [ new_iname ] ) size = orig_temporary . shape [ t_idx ] from loopy . symbolic import aff_from_expr domain &= aff [ new_iname ] . le_set ( aff_from_expr ( domain . space , size ) ) hw_inames = [ ] for t_idx , hw_iname in enumerate ( promoted_temporary . hw_inames ) : new_iname = name_gen ( "{name}_{mode}_hw_dim_{dim}" . format ( name = orig_temporary . name , mode = mode , dim = t_idx ) ) hw_inames . append ( new_iname ) iname_to_tag [ new_iname ] = kernel . iname_to_tag [ hw_iname ] from loopy . isl_helpers import duplicate_axes domain = duplicate_axes ( domain , promoted_temporary . hw_inames , hw_inames ) domain_list = domain . get_basic_set_list ( ) assert domain_list . n_basic_set ( ) == 1 domain = domain_list . get_basic_set ( 0 ) return domain , hw_inames , dim_inames , iname_to_tag
Add new axes to the domain corresponding to the dimensions of
`promoted_temporary`.
Add new axes to the domain corresponding to the dimensions of ` promoted_temporary ` .
"""
    Add new axes to the domain corresponding to the dimensions of
    `promoted_temporary`.
    """ # Add dimension-dependent inames. #from loopy.kernel.data import auto #iname_to_tag[new_iname] = auto # Add size information. # Add hardware inames duplicates. # The operations on the domain above return a Set object, but the # underlying domain should be expressible as a single BasicSet.
kernel
domain
promoted_temporary
mode
name_gen