-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add proof of concept for tasks with MPI capabilities (in the same namespace) * Tidy up a bit * Carfeul about (ab)using globals * Make script executable * Fix spelling error * Start incorporating the necessary code * Only import MPI if I need to * Add some error checking * Move some more functions to the module, improve errors * Add the wrapper script for dask_worker * Simplify * Prepare for wrapping mpi_dask_worker.py call * Add dask mpi launcher * Run black * Provide traceback when aborting * Enable switch for forking MPI programs * Run black on codebase * Add default MPI launcher to tests * Restore state in tests * Prepare for more tests * Correct warning string * Correct warning string * Correct warning string * Imports done incorrectly * Add an example to test MPI functionality * Add launcher to example * Use trivial queue * Fix typo * Only add additional kwargs if they are needed * No forking other processes when using MPI to launch dask * Add missing kwargs * Use simple queues in example * Move requirements in CI * Only do the dask worker import where it is needed * Debugging * Debugging * Serialize before submitting the task * Serialize before submitting the task * Serialize before submitting the task * Be more careful with args and kwargs * Get rid of a warning * Remove unnecessary print statements * Make sure we can run multiple tasks * Make sure we can run multiple tasks * Make sure we can run multiple tasks * Flush strings * REmove bad print command * See if nanny works * Only do import when we need to * Only do import when we need to * Revert last commit * Address comment * Tidy up before adding additional tests * Remove dask worker directories * Add initial set of new tests * Additional tests * Final additional tests * Make sure Py2 is also passing
- Loading branch information
ocaisa
committed
May 29, 2019
1 parent
71ba25a
commit 696f815
Showing
14 changed files
with
607 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from __future__ import print_function | ||
import os | ||
|
||
from dask.distributed import LocalCluster | ||
|
||
from jobqueue_features.clusters import CustomSLURMCluster | ||
from jobqueue_features.decorators import on_cluster, mpi_task | ||
from jobqueue_features.mpi_wrapper import mpi_wrap | ||
from jobqueue_features.functions import set_default_cluster | ||
|
||
# import logging | ||
# logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG) | ||
|
||
# set_default_cluster(LocalCluster) | ||
set_default_cluster(CustomSLURMCluster) | ||
|
||
custom_cluster = CustomSLURMCluster( | ||
name="mpiCluster", walltime="00:04:00", nodes=2, mpi_mode=True, fork_mpi=True | ||
) | ||
|
||
|
||
@on_cluster(cluster=custom_cluster, cluster_id="mpiCluster") | ||
@mpi_task(cluster_id="mpiCluster") | ||
def mpi_wrap_task(**kwargs): | ||
return mpi_wrap(**kwargs) | ||
|
||
|
||
# @on_cluster() # LocalCluster | ||
def main(): | ||
script_path = os.path.join(os.path.dirname(__file__), "resources", "helloworld.py") | ||
t = mpi_wrap_task(executable="python", exec_args=script_path) | ||
print(t.result()["out"]) | ||
print(t.result()["err"]) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Distribution of MPI enabled tasks | ||
""" | ||
|
||
from jobqueue_features.mpi_wrapper import ( | ||
mpi_deserialize_and_execute, | ||
serialize_function_and_args, | ||
shutdown_mpitask_worker, | ||
verify_mpi_communicator, | ||
) | ||
|
||
|
||
# Add the no-nanny option so we don't fork additional processes | ||
MPI_DASK_WRAPPER_MODULE = "jobqueue_features.cli.mpi_dask_worker --no-nanny" | ||
|
||
|
||
def prepare_for_mpi_tasks(root=0, comm=None): | ||
|
||
if comm is None: | ||
from mpi4py import MPI | ||
|
||
comm = MPI.COMM_WORLD | ||
verify_mpi_communicator(comm) | ||
|
||
rank = comm.Get_rank() | ||
|
||
if rank == root: | ||
# Start dask so root reports to scheduler and accepts tasks | ||
# Task distribution is part of task itself (via our wrapper) | ||
from distributed.cli import dask_worker | ||
|
||
dask_worker.go() | ||
|
||
# As a final task, send a shutdown to the other MPI ranks | ||
serialized_object = serialize_function_and_args(shutdown_mpitask_worker) | ||
mpi_deserialize_and_execute( | ||
serialized_object=serialized_object, root=root, comm=comm | ||
) | ||
else: | ||
while True: | ||
# Calling with no serialized_object means these are non-root processes | ||
mpi_deserialize_and_execute(root=root, comm=comm) | ||
|
||
|
||
if __name__ == "__main__": | ||
prepare_for_mpi_tasks() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.