sidpy/proc/comp_utils.py
def group_ranks_by_socket(verbose=False):
    """
    Groups MPI ranks in COMM_WORLD by socket. Another way to think about this
    is that it assigns a master rank for each rank such that there is a single
    master rank per socket (CPU). The results from this function can be used to
    split MPI communicators based on the socket for intra-node communication.

    Parameters
    ----------
    verbose : bool, optional
        Whether or not to print debugging statements

    Returns
    -------
    master_ranks : 1D unsigned integer :class:`numpy.ndarray`
        Array with values that signify which rank a given rank should consider
        its master.

    Notes
    -----
    This is necessary when wanting to carve up the memory for all ranks within
    a socket. This is also relevant when trying to bring down the number of
    ranks that are writing to the HDF5 file. This is all based on the premise
    that data analysis involves a fair amount of file writing and writing with
    3 ranks is a lot better than writing with 100 ranks. An assumption is made
    that the communication between the ranks within each socket would be faster
    than communicating across nodes / scokets. No assumption is made about the
    names of each socket
    """
    MPI = get_MPI()

    comm = MPI.COMM_WORLD
    size = comm.Get_size()
    rank = comm.Get_rank()

    # Step 1: Gather all the socket names:
    sendbuf = MPI.Get_processor_name()
    if verbose:
        print('Rank: ', rank, ', sendbuf: ', sendbuf)
    recvbuf = comm.allgather(sendbuf)
    if verbose and rank == 0:
        print('Rank: ', rank, ', recvbuf received: ', recvbuf)

    # Step 2: Find all unique socket names:
    recvbuf = np.array(recvbuf)
    unique_sockets = np.unique(recvbuf)
    if verbose and rank == 0:
        print('Unique sockets: {}'.format(unique_sockets))

    master_ranks = np.zeros(size, dtype=np.uint16)

    for item in unique_sockets:
        temp = np.where(recvbuf == item)[0]
        master_ranks[temp] = temp[0]

    if verbose and rank == 0:
        print('Parent rank for all ranks: {}'.format(master_ranks))

    return master_ranks

    Groups MPI ranks in COMM_WORLD by socket. Another way to think about this
    is that it assigns a master rank for each rank such that there is a single
    master rank per socket (CPU). The results from this function can be used to
    split MPI communicators based on the socket for intra-node communication.

    Parameters
    ----------
    verbose : bool, optional
        Whether or not to print debugging statements

    Returns
    -------
    master_ranks : 1D unsigned integer :class:`numpy.ndarray`
        Array with values that signify which rank a given rank should consider
        its master.

    Notes
    -----
    This is necessary when wanting to carve up the memory for all ranks within
    a socket. This is also relevant when trying to bring down the number of
    ranks that are writing to the HDF5 file. This is all based on the premise
    that data analysis involves a fair amount of file writing and writing with
    3 ranks is a lot better than writing with 100 ranks. An assumption is made
    that the communication between the ranks within each socket would be faster
    than communicating across nodes / scokets. No assumption is made about the
    names of each socket
    
Groups MPI ranks in COMM_WORLD by socket. Another way to think about this
is that it assigns a master rank for each rank such that there is a single
master rank per socket (CPU). The results from this function can be used to
split MPI communicators based on the socket for intra-node communication.

Parameters

verbose : bool, optional
Whether or not to print debugging statements

Returns

master_ranks : 1D unsigned integer :class:`numpy.ndarray`
Array with values that signify which rank a given rank should consider
its master.

Notes

