Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiprocessing: from pool.apply to pool.imap_unordered #5

Open
apasto opened this issue Oct 5, 2024 · 0 comments
Open

multiprocessing: from pool.apply to pool.imap_unordered #5

apasto opened this issue Oct 5, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@apasto
Copy link
Owner

apasto commented Oct 5, 2024

Here we do need the synchronous calls and ordered execution of pool.apply (pool is an instance of multiprocessing.Pool).
The reason why I used it was mainly out of habit, and ease of providing the arguments (same for all elements) in kwds:

pool = mp.Pool(n_processes)
for element in valid_elements_idx:
(
out["c0"]["c0"][element[0], element[1]],
out["c1"]["c1"][element[0], element[1]],
out["rv"]["rv"][element[0], element[1]],
out["pv"]["pv"][element[0], element[1]],
out["ie"]["ie"][element[0], element[1]],
out["se"]["se"][element[0], element[1]],
out["np"]["np"][element[0], element[1]]) = pool.apply(
rolling_linregress,
kwds={
'a': A.to_numpy(), 'b': B.to_numpy(), 'e_i': element,
'hw_x_i': window_halfwidth_x_i,
'hw_y_i': window_halfwidth_y_i})

Let's try to migrate to pool.imap_unordered and see how it turns out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant