-
Notifications
You must be signed in to change notification settings - Fork 41
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
Use Kokkos::view_alloc with Kokkos::resize/realloc and Kokkos::create_mirror* for Kokkos 3.7 #749
Conversation
I really dislike how |
3777eb5
to
9a7012e
Compare
Retest this please. |
c225a67
to
b1e4d99
Compare
src/ArborX_DistributedTree.hpp
Outdated
#else | ||
#if KOKKOS_VERSION >= 30700 | ||
auto boxes_host = | ||
Kokkos::create_mirror_view(Kokkos::view_alloc(space), boxes); | ||
#else |
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.
Does this need a space.fence()
? I think not, but I'm not entirely confident
3ea26a3
to
0d37d8b
Compare
Retest this please. |
9399934
to
202541c
Compare
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.
I would slightly prefer if we waited for our requiring Kokkos 3.7
static_assert(Kokkos::is_execution_space<ExecutionSpace>::value); | ||
static_assert(Kokkos::is_memory_space<MemorySpace>::value); |
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.
Both have an _v version (not requesting you to change)
0908795
to
fe99cbc
Compare
I'm happy to rebase this on top of #833 and #834 but I still think that we should also address |
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.
Partial review
scripts/check_format_cpp.sh
Outdated
if [ "${clang_format_major_version}" -ne 14 ] || [ "${clang_format_minor_version}" -ne 0 ] || [ "${clang_format_patch_version}" -ne 0 ]; then | ||
echo "*** ArborX requires clang-format version 14.0.0," | ||
echo "*** but version ${clang_format_major_version}.${clang_format_minor_version}.${clang_format_patch_version} was found instead." | ||
exit 1 | ||
fi |
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.
Why remove this?
@@ -236,7 +236,7 @@ void queryImpl(ExecutionSpace const &space, Tree const &tree, | |||
// Exit early if either no results were found for any of the queries, or | |||
// nothing was inserted inside a callback for found results. This check | |||
// guarantees that the second pass will not be executed. | |||
Kokkos::resize(out, 0); | |||
Kokkos::resize(Kokkos::view_alloc(space), out, 0); |
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.
Do we need the space if we resize to 0?
auto tmp_view = | ||
Kokkos::create_mirror_view_and_copy(space, imports_layout_right); | ||
auto tmp_view = Kokkos::create_mirror_view_and_copy( | ||
Kokkos::view_alloc(space, typename ExecutionSpace::memory_space{}), |
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.
Does it need WithoutInitializing
, or is that done by default?
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.
That's done by default.
src/ArborX_DistributedTree.hpp
Outdated
@@ -184,7 +188,9 @@ DistributedTree<MemorySpace, Enable>::DistributedTree( | |||
"ArborX::DistributedTree::" | |||
"leave_count_in_local_trees"), | |||
comm_size); | |||
auto bottom_tree_sizes_host = Kokkos::create_mirror_view(_bottom_tree_sizes); | |||
auto bottom_tree_sizes_host = Kokkos::create_mirror_view( | |||
Kokkos::view_alloc(host_exec), _bottom_tree_sizes); |
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.
WithoutInitializing
?
src/ArborX_DistributedTree.hpp
Outdated
@@ -163,7 +165,9 @@ DistributedTree<MemorySpace, Enable>::DistributedTree( | |||
static_cast<void *>(boxes.data()), sizeof(Box), MPI_BYTE, | |||
getComm()); | |||
#else | |||
auto boxes_host = Kokkos::create_mirror_view(boxes); | |||
auto boxes_host = | |||
Kokkos::create_mirror_view(Kokkos::view_alloc(host_exec), boxes); |
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.
WithoutInitializing
@@ -103,11 +103,16 @@ determineBufferLayout(ExecutionSpace const &space, InputView batched_ranks, | |||
auto restricted_unique_ranks = InputView( | |||
compact_ranks, std::make_pair(0, static_cast<int>(n_unique_ranks))); | |||
|
|||
auto const unique_ranks_host = Kokkos::create_mirror_view_and_copy( |
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.
Is there a version of create_mirror_view_and_copy
that does that without intialization? It seems a bit weird to split this function into create_mirror_view
and deep_copy
just so that it does not initialize.
auto device_permutation_indices = | ||
Kokkos::create_mirror_view(DeviceType(), permutation_indices); | ||
auto device_permutation_indices = Kokkos::create_mirror_view( | ||
Kokkos::view_alloc(space, typename DeviceType::memory_space{}), |
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.
I think this can be WithoutInitializing
.
@@ -299,13 +305,13 @@ class Distributor | |||
|
|||
dest_buffer_mirror = | |||
ArborX::Details::create_layout_right_mirror_view_and_copy( | |||
typename ImportView::memory_space(), dest_buffer); | |||
space, typename ImportView::memory_space(), dest_buffer); |
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.
Should not initialize, check.
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.
create_layout_right_mirror_view_and_copy
doesn't initialize anyway.
I think there are too many changes in this single PR, and would prefer to split it. |
I'm still waiting for #833. |
Yes, I was pretty much good with it and would just suggest #833 (comment) to be addressed. After that, I would incorporate the changes here, possibly also addressing #833 (comment). |
Retest this please. |
7c622ff
to
9040597
Compare
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.
Partial review. I haven't looked at the distributed changes yet, or at the changes to add a memory space to creating right layout views. I have to understand why those are necessary.
@@ -26,11 +26,11 @@ stages: | |||
tags: | |||
- nobatch | |||
|
|||
.BuildKokkos: | |||
BuildKokkos: |
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.
I think it's fine to leave it open, so that it rebuilds every time.
num_components = | ||
static_cast<int>(n) - | ||
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, num_edges)(); |
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.
Was this a bug?
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.
Not really in the sense you get the right answer. The change here are about using the execution space provided to transfer to the host instead of the default one.
Kokkos::realloc(Kokkos::view_alloc(space, Kokkos::WithoutInitializing), v, n0, | ||
n1, n2, n3, n4, n5, n6, n7); |
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.
Should we get rid of reallocWithoutInitializing
completely? It's an empty function.
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.
Yes, I avoided doing that so far thinking that someone would care about the shorter name.
Kokkos::realloc(Kokkos::view_alloc(space, Kokkos::WithoutInitializing), v, | ||
layout); |
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.
Likewise, should we get rid of this function?
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.
Yes, I avoided doing that so far thinking that someone would care about the shorter name.
return Kokkos::create_mirror(Kokkos::view_alloc(typename View::memory_space{}, | ||
space, |
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.
This seems to do something different from what it used to. In the previous iteration, the memory space was taken from the execution space, now it is taken from the view. Not saying it's wrong, just a change.
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.
Yes, that's fair. To me, the function reads "copy the View with all its properties" using the execution space given. If we take the memory space from the execution space, the memory space might change (especially for Views in shared memory spaces).
cloneWithoutInitializingNorCopying(ExecutionSpace const &space, View const &v, | ||
std::string const &label) |
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.
Why was the label version removed? Was it not used?
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 was not used and Kokkos::create_mirror
doesn't allow passing a new label.
Kokkos::resize(Kokkos::view_alloc(exec_space, Kokkos::WithoutInitializing), | ||
offsets, num_offsets); |
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.
This seems like a bug. We want to resize the offsets
array, but keep its values. Or does it do that?
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 avoids initializing the new elements.
Retest this please. |
Fixes #641. Only files in
src
are changed.