How to correctly use MPI with Devito? #2747
-
|
When I use MPI to parallelize the wavefield simulation with the method AcousticWaveSolver imported from devito, the shapes of the simulated wavefields are not as expected. `from mpi4py import MPI from examples.seismic import Model, RickerSource, Receiver, TimeAxis, AcquisitionGeometry ------------------------------------------MPI setup------------------------------------------comm = MPI.COMM_WORLD ------------------------------------------Define source locations (one per rank)------------------------------------------num_shots = 10 if size != num_shots: my_source_coords = source_locations[0] ------------------------------------------Create velocity model------------------------------------------shape = (201, 201) # grid points vp = 1500. * np.ones(shape, dtype=np.float32) model = Model(vp=vp, origin=(0., 0.), shape=shape, ------------------------------------------Time axis------------------------------------------t0, tn, dt = 0., 1000., 1.0 ------------------------------------------Define source and receiver geometry------------------------------------------src = RickerSource(name='src', grid=model.grid, f0=0.01, time_range=time_axis) src.coordinates.data[0, :] = np.array(my_source_coords) nrec = 101 ------------------------------------------Set up and run the forward solver------------------------------------------solver = AcousticWaveSolver(model, geometry, time_order=2, space_order=4) rec_data, u, _ = solver.forward(save=True) Save wavefield and receiver data for this shot#np.save(f"wavefield_shot{rank}.npy", u.data) print(f"Rank {rank}: u.shape = {u.shape}, rec.shape = {rec_data.shape}") `Rank 1: u.shape = (246186, 57, 140) Rank 4: u.shape = (246186, 56, 141) Rank 5: u.shape = (246186, 56, 140) Rank 8: u.shape = (246186, 56, 141) Rank 9: u.shape = (246186, 56, 140) Rank 3: u.shape = (246186, 56, 140) Rank 6: u.shape = (246186, 56, 141) Rank 7: u.shape = (246186, 56, 140) Rank 2: u.shape = (246186, 56, 141) Rank 0: u.shape = (246186, 57, 141)` What am I missing here? How to get the complete wavefield corresponding to each source location at once using mpi4py, rather than performing serial simulations? Many Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
MPI is used fror domain decomposition,i.e the domain is slit into smaller domain, one for each rank. So you can either gather the wavefield at the end (which defeat the purpose so why use mpi in the first place and just use openmp) or work with each domain individually. |
Beta Was this translation helpful? Give feedback.
MPI is used fror domain decomposition,i.e the domain is slit into smaller domain, one for each rank. So you can either gather the wavefield at the end (which defeat the purpose so why use mpi in the first place and just use openmp) or work with each domain individually.