Replies: 2 comments 16 replies
-
Prima facie, I would say that PS: Not sure if this will be helpful to your use case, but look at my tip in #324 if your "jobs" have to be parallel. |
Beta Was this translation helpful? Give feedback.
-
I thought I could set a flag in a worker process asynchronously using one-sided communciation. Unfortunately, the following toy problem does not seem to confirm this. First, I initialize each buffer with zeros. Then, I set in import time
import numpy as np
from mpi4py import MPI
from mpi4py.util import dtlib
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
datatype = MPI.BOOL
np_dtype = dtlib.to_numpy_dtype(datatype)
itemsize = datatype.Get_size()
N = 3
win_size = N * itemsize
win = MPI.Win.Allocate(win_size, comm=comm)
# Fill buffer with 0s
buf = np.zeros(N, dtype=np_dtype)
buf.fill(0)
win.Lock(rank=rank)
win.Put(buf, target_rank=rank)
win.Unlock(rank=rank)
comm.Barrier()
if rank == 0:
true_value = np.ones(1, dtype=np_dtype)
for pos in [0, 2]:
win.Lock(rank=1, lock_type=MPI.LOCK_EXCLUSIVE)
win.Put(true_value, target_rank=1, target=(pos, 1, datatype))
win.Unlock(rank=1)
print(f'{rank} {size} End put {pos}', flush=True)
elif rank == 1:
time.sleep(1)
for _ in range(5):
win.Lock(rank=1, lock_type=MPI.LOCK_EXCLUSIVE)
win.Get(buf, target_rank=1)
win.Unlock(rank=1)
print(f'{rank} {size} {list(buf)}', flush=True) I would expect the output
but what I am getting is
It seems to me like |
Beta Was this translation helpful? Give feedback.
-
Hi,
I would like to use the futures interface to launch multiple jobs in parallel. Additionally, I would like to report intermediate values back to the master process which then can tell a job to stop prematurely, if the intermediate values are too bad (pruning with optuna).
Unfortunately, I am stuck on how best to establish the communication between the master and worker processes. Is there a way to get the intercommunicator of the MpiPoolExecutor or should I use
Open_port
,Introcomm.Accept
andIntracomm.Connect
.Afterwards, I would like to merge the intercommunicator with the master process to get an intracommunicator.
Can I do this with mpi4py or should I rather use another library?
Thanks a lot!
Best regards,
Dirk
Beta Was this translation helpful? Give feedback.
All reactions