Skip to content

Instantly share code, notes, and snippets.

@leslie-fang-intel
Created July 4, 2025 05:20
Show Gist options
  • Save leslie-fang-intel/29f100e610b9ae5d58a5d6f4ee8f83dc to your computer and use it in GitHub Desktop.
Save leslie-fang-intel/29f100e610b9ae5d58a5d6f4ee8f83dc to your computer and use it in GitHub Desktop.
# Run with: clear && mpiexec -n 2 python test_mpi4.py
from mpi4py.futures import MPIPoolExecutor
def work(x):
print(f"Working on: {x}")
return x * x
if __name__ == "__main__":
with MPIPoolExecutor() as executor:
future = executor.submit(work, 5)
print("Result:", future.result())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment