Skip to content

Conversation

@jan-janssen
Copy link
Member

@jan-janssen jan-janssen commented Apr 17, 2024

This pull request introduces a new class of interfaces PyFluxStepExecutor, PyMPIStepExecutor and PySlurmStepExecutor. Each of these allow to submit a function by specifying the resource requirements on the function rather than on the executor.

Example:

import numpy as np
from pympipool.mpi import PyMPIStepExecutor

def calc(i, j, k):
    from mpi4py import MPI
    size = MPI.COMM_WORLD.Get_size()
    rank = MPI.COMM_WORLD.Get_rank()
    return np.array([i, j, k]), size, rank

with PyMPIStepExecutor(max_cores=2) as p:
    fs = p.submit(calc, 2, j=4, k=3, resource_dict={"cores": 2})
    print(fs.result())

Output:

>>> [(array([2, 4, 3]), 2, 0), (array([2, 4, 3]), 2, 1)]

@jan-janssen jan-janssen marked this pull request as draft April 17, 2024 01:58
@jan-janssen jan-janssen linked an issue Apr 17, 2024 that may be closed by this pull request
@jan-janssen jan-janssen changed the title Add option to submit one function per executor Add option to specify resources during submit() call rather than on the executor level Apr 17, 2024
@mgt16-LANL
Copy link

I think there's a good chance this would work. When I have a chance I want to download and try. I think the thing that really stands out to me from my initial pass was the ability to do multi-core MPI "jobs" locally. That's SUPER useful for local dev.

@jan-janssen jan-janssen marked this pull request as ready for review April 18, 2024 22:03
@jan-janssen jan-janssen merged commit 58a0731 into main Apr 18, 2024
@jan-janssen jan-janssen deleted the tasksteps branch April 18, 2024 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] control "submit"-level resource distribution

3 participants