Beispiel #1
0
def call_louvain(sID, data, num_verts, num_edges, vertex_partition_offsets,
                 aggregate_segment_offsets, max_level, resolution):
    wid = Comms.get_worker_id(sID)
    handle = Comms.get_handle(sID)
    local_size = len(aggregate_segment_offsets) // Comms.get_n_workers(sID)
    segment_offsets = \
        aggregate_segment_offsets[local_size * wid: local_size * (wid + 1)]
    return c_mg_louvain.louvain(data[0], num_verts, num_edges,
                                vertex_partition_offsets, wid, handle,
                                segment_offsets, max_level, resolution)
Beispiel #2
0
def call_sssp(sID, data, num_verts, num_edges, vertex_partition_offsets,
              aggregate_segment_offsets, start):
    wid = Comms.get_worker_id(sID)
    handle = Comms.get_handle(sID)
    local_size = len(aggregate_segment_offsets) // Comms.get_n_workers(sID)
    segment_offsets = \
        aggregate_segment_offsets[local_size * wid: local_size * (wid + 1)]
    return mg_sssp.mg_sssp(data[0], num_verts, num_edges,
                           vertex_partition_offsets, wid, handle,
                           segment_offsets, start)
Beispiel #3
0
def call_bfs(sID, data, src_col_name, dst_col_name, num_verts, num_edges,
             vertex_partition_offsets, aggregate_segment_offsets, start,
             depth_limit, return_distances):
    wid = Comms.get_worker_id(sID)
    handle = Comms.get_handle(sID)
    local_size = len(aggregate_segment_offsets) // Comms.get_n_workers(sID)
    segment_offsets = \
        aggregate_segment_offsets[local_size * wid: local_size * (wid + 1)]
    return mg_bfs.mg_bfs(data[0], src_col_name, dst_col_name, num_verts,
                         num_edges, vertex_partition_offsets, wid, handle,
                         segment_offsets, start, depth_limit, return_distances)
Beispiel #4
0
def call_pagerank(sID, data, num_verts, num_edges, vertex_partition_offsets,
                  aggregate_segment_offsets, alpha, max_iter, tol,
                  personalization, nstart):
    wid = Comms.get_worker_id(sID)
    handle = Comms.get_handle(sID)
    local_size = len(aggregate_segment_offsets) // Comms.get_n_workers(sID)
    segment_offsets = \
        aggregate_segment_offsets[local_size * wid: local_size * (wid + 1)]
    return mg_pagerank.mg_pagerank(data[0], num_verts, num_edges,
                                   vertex_partition_offsets, wid, handle,
                                   segment_offsets, alpha, max_iter, tol,
                                   personalization, nstart)
Beispiel #5
0
def call_katz_centrality(sID, data, src_col_name, dst_col_name, num_verts,
                         num_edges, vertex_partition_offsets,
                         aggregate_segment_offsets, alpha, beta, max_iter, tol,
                         nstart, normalized):
    wid = Comms.get_worker_id(sID)
    handle = Comms.get_handle(sID)
    local_size = len(aggregate_segment_offsets) // Comms.get_n_workers(sID)
    segment_offsets = \
        aggregate_segment_offsets[local_size * wid: local_size * (wid + 1)]
    return mg_katz_centrality.mg_katz_centrality(
        data[0], src_col_name, dst_col_name, num_verts, num_edges,
        vertex_partition_offsets, wid, handle, segment_offsets, alpha, beta,
        max_iter, tol, nstart, normalized)
Beispiel #6
0
def call_wcc(sID,
             data,
             src_col_name,
             dst_col_name,
             num_verts,
             num_edges,
             vertex_partition_offsets,
             aggregate_segment_offsets):
    wid = Comms.get_worker_id(sID)
    handle = Comms.get_handle(sID)
    local_size = len(aggregate_segment_offsets) // Comms.get_n_workers(sID)
    segment_offsets = \
        aggregate_segment_offsets[local_size * wid: local_size * (wid + 1)]
    return mg_connectivity.mg_wcc(data[0],
                                  src_col_name,
                                  dst_col_name,
                                  num_verts,
                                  num_edges,
                                  vertex_partition_offsets,
                                  wid,
                                  handle,
                                  segment_offsets)
Beispiel #7
0
def shuffle(dg, transposed=False):
    """
    Shuffles the renumbered input distributed graph edgelist into ngpu
    partitions. The number of processes/gpus P = prows*pcols. The 2D
    partitioning divides the matrix into P*pcols rectangular partitions
    as per vertex partitioning performed in renumbering, and then shuffles
    these partitions into P gpus.

    Parameters
    ----------
    transposed : bool, optional (default=False)
    """

    ddf = dg.edgelist.edgelist_df
    ngpus = Comms.get_n_workers()
    prows, pcols, partition_type = Comms.get_2D_partition()

    renumber_vertex_count = dg.renumber_map.implementation.\
        ddf.map_partitions(len).compute()
    renumber_vertex_cumsum = renumber_vertex_count.cumsum()

    if transposed:
        row_dtype = ddf['dst'].dtype
        col_dtype = ddf['src'].dtype
    else:
        row_dtype = ddf['src'].dtype
        col_dtype = ddf['dst'].dtype

    vertex_partition_offsets = cudf.Series([0], dtype=row_dtype)
    vertex_partition_offsets = vertex_partition_offsets.append(
        cudf.Series(renumber_vertex_cumsum, dtype=row_dtype))
    num_verts = vertex_partition_offsets.iloc[-1]
    if partition_type == 1:
        vertex_row_partitions = []
        for i in range(prows + 1):
            vertex_row_partitions.append(vertex_partition_offsets.iloc[i *
                                                                       pcols])
        vertex_row_partitions = cudf.Series(vertex_row_partitions,
                                            dtype=row_dtype)
    else:
        vertex_row_partitions = vertex_partition_offsets
    vertex_col_partitions = []
    for i in range(pcols + 1):
        vertex_col_partitions.append(vertex_partition_offsets.iloc[i * prows])
    vertex_col_partitions = cudf.Series(vertex_col_partitions, dtype=col_dtype)

    meta = ddf._meta._constructor_sliced([0])
    partitions = ddf.map_partitions(
        _set_partitions_pre,
        vertex_row_partitions=vertex_row_partitions,
        vertex_col_partitions=vertex_col_partitions,
        prows=prows,
        pcols=pcols,
        transposed=transposed,
        partition_type=partition_type,
        meta=meta)
    ddf2 = ddf.assign(_partitions=partitions)
    ddf3 = rearrange_by_column(
        ddf2,
        "_partitions",
        max_branch=None,
        npartitions=ngpus,
        shuffle="tasks",
        ignore_index=True,
    ).drop(columns=["_partitions"])

    partition_row_size = pcols
    partition_col_size = prows

    return (ddf3, num_verts, partition_row_size, partition_col_size,
            vertex_partition_offsets)