In [1]:
import os
In [2]:
os.getcwd()
Out[2]:
In [3]:
import ipyparallel as ipp
c = ipp.Client(profile='mpi')
print(c.ids)
view = c[:]
view.activate()
In [4]:
%%px --block
import os
os.getcwd()
In [10]:
%%writefile test001.py
#%%px --block
from mpi4py import MPI
import time
import numpy as np
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
t = MPI.Wtime()
print("result =",np.max(np.random.randn(5000,5000//4)))
t = MPI.Wtime() - t
print(rank,":: execution time:",t)
In [11]:
!mpirun -n 2 python test001.py
In [12]:
import numpy as np
In [27]:
x = np.linspace(0,np.pi,44)
dx = x[1]-x[0]
In [28]:
w = np.ones_like(x)
w[0] = 0.5
w[-1] = 0.5
np.sum(w*dx*np.sin(x))
Out[28]:
In [20]:
Out[20]:
In [ ]: