예제 #1
0
파일: share_data.py 프로젝트: pankajp/pysph
def case2():
    """ 2 processes """
    if num_procs != 2: return
    nbr_list = [1 - rank]
    proc_data = {1 - rank: (rank, 1 - rank)}
    recv_data = share_data(rank, nbr_list, proc_data, comm, multi=True)
    print rank, recv_data
예제 #2
0
파일: share_data.py 프로젝트: pankajp/pysph
def case2():
    """ 2 processes """
    if num_procs != 2: return
    nbr_list = [1-rank]
    proc_data = {1-rank:(rank, 1-rank)}
    recv_data = share_data(rank, nbr_list, proc_data, comm, multi=True)
    print rank, recv_data
예제 #3
0
파일: share_data.py 프로젝트: pankajp/pysph
def case4(multi=True, to_self=False):
    """ all-to-all oneway communication """
    nbr_list = range(num_procs)
    if not to_self: nbr_list.remove(rank)
    proc_data = {}
    for nbr in nbr_list:
        proc_data[nbr] = (rank, nbr)
    recv_data = share_data(rank, nbr_list, proc_data, comm, multi=multi)
    assert len(recv_data) == len(nbr_list)
    if multi:
        for pid,data in recv_data.iteritems():
            assert data == (pid, rank)
    else:
        print rank, recv_data
        for pid,data in recv_data.iteritems():
            for pid2,data2 in data.iteritems():
                assert data2 == (pid, pid2)
예제 #4
0
파일: share_data.py 프로젝트: pankajp/pysph
def case4(multi=True, to_self=False):
    """ all-to-all oneway communication """
    nbr_list = range(num_procs)
    if not to_self: nbr_list.remove(rank)
    proc_data = {}
    for nbr in nbr_list:
        proc_data[nbr] = (rank, nbr)
    recv_data = share_data(rank, nbr_list, proc_data, comm, multi=multi)
    assert len(recv_data) == len(nbr_list)
    if multi:
        for pid, data in recv_data.iteritems():
            assert data == (pid, rank)
    else:
        print rank, recv_data
        for pid, data in recv_data.iteritems():
            for pid2, data2 in data.iteritems():
                assert data2 == (pid, pid2)
예제 #5
0
파일: share_data.py 프로젝트: pankajp/pysph
def case5(multi=True, to_self=False):
    """ oneway communication to next two consecutive procs """
    send_procs = [(rank+1)%num_procs, (rank+2)%num_procs]
    recv_procs = [(rank-1)%num_procs, (rank-2)%num_procs]

    proc_data = {}
    for nbr in send_procs:
        proc_data[nbr] = (rank, nbr)
    print rank, send_procs, recv_procs, proc_data
    recv_data = share_data(rank, send_procs, proc_data, comm, multi=multi,
                           recv_procs=recv_procs)
    assert len(recv_data) == len(recv_procs)
    if multi:
        for pid,data in recv_data.iteritems():
            assert data == (pid, rank)
    else:
        print rank, recv_data
        for pid,data in recv_data.iteritems():
            for pid2,data2 in data.iteritems():
                assert data2 == (pid, pid2)
예제 #6
0
파일: share_data.py 프로젝트: pankajp/pysph
def case1(multi=True, to_self=False):
    """ 5 processes """
    if num_procs != 5: return
    nbr_lists = [[1,4],
                 [0,2,4],
                 [1,3,4],
                 [2],
                 [0,1,2],
                 ]
    nbr_list = nbr_lists[rank]
    if to_self: nbr_list.append(rank)
    proc_data = {}
    for nbr in nbr_list:
        proc_data[nbr] = (rank, nbr)
    recv_data = share_data(rank, nbr_list, proc_data, comm, multi=multi)
    assert len(recv_data) == len(nbr_list)
    if multi:
        for pid,data in recv_data.iteritems():
            assert data == (pid, rank)
    else:
        for pid,data in recv_data.iteritems():
            for pid2,data2 in data.iteritems():
                assert data2 == (pid, pid2)
예제 #7
0
파일: share_data.py 프로젝트: pankajp/pysph
def case1(multi=True, to_self=False):
    """ 5 processes """
    if num_procs != 5: return
    nbr_lists = [
        [1, 4],
        [0, 2, 4],
        [1, 3, 4],
        [2],
        [0, 1, 2],
    ]
    nbr_list = nbr_lists[rank]
    if to_self: nbr_list.append(rank)
    proc_data = {}
    for nbr in nbr_list:
        proc_data[nbr] = (rank, nbr)
    recv_data = share_data(rank, nbr_list, proc_data, comm, multi=multi)
    assert len(recv_data) == len(nbr_list)
    if multi:
        for pid, data in recv_data.iteritems():
            assert data == (pid, rank)
    else:
        for pid, data in recv_data.iteritems():
            for pid2, data2 in data.iteritems():
                assert data2 == (pid, pid2)
예제 #8
0
파일: share_data.py 프로젝트: pankajp/pysph
def case5(multi=True, to_self=False):
    """ oneway communication to next two consecutive procs """
    send_procs = [(rank + 1) % num_procs, (rank + 2) % num_procs]
    recv_procs = [(rank - 1) % num_procs, (rank - 2) % num_procs]

    proc_data = {}
    for nbr in send_procs:
        proc_data[nbr] = (rank, nbr)
    print rank, send_procs, recv_procs, proc_data
    recv_data = share_data(rank,
                           send_procs,
                           proc_data,
                           comm,
                           multi=multi,
                           recv_procs=recv_procs)
    assert len(recv_data) == len(recv_procs)
    if multi:
        for pid, data in recv_data.iteritems():
            assert data == (pid, rank)
    else:
        print rank, recv_data
        for pid, data in recv_data.iteritems():
            for pid2, data2 in data.iteritems():
                assert data2 == (pid, pid2)