Skip to content

Instantly share code, notes, and snippets.

@mikaem
Created May 8, 2017 19:26
Show Gist options
  • Save mikaem/cdcfb6f21962c897fe6cc5bb414cac03 to your computer and use it in GitHub Desktop.
Save mikaem/cdcfb6f21962c897fe6cc5bb414cac03 to your computer and use it in GitHub Desktop.
Testing if slab works for mpi4py-fft
from numpy import *
from mpi4py import MPI
from mpi4py_fft.mpifft import PFFT, Function
N = array([25, 28, 23], dtype=int)
for slab in range(3):
fft = PFFT(MPI.COMM_WORLD, N, axes=(0,1,2), collapse=False, slab=slab)
u = Function(fft, False)
u[:] = random.random(u.shape).astype(u.dtype)
u_hat = Function(fft)
u_hat = fft.forward(u, u_hat)
uj = zeros_like(u)
uj = fft.backward(u_hat, uj)
assert allclose(uj, u)
fft.destroy()
MPI.COMM_WORLD.barrier()
if MPI.COMM_WORLD.Get_rank() == 0:
print('Slab ', slab, ' is ok')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment