-
Notifications
You must be signed in to change notification settings - Fork 10
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
non-contiguous Impl::irecv
#32
Closed
Closed
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
3624a5a
KokkosComm::irecv
cwpearson d45bf65
docs: update KokkosComm::Req
cwpearson 5eddb34
add Invokable concept
cwpearson 6815a0c
Req: use Invokable
cwpearson 1c5859f
unit_tests: enable IsendIrecv mdspan tests
cwpearson 63bcfe0
rename Req members
cwpearson 95641b1
revert drop_at_wait back to keep_until_wait
cwpearson 64b20d5
formatting
cwpearson eb5a88e
Use default virtual dtor
cwpearson c237d59
Don't require void return type on Invokable
cwpearson e1ce0b5
Keep irecv view alive until wait
cwpearson 2730595
Formatting docs/design.rst
cwpearson 5e09b95
Formatting docs/design.rst
cwpearson 3849c9a
Formatting docs/design.rst
cwpearson 3037006
Irecv: fix include ordering
cwpearson 536711b
irecv: remove mdspan
cwpearson 6898850
irecv: remove mdspan tests
cwpearson 1766ae5
irecv: test utility to make different kinds of views
cwpearson f75daab
view_builder.hpp: formatting
cwpearson b427737
irecv: add 2d view tests
cwpearson 123d36a
design.rst: fix bullet list formatting
cwpearson b9a1b63
core.rst: fix MPI ops table
cwpearson 4b76cfa
test_isendirecv: factor out common code
cwpearson c79e931
design.rst: drop mdspan-related reference
cwpearson 1a1d649
Restrict KokkosComm::Req interface through pimpl
cwpearson 2348031
newlines
cwpearson 61bbc24
core.rst: remove non-existent Req members
cwpearson b73339c
improve comments on Impl::Req
cwpearson 8090c57
Clarify async / fencing behavior of isend
cwpearson 2fbfc59
space fencing in requests
cwpearson dcb918e
irecv: update wait semantics
cwpearson 442458d
irecv: clang-format-14
cwpearson 7f47397
irecv: fix some goofed types
cwpearson 7a404e2
irecv: docs
cwpearson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
//@HEADER | ||
// ************************************************************************ | ||
// | ||
// Kokkos v. 4.0 | ||
// Copyright (2022) National Technology & Engineering | ||
// Solutions of Sandia, LLC (NTESS). | ||
// | ||
// Under the terms of Contract DE-NA0003525 with NTESS, | ||
// the U.S. Government retains certain rights in this software. | ||
// | ||
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://kokkos.org/LICENSE for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//@HEADER | ||
|
||
#pragma once | ||
|
||
#include <memory> | ||
|
||
#include <Kokkos_Core.hpp> | ||
|
||
#include "KokkosComm_pack_traits.hpp" | ||
#include "KokkosComm_traits.hpp" | ||
|
||
// impl | ||
#include "KokkosComm_include_mpi.hpp" | ||
|
||
namespace KokkosComm::Impl { | ||
|
||
template <KokkosExecutionSpace ExecSpace, KokkosView RecvView, typename MpiArgs> | ||
struct IrecvUnpacker { | ||
IrecvUnpacker(const ExecSpace &space, RecvView &rv, MpiArgs &args) : space_(space), rv_(rv), args_(args) {} | ||
|
||
void operator()() { | ||
Kokkos::Tools::pushRegion("KokkosComm::Impl::IrecvUnpacker::operator()"); | ||
MpiArgs::packer_type::unpack_into(space_, rv_, args_.view); | ||
Kokkos::Tools::popRegion(); | ||
} | ||
|
||
ExecSpace space_; | ||
RecvView rv_; | ||
MpiArgs args_; | ||
}; | ||
|
||
template <KokkosExecutionSpace ExecSpace, KokkosView RecvView> | ||
std::shared_ptr<Req> irecv(const ExecSpace &space, RecvView &rv, int src, int tag, MPI_Comm comm) { | ||
Kokkos::Tools::pushRegion("KokkosComm::Impl::irecv"); | ||
|
||
using KCT = KokkosComm::Traits<RecvView>; | ||
using KCPT = KokkosComm::PackTraits<RecvView>; | ||
|
||
auto req = std::make_shared<Req>(); | ||
|
||
if (KCPT::needs_unpack(rv)) { | ||
using Packer = typename KCPT::packer_type; | ||
using Args = typename Packer::args_type; | ||
|
||
Args args = Packer::allocate_packed_for(space, "packed", rv); | ||
space.fence(); // make sure allocation is done | ||
MPI_Irecv(KCT::data_handle(args.view), args.count, args.datatype, src, tag, comm, &req->mpi_req()); | ||
req->call_and_drop_at_wait(IrecvUnpacker{space, rv, args}); | ||
// req.wait() promises that communication is done before any future work put into space after wait can proceed. | ||
// For MPI, wait uses MPI_Wait to make sure the communication is done, which blocks the host, thereby preventing | ||
// later work from being submitted to space, so no space fence is needed at wait. | ||
} else { | ||
using RecvScalar = typename RecvView::value_type; | ||
MPI_Irecv(KCT::data_handle(rv), KCT::span(rv), mpi_type_v<RecvScalar>, src, tag, comm, &req->mpi_req()); | ||
req->keep_until_wait(rv); | ||
} | ||
return req; | ||
|
||
Kokkos::Tools::popRegion(); | ||
} | ||
} // namespace KokkosComm::Impl |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
|
||
#pragma once | ||
|
||
#include <iostream> | ||
#include <memory> | ||
|
||
#include <Kokkos_Core.hpp> | ||
|
||
|
@@ -35,7 +35,7 @@ template <CommMode SendMode = CommMode::Default, KokkosExecutionSpace ExecSpace, | |
KokkosComm::Req isend(const ExecSpace &space, const SendView &sv, int dest, int tag, MPI_Comm comm) { | ||
Kokkos::Tools::pushRegion("KokkosComm::Impl::isend"); | ||
|
||
KokkosComm::Req req; | ||
auto req = std::make_shared<Req>(); | ||
|
||
using KCT = KokkosComm::Traits<SendView>; | ||
using KCPT = KokkosComm::PackTraits<SendView>; | ||
|
@@ -63,13 +63,13 @@ KokkosComm::Req isend(const ExecSpace &space, const SendView &sv, int dest, int | |
|
||
MpiArgs args = Packer::pack(space, sv); | ||
space.fence(); | ||
mpi_isend_fn(KCT::data_handle(args.view), args.count, args.datatype, dest, tag, comm, &req.mpi_req()); | ||
req.keep_until_wait(args.view); | ||
mpi_isend_fn(KCT::data_handle(args.view), args.count, args.datatype, dest, tag, comm, &req->mpi_req()); | ||
req->keep_until_wait(args.view); | ||
} else { | ||
using SendScalar = typename SendView::value_type; | ||
mpi_isend_fn(KCT::data_handle(sv), KCT::span(sv), mpi_type_v<SendScalar>, dest, tag, comm, &req.mpi_req()); | ||
mpi_isend_fn(KCT::data_handle(sv), KCT::span(sv), mpi_type_v<SendScalar>, dest, tag, comm, &req->mpi_req()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Somewhat out of scope, but: there needs to be a fence before the send to make sure all computation on the execution space has completed. |
||
if (KCT::is_reference_counted()) { | ||
req.keep_until_wait(sv); | ||
req->keep_until_wait(sv); | ||
} | ||
} | ||
|
||
|
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
Oops, something went wrong.
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.
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.
Maybe
use allocate_packed_for
also in theisend
andsend
implementation