{ "info": { "author": "Christoph Boeddeker", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Build Tools" ], "description": "# dlp_mpi - Data-level parallelism with mpi for python\n\n
| \nRun an serial algorithm on multiple examples\n | \n\nUse dlp_mpi to run the loop body in parallel\n | \n\nUse dlp_mpi to run a function in parallel\n | \n
|---|---|---|
| \n\n```python\n# python script.py\n\nimport time\n\n\nexamples = list(range(10))\nresults = []\n\n\n\n\n\n\n\nfor example in examples:\n\n # Some heavy workload:\n # CPU or IO\n time.sleep(0.2)\n result = example\n\n # Remember the results\n results.append(result)\n\n\n\n\n\n\n\n\n\n\n# Summarize your experiment\nprint(sum(results))\n```\n | \n\n\n```python\n# mpiexec -np 8 python script.py\n\nimport time\nimport dlp_mpi\n\nexamples = list(range(10))\nresults = []\n\n\n\n\n\n\n\nfor example in dlp_mpi.split_managed(\n examples):\n # Some heavy workload:\n # CPU or IO\n time.sleep(0.2)\n result = example\n\n # Remember the results\n results.append(result)\n\nresults = dlp_mpi.gather(results)\n\nif dlp_mpi.IS_MASTER:\n results = [\n result\n for worker_results in results\n for result in worker_results\n ]\n\n # Summarize your experiment\n print(results)\n```\n | \n\n\n```python\n# mpiexec -np 8 python script.py\n\nimport time\nimport dlp_mpi\n\nexamples = list(range(10))\nresults = []\n\ndef work_load(example):\n # Some heavy workload:\n # CPU or IO\n time.sleep(0.2)\n result = example\n\nfor result in dlp_mpi.map_unordered(\n work_load, examples):\n\n\n\n\n\n # Remember the results\n results.append(result)\n\n\n\n\n\n\n\n\n\nif dlp_mpi.IS_MASTER:\n # Summarize your experiment\n print(results)\n```\n | \n