utils.py
def greedy_partition_grower(n_nodes: int, ppn: int, stencil: list, grid: list) -> list:
    """
    For each partition, randomly select a starting vertex and greedily expand the graph
    around it.
    :param n_node: Number of nodes
    :param ppn: Number of processes per node
    :param stencil: integer flattened list describing offset
    :param grid: integer list describing the dimensions of the grid
    :return: p = permutation list
    """
    n_proc = n_nodes * ppn
    unassigned_vertices = list(range(n_proc))
    p = [-1] * n_proc
    for node_idx in range(n_nodes):
        boundary_vertices = []
        start_index = random.choice(range(len(unassigned_vertices)))
        start_rank = unassigned_vertices.pop(start_index)
        p[node_idx * ppn] = start_rank
        boundary_vertices += extract_neighbors(start_rank, stencil, grid)
        assigned_to_node = 1

        # Select a random vertex from boundary region and remove it from list
        while assigned_to_node < ppn:
            if len(boundary_vertices):
                next_rank = boundary_vertices.pop(random.choice(range(len(boundary_vertices))))
            else:
                next_rank = unassigned_vertices.pop(random.choice(range(len(unassigned_vertices))))
            #Check if it assigned in p and assign if not
            if not next_rank in p:
                p[node_idx * ppn + assigned_to_node] = next_rank
                #logging.info("Next rank {}".format(next_rank))
                boundary_vertices += extract_neighbors(next_rank, stencil, grid)
                assigned_to_node += 1
            #Remove it from unassigned vertices
            try:
                unassigned_vertices.remove(next_rank)
            except:
                pass

    return p

    For each partition, randomly select a starting vertex and greedily expand the graph
    around it.
    :param n_node: Number of nodes
    :param ppn: Number of processes per node
    :param stencil: integer flattened list describing offset
    :param grid: integer list describing the dimensions of the grid
    :return: p = permutation list
    
For each partition, randomly select a starting vertex and greedily expand the graph
around it.
For each partition randomly select a starting vertex and greedily expand the graph around it .
def greedy_partition_grower(n_nodes: int, ppn: int, stencil: list, grid: list) -> list:
    n_proc = n_nodes * ppn
    unassigned_vertices = list(range(n_proc))
    p = [-1] * n_proc
    for node_idx in range(n_nodes):
        boundary_vertices = []
        start_index = random.choice(range(len(unassigned_vertices)))
        start_rank = unassigned_vertices.pop(start_index)
        p[node_idx * ppn] = start_rank
        boundary_vertices += extract_neighbors(start_rank, stencil, grid)
        assigned_to_node = 1
        while assigned_to_node < ppn:
            if len(boundary_vertices):
                next_rank = boundary_vertices.pop(random.choice(range(len(boundary_vertices))))
            else:
                next_rank = unassigned_vertices.pop(random.choice(range(len(unassigned_vertices))))
            if not next_rank in p:
                p[node_idx * ppn + assigned_to_node] = next_rank
                boundary_vertices += extract_neighbors(next_rank, stencil, grid)
                assigned_to_node += 1
            try:
                unassigned_vertices.remove(next_rank)
            except:
                pass
    return p
def greedy_partition_grower ( n_nodes : int , ppn : int , stencil : list , grid : list ) -> list : n_proc = n_nodes * ppn unassigned_vertices = list ( range ( n_proc ) ) p = [ - 1 ] * n_proc for node_idx in range ( n_nodes ) : boundary_vertices = [ ] start_index = random . choice ( range ( len ( unassigned_vertices ) ) ) start_rank = unassigned_vertices . pop ( start_index ) p [ node_idx * ppn ] = start_rank boundary_vertices += extract_neighbors ( start_rank , stencil , grid ) assigned_to_node = 1 while assigned_to_node < ppn : if len ( boundary_vertices ) : next_rank = boundary_vertices . pop ( random . choice ( range ( len ( boundary_vertices ) ) ) ) else : next_rank = unassigned_vertices . pop ( random . choice ( range ( len ( unassigned_vertices ) ) ) ) if not next_rank in p : p [ node_idx * ppn + assigned_to_node ] = next_rank boundary_vertices += extract_neighbors ( next_rank , stencil , grid ) assigned_to_node += 1 try : unassigned_vertices . remove ( next_rank ) except : pass return p
For each partition, randomly select a starting vertex and greedily expand the graph
around it.
For each partition randomly select a starting vertex and greedily expand the graph around it .
"""
    For each partition, randomly select a starting vertex and greedily expand the graph
    around it.
    :param n_node: Number of nodes
    :param ppn: Number of processes per node
    :param stencil: integer flattened list describing offset
    :param grid: integer list describing the dimensions of the grid
    :return: p = permutation list
    """ # Select a random vertex from boundary region and remove it from list #Check if it assigned in p and assign if not #logging.info("Next rank {}".format(next_rank)) #Remove it from unassigned vertices
p = permutation list
p = permutation list
n_nodes
int
ppn
int
Number of processes per node
Number of processes per node
stencil
list
integer flattened list describing offset
integer flattened list describing offset
grid
list
integer list describing the dimensions of the grid
integer list describing the dimensions of the grid
n_node
Number of nodes
Number of nodes