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

Fix for Kokkos::vector::insert into empty vector with begin and end iterators #4988

Merged
merged 1 commit into from
Apr 28, 2022

Conversation

nliber
Copy link
Contributor

@nliber nliber commented Apr 28, 2022

This is primarily a fix for issue #4975.

In vector::insert(iterator, InputIterator, InputIterator):
Changed the out of range check on it to use std::less, as one
cannot portably perform ordered pointer comparisons on pointers
that aren't pointing inside the same array (to a first approximation).

Removed the special case when inserting into an empty vector,
as it was incorrect (see issue #4975) and has no real performance
gain (unlike this special case in insert(it, count, val)).

Removed the special case when inserting zero elements, as there
is no need to hand optimize for this rare case, as it falls out
of the general algorithm anyway.

In vector::insert(it, count, val):

Changed the out of range check to use std::less

In TestVector.hpp:
Added tests for the above

Changed the out of range check on it to use std::less, as one
cannot portably perform ordered pointer comparisons on pointers
that aren't pointing inside the same array (to a first approximation).

Removed the special case when inserting into an empty vector,
as it was incorrect (see issue kokkos#4975) and has no real performance
gain (unlike this special case in insert(it, count, val)).

Removed the special case when inserting zero elements, as there
is no need to hand optimize for this rare case, as it falls out
of the general algorithm anyway.

In vector::insert(it, count, val):

Changed the out of range check to use std::less

In TestVector.hpp:
Added tests for the above
@nliber nliber changed the title WIP Fix for Kokkos::vector::insert into empty vector with begin and end iterators Fix for Kokkos::vector::insert into empty vector with begin and end iterators Apr 28, 2022
@crtrott
Copy link
Member

crtrott commented Apr 28, 2022

Retest this please

@crtrott crtrott merged commit f09bd7d into kokkos:develop Apr 28, 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.

None yet

3 participants