Esempio n. 1
0
    def __del__(self):
        ierr = -1

        # Free the datatype
        mpi_type_free(self.type_line, ierr)
        mpi_type_free(self.type_column, ierr)

        # Destruction of the communicators
        mpi_comm_free(self.comm_cart, ierr)
Esempio n. 2
0
mpi_cart_coords(comm_2d, rank_in_topo, ndims, coords, ierr)

# Search of my West and East neigbors
mpi_cart_shift(comm_2d, 0, steps[0], neighbor[west], neighbor[east], ierr)

# Search of my South and North neighbors
mpi_cart_shift(comm_2d, 1, steps[1], neighbor[south], neighbor[north], ierr)

m = 4
v = zeros(m, double)
if coords[0] == 1:
    v = (rank + 1) * 1.0

# Every row of the grid must be a 1D cartesian topology
remain_dims = [True, False]

# Subdivision of the 2D cartesian grid
mpi_cart_sub(comm_2d, remain_dims, comm_1d, ierr)

# The processes of column 2 distribute the V vector to the processes of their row
w = 0.0
mpi_scatter(v, 1, MPI_DOUBLE, w, 1, MPI_DOUBLE, 1, comm_1d, ierr)

print("Rank : ", rank, " ; Coordinates : (", coords, ") ; W = ", w)

# Destruction of the communicators
mpi_comm_free(comm_1d, ierr)
mpi_comm_free(comm_2d, ierr)

mpi_finalize(ierr)
Esempio n. 3
0
a = zeros(m, int)

if rank_in_world == 1:
    a = 1
if rank_in_world == 2:
    a = 2

key = rank_in_world
if rank_in_world == 1:
    key = -1
if rank_in_world == 2:
    key = -1

two = 2
color = mod(rank_in_world, two)

newcomm = -1
mpi_comm_split(comm, color, key, newcomm, ierr)

# Broadcast of the message by the rank process master of
# each communicator to the processes of its group
mpi_bcast(a, m, MPI_INTEGER, master, newcomm, ierr)

print("> processor ", rank_in_world, " has a = ", a)

# Destruction of the communicators
mpi_comm_free(newcomm, ierr)

mpi_finalize(ierr)