This is necessary when wanting to carve up the memory for all ranks within
a socket. This is also relevant when trying to bring down the number of
ranks that are writing to the HDF5 file. This is all based on the premise
that data analysis involves a fair amount of file writing and writing with
3 ranks is a lot better than writing with 100 ranks. An assumption is made
that the communication between the ranks within each socket would be faster
than communicating across nodes / scokets. No assumption is made about the
names of each socket
Groups MPI ranks in COMM_WORLD by socket . Another way to think about this is that it assigns a master rank for each rank such that there is a single master rank per socket ( CPU ) . The results from this function can be used to split MPI communicators based on the socket for intra - node communication . Parameters verbose : bool optional Whether or not to print debugging statements Returns master_ranks : 1D unsigned integer : class : ` numpy . ndarray ` Array with values that signify which rank a given rank should consider its master . Notes This is necessary when wanting to carve up the memory for all ranks within a socket . This is also relevant when trying to bring down the number of ranks that are writing to the HDF5 file . This is all based on the premise that data analysis involves a fair amount of file writing and writing with 3 ranks is a lot better than writing with 100 ranks . An assumption is made that the communication between the ranks within each socket would be faster than communicating across nodes / scokets . No assumption is made about the names of each socket
def group_ranks_by_socket(verbose=False):
    MPI = get_MPI()
    comm = MPI.COMM_WORLD
    size = comm.Get_size()
    rank = comm.Get_rank()
    sendbuf = MPI.Get_processor_name()
    if verbose:
        print('Rank: ', rank, ', sendbuf: ', sendbuf)
    recvbuf = comm.allgather(sendbuf)
    if verbose and rank == 0:
        print('Rank: ', rank, ', recvbuf received: ', recvbuf)
    recvbuf = np.array(recvbuf)
    unique_sockets = np.unique(recvbuf)
    if verbose and rank == 0:
        print('Unique sockets: {}'.format(unique_sockets))
    master_ranks = np.zeros(size, dtype=np.uint16)
    for item in unique_sockets:
        temp = np.where(recvbuf == item)[0]
        master_ranks[temp] = temp[0]
    if verbose and rank == 0:
        print('Parent rank for all ranks: {}'.format(master_ranks))
    return master_ranks
def group_ranks_by_socket ( verbose = False ) : MPI = get_MPI ( ) comm = MPI . COMM_WORLD size = comm . Get_size ( ) rank = comm . Get_rank ( ) sendbuf = MPI . Get_processor_name ( ) if verbose : print ( 'Rank: ' , rank , ', sendbuf: ' , sendbuf ) recvbuf = comm . allgather ( sendbuf ) if verbose and rank == 0 : print ( 'Rank: ' , rank , ', recvbuf received: ' , recvbuf ) recvbuf = np . array ( recvbuf ) unique_sockets = np . unique ( recvbuf ) if verbose and rank == 0 : print ( 'Unique sockets: {}' . format ( unique_sockets ) ) master_ranks = np . zeros ( size , dtype = np . uint16 ) for item in unique_sockets : temp = np . where ( recvbuf == item ) [ 0 ] master_ranks [ temp ] = temp [ 0 ] if verbose and rank == 0 : print ( 'Parent rank for all ranks: {}' . format ( master_ranks ) ) return master_ranks
Groups MPI ranks in COMM_WORLD by socket.
Groups MPI ranks in COMM_WORLD by socket .
"""
    Groups MPI ranks in COMM_WORLD by socket. Another way to think about this
    is that it assigns a master rank for each rank such that there is a single
    master rank per socket (CPU). The results from this function can be used to
    split MPI communicators based on the socket for intra-node communication.

    Parameters
    ----------
    verbose : bool, optional
        Whether or not to print debugging statements

    Returns
    -------
    master_ranks : 1D unsigned integer :class:`numpy.ndarray`
        Array with values that signify which rank a given rank should consider
        its master.

    Notes
    -----
    This is necessary when wanting to carve up the memory for all ranks within
    a socket. This is also relevant when trying to bring down the number of
    ranks that are writing to the HDF5 file. This is all based on the premise
    that data analysis involves a fair amount of file writing and writing with
    3 ranks is a lot better than writing with 100 ranks. An assumption is made
    that the communication between the ranks within each socket would be faster
    than communicating across nodes / scokets. No assumption is made about the
    names of each socket
    """ # Step 1: Gather all the socket names: # Step 2: Find all unique socket names:
verbose