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

Allow passing a temporary std::vector to partition_space #6167

Merged

Conversation

masterleinad
Copy link
Contributor

Related to https://kokkosteam.slack.com/archives/C5BGU5NDQ/p1685215235868969. There doesn't seem to be a good reason not to allow passing a temporary std::vector to partition_space.
Also, this overload is not mentioned at https://kokkos.github.io/kokkos-core-wiki/API/core/spaces/partition_space.html?highlight=partition_space#_CPPv4I0DpE15partition_spaceNSt6vectorI9ExecSpaceEERK9ExecSpaceDp4Args.

@masterleinad masterleinad marked this pull request as ready for review May 31, 2023 14:27
Copy link
Contributor

@fnrizzi fnrizzi left a comment

Choose a reason for hiding this comment

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

just left a couple comments i noticed when reviewing

core/src/HIP/Kokkos_HIP_Instance.hpp Show resolved Hide resolved
auto instances =
Kokkos::Experimental::partition_space(TEST_EXECSPACE(), weights);
auto instances = Kokkos::Experimental::partition_space(
TEST_EXECSPACE(), std::vector<int> /*weights*/ {1, 1});
Copy link
Member

Choose a reason for hiding this comment

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

It does not make it obvious to the reader that you mean to call with a temporary.
Consider doing

static_assert(
  std::is_invocablle_v<
    decltype(Kokkos::Experimental::partition_space<int>),
    std::vector<int>&&>,
  "intended to be callable with temporary"
);

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 would need overload resolution for Kokkos::Experimental::partition_space<ExecSpace, int>) since both overloads are eligible. That means that I would need to simulate the call before testing that the function is callable with the arguments I need to provide for overload resolution which seems to defeat the purpose.

I just added a comment making the intent clear.

@dalg24
Copy link
Member

dalg24 commented May 31, 2023

Please check on the original PR if taking a non-const reference was a design choice.

@masterleinad
Copy link
Contributor Author

Please check on the original PR if taking a non-const reference was a design choice.

#4096 (comment) asked that question but there was no answer.

@dalg24 dalg24 merged commit 0b7bed5 into kokkos:develop Jun 2, 2023
@masterleinad masterleinad mentioned this pull request Jun 7, 2023
nliber pushed a commit to nliber/kokkos that referenced this pull request Jun 22, 2023
* Allow passing a temporary std::vector to partition_space

* Comment on ignoring content of weights

* Add comment that we test that we can use temporaries for weights
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.

4 participants