Skip to content

added support for 'searchsorted'#414

Merged
mfoerste4 merged 14 commits intonv-legate:branch-22.07from
mfoerste4:searchsorted
Jul 8, 2022
Merged

added support for 'searchsorted'#414
mfoerste4 merged 14 commits intonv-legate:branch-22.07from
mfoerste4:searchsorted

Conversation

@mfoerste4
Copy link
Contributor

@mfoerste4 mfoerste4 commented Jun 20, 2022

CPU/OMP & GPU support for searchsorted

The (local) GPU implementation is kept simple for now, using a single thread for every value to-be-inserted performing binary search. AFAIU this is how cupy does it. It might make sense to do something more sophisticated here.

@mfoerste4 mfoerste4 requested a review from magnatelee June 20, 2022 16:35
Multiple GPUs, Multiple CPUs
"""

v = convert_to_cunumeric_ndarray(v)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason that you don't use add_boilerplate?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, this statement changes the type of v, which makes the typing harder. if you want to keep this statement, I suggest you change the variable name on the LHS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used this statement in order to guarantee to pass the argument as a ndarray further - even for scalar inputs. I have changed the lhs variable name and added a comment to clarify.


def check_dtypes():
np.random.seed(42)
check_api(generate_random((156,), np.uint8))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using pytest decorators instead of enumerating test calls like this. e.g., https://github.com/nv-legate/cunumeric/blob/branch-22.07/tests/integration/test_matmul.py#L28-L29



def compare_assert(a_np, a_num):
if not num.allclose(a_np, a_num):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a nitpick: can't this be array_equal? I think searchsorted shouldn't ever do anything that could cause rounding errors

{
auto input = input_array.read_accessor<VAL, 1>(rect_base);
auto input_v = input_values.read_accessor<VAL, 1>(rect_values);
assert(input.accessor.is_dense_arbitrary(rect_base));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please request an exact instance for the input to make this assertion hold all the time

@magnatelee
Copy link
Contributor

@mfoerste4 doing a full search in every iteration seems pretty bad for memory bandwidth. do you know of any optimized algorithms that search for multiple values simultaneously? at minimum we could sort the search values to improve the access locality.

@mfoerste4 mfoerste4 requested a review from ipdemes July 1, 2022 10:59
@mfoerste4
Copy link
Contributor Author

@mfoerste4 doing a full search in every iteration seems pretty bad for memory bandwidth. do you know of any optimized algorithms that search for multiple values simultaneously? at minimum we could sort the search values to improve the access locality.

I will bring this question up in the next tech-meeting.

@ipdemes , could you do a second pass review?

@ipdemes
Copy link
Contributor

ipdemes commented Jul 5, 2022

@mfoerste4 there are some corner cases I think we would like to test explicitly. (I think you do test them by generating inputs randomly, but, maybe, we would like to force these tests ):
1)some entries of V are not in the array a.
2)some entries of V are the same
3) v is empty
4) a is empty

Some more tests that I believe are not tested:
5) v is a ND array
6) a and v have different types

@ipdemes
Copy link
Contributor

ipdemes commented Jul 5, 2022

another comment for the test:
Please make sure you test this method for up to LEGATE_MAX_DIM array dimension. Please see an example here:
https://github.com/nv-legate/cunumeric/blob/branch-22.07/tests/integration/test_diag_indices.py#L30_L37


Availability
--------
Multiple GPUs, Multiple CPUs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not required in the docstring of the cunuemeric/array,py file, only at the cunumeric/module.py file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have seen it in some places in array.py as well (some of them are from myself though). Should I remove it? Just Availability or the whole doc?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bryevdv : you have done the most recent changes in the way documentation/comparison table is built. Do we need to have Availability section in array.py? Or having it in module.py is enough?

@mfoerste4
Copy link
Contributor Author

@ipdemes , I think I have addressed all of your suggestions. Please have another look. Thanks.

@mfoerste4 mfoerste4 merged commit 8745b04 into nv-legate:branch-22.07 Jul 8, 2022
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.

3 participants