This repository has been archived by the owner on Feb 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
WIP: interface for map-reduce style kernels #284
Open
Hardcode84
wants to merge
11
commits into
IntelPython:master
Choose a base branch
from
Hardcode84:dist_refac
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Hello @Hardcode84! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2019-11-12 11:16:09 UTC |
shssf
reviewed
Nov 12, 2019
a = len(l) // n | ||
b = a + 1 | ||
c = len(l) % n | ||
return [l[i * b: i * b + b] if i < c else l[c * b + (i - c) * a: c * b + (i - c) * a + a] for i in range(n)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is quite understandable code, isn't it? :-)
please don't call variables by single letter
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds new APIs to be used by pandas functions implementers to help parallelize theirs kernels:
map_reduce(arg, init_val, map_func, reduce_func)
map_reduce_chunked(arg, init_val, map_func, reduce_func)
Parameters:
arg
- list-like object (it can be python list, numpy array or any other object with similar interface)init_val
- initial valuemap_func
- map function which will be applied to each element/elements range in parallel (on different processes of on different nodes)reduce_func
- reduction function to combine initial value and results from different processes/nodesThe difference between these two functions:
map_reduce
will apply map function to each element in range (map function must take single element and return single element) and then apply reduce function pairwise (reduce function must take two elements and return single element)map_reduce_chunked
will apply map function to range of elements, belonging to current thread/node (map function must take range of elements as paramenter and return list/array as result) and then apply reduce to entire ranges (reduce function must take two ranges as parameters and return list/array)You can also call any of these functions from inside map or reduce func to support nested parallelism.
These functions usable for both thread/mpi parallelism.
If you call them from numba
@njit
function they will be parallelized by numba buiilt-in parallelisation machinery.If you call them from
@hpat.jit
they will be distributed by hpat parallelisation pass (doesn't work currently)Wrote parallel series sorting (numpy.sort + hand-written merge) as example.
Current issues:
numpy.sort
, need to fixmap_reduce_chunked
handcode as 4, will fixThe second part of this PR is distribution depth knob to (not-so)fine-tune nested parallelism between distribution and threading:
SDC_DISTRIBUTION_DEPTH
controls how much nested parallel loops will be distributed by DistributionPassmap_reduce*
functions or manually writtenprange
loops.1
which means that only the most outer loop will be distributed by mpi, then next loop will parallelised by numba, and then all deeper loops will be executed sequentually (as numba doesn't support nested parallelisation)SDC_DISTRIBUTION_DEPTH
to0
to disable distribution.