Esempio n. 1
0
def test_fetch_op():

    a0 = np.zeros(1, dtype=INT64)
    a1 = np.zeros(1, dtype=INT64)
    b0 = np.zeros(1, dtype=INT64)
    b1 = np.zeros(MPISIZE, INT64)

    a0[:] = 1
    a1[:] = -1
    b1[:] = -1

    comm = MPI.COMM_WORLD
    gwin = MPI.Win()
    win = gwin.Create(b0, b0[0].nbytes, comm=comm)

    comm.Barrier()
    win.Fence()

    win.Fetch_and_op(a0, a1, 0, 0)

    win.Fence()
    comm.Barrier()

    comm.Gather(a1, b1)

    comm.Barrier()
    if MPIRANK == 0:
        assert b0[0] == MPISIZE
        required = set(range(MPISIZE))
        for bx in b1:
            required.remove(bx)
        assert len(required) == 0