-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial attempt at comm/space wrapping and noncontig views
- Loading branch information
Showing
14 changed files
with
287 additions
and
37 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//@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 "mpi/KokkosComm_mpi.hpp" | ||
#include "KokkosComm_concepts.hpp" | ||
|
||
namespace KokkosComm { | ||
|
||
using GenericTransport = ::KokkosComm::Mpi; | ||
using SpecialTransport = ::KokkosComm::Mpi; | ||
template <KokkosExecutionSpace ExecSpace> | ||
using Handle = Mpi::Handle<ExecSpace>; | ||
|
||
} // namespace KokkosComm |
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,26 @@ | ||
//@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 | ||
|
||
namespace KokkosComm { | ||
|
||
template <KokkosExecutionSpace ExecSpace, typename CommFunc> | ||
Mpi::Handle<ExecSpace> plan(const ExecSpace &space, MPI_Comm comm, CommFunc f) { | ||
return Mpi::Plan<ExecSpace, CommFunc>(space, comm, f).handle(); | ||
} | ||
|
||
} // namespace KokkosComm |
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,56 @@ | ||
//@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 "KokkosComm_api.hpp" | ||
#include "KokkosComm_concepts.hpp" | ||
#include "KokkosComm_config.hpp" | ||
#include "KokkosComm_plan.hpp" | ||
|
||
namespace KokkosComm { | ||
|
||
template <typename Handle, KokkosView RecvView> | ||
void irecv(Handle &h, RecvView &rv, int src, int tag) { | ||
if constexpr (Impl::api_avail_v<SpecialTransport, Impl::Api::Irecv>) { | ||
SpecialTransport::irecv(h, rv, src, tag); | ||
} else { | ||
GenericTransport::irecv(h, rv, src, tag); | ||
} | ||
} | ||
|
||
template <KokkosExecutionSpace ExecSpace, KokkosView RecvView> | ||
KokkosComm::Handle<ExecSpace> irecv(const ExecSpace &space, const RecvView &rv, int dest, int tag, MPI_Comm comm) { | ||
using MyHandle = KokkosComm::Handle<ExecSpace>; | ||
return KokkosComm::plan(space, comm, [=](MyHandle &handle) { KokkosComm::irecv(handle, rv, dest, tag); }); | ||
} | ||
|
||
template <typename Handle, KokkosView SendView> | ||
void isend(Handle &h, SendView &sv, int src, int tag) { | ||
if constexpr (Impl::api_avail_v<SpecialTransport, Impl::Api::Isend>) { | ||
SpecialTransport::isend(h, sv, src, tag); | ||
} else { | ||
GenericTransport::isend(h, sv, src, tag); | ||
} | ||
} | ||
|
||
template <KokkosExecutionSpace ExecSpace, KokkosView SendView> | ||
KokkosComm::Handle<ExecSpace> isend(const ExecSpace &space, const SendView &sv, int dest, int tag, MPI_Comm comm) { | ||
using MyHandle = KokkosComm::Handle<ExecSpace>; | ||
return KokkosComm::plan(space, comm, [=](MyHandle &handle) { KokkosComm::isend(handle, sv, dest, tag); }); | ||
} | ||
|
||
} // namespace KokkosComm |
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,30 @@ | ||
//@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 | ||
|
||
namespace KokkosComm::Impl { | ||
|
||
enum class Api { Irecv, Isend }; | ||
|
||
// catch-all: no transports implement any APIs | ||
template <typename Transport, Impl::Api API> | ||
struct api_avail : public std::false_type {}; | ||
|
||
template <typename Transport, Impl::Api API> | ||
constexpr bool api_avail_v = api_avail<Transport, API>::value; | ||
|
||
} // 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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
//@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 <string> | ||
|
||
#include <Kokkos_Core.hpp> | ||
|
||
#include "KokkosComm_concepts.hpp" | ||
|
||
namespace KokkosComm::Impl { | ||
|
||
template <KokkosView View> | ||
struct contiguous_view { | ||
using type = Kokkos::View<typename View::non_const_data_type, Kokkos::LayoutRight, typename View::memory_space>; | ||
}; | ||
|
||
template <KokkosView View> | ||
using contiguous_view_t = contiguous_view<View>::type; | ||
|
||
template <KokkosView View, KokkosExecutionSpace Space> | ||
auto allocate_contiguous_for(const Space &space, const std::string &label, View &v) { | ||
using non_const_packed_view_type = contiguous_view_t<View>; | ||
|
||
if constexpr (KokkosComm::rank<View>() == 1) { | ||
return non_const_packed_view_type(Kokkos::view_alloc(space, Kokkos::WithoutInitializing, label), v.extent(0)); | ||
} else if constexpr (KokkosComm::rank<View>() == 2) { | ||
return non_const_packed_view_type(Kokkos::view_alloc(space, Kokkos::WithoutInitializing, label), v.extent(0), | ||
v.extent(1)); | ||
} else { | ||
static_assert(std::is_void_v<View>, "allocate_contiguous_for for views > rank 2 not implemented"); | ||
} | ||
} | ||
|
||
template <KokkosExecutionSpace Space, KokkosView DstView, KokkosView SrcView> | ||
auto resize_contiguous_for(const Space &space, DstView &out, const SrcView &in) { | ||
static_assert(DstView::rank == SrcView::rank, ""); | ||
|
||
if constexpr (KokkosComm::rank<DstView>() == 1) { | ||
Kokkos::realloc(Kokkos::view_alloc(space, Kokkos::WithoutInitializing), out, in.extent(0)); | ||
} else if constexpr (KokkosComm::rank<DstView>() == 2) { | ||
Kokkos::realloc(Kokkos::view_alloc(space, Kokkos::WithoutInitializing), out, in.extent(0), in.extent(1)); | ||
} else { | ||
static_assert(std::is_void_v<DstView>, "realloc_contiguous_for for views > rank 2 not implemented"); | ||
} | ||
} | ||
|
||
} // namespace KokkosComm::Impl |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.