-
Notifications
You must be signed in to change notification settings - Fork 0
Kokkos::create_mirror
Header File: Kokkos_Core.hpp
A common desired use case is to have a memory allocation in GPU memory and an identical memory allocation in CPU memory, such that copying from one to another is straightforward. To satisfy this use case and others, Kokkos has facilities for dealing with "mirrors" of View. A "mirror" of a View type A
is loosely defined a View type B
such that Views of type B
are accessible from the CPU and deep_copy
between Views of type A
and B
are direct. The most common functions for dealing with mirrors are create_mirror
, create_mirror_view
and create_mirror_view_and_copy
.
Usage:
auto host_mirror = create_mirror(a_view);
auto host_mirror_view = create_mirror_view(a_view);
auto host_mirror_space = create_mirror(ExecSpace(),a_view);
auto host_mirror_view_space = create_mirror_view(ExecSpace(),a_view);
template <class ViewType>
typename ViewType::HostMirror create_mirror(ViewType const&);
template <class ViewType>
typename ViewType::HostMirror create_mirror(decltype(Kokkos::ViewAllocateWithoutInitializing()),
ViewType const&);
template <class Space, class ViewType>
ImplMirrorType create_mirror(Space const& space, ViewType const&);
template <class Space, class ViewType>
ImplMirrorType create_mirror(decltype(Kokkos::ViewAllocateWithoutInitializing()),
Space const& space, ViewType const&);
template <class ViewType>
typename ViewType::HostMirror create_mirror_view(ViewType const&);
template <class ViewType>
typename ViewType::HostMirror create_mirror_view(decltype(Kokkos::ViewAllocateWithoutInitializing()),
ViewType const&);
template <class Space, class ViewType>
ImplMirrorType create_mirror_view(Space const& space, ViewType const&);
template <class Space, class ViewType>
ImplMirrorType create_mirror_view(decltype(Kokkos::ViewAllocateWithoutInitializing()),
Space const& space, ViewType const&);
template <class Space, class ViewType>
ImplMirrorType create_mirror_view_and_copy(Space const& space, ViewType const&);
-
template <class ViewType> typename ViewType::HostMirror create_mirror(ViewType const& src);
Creates a new host accessible
View
with the same layout and padding assrc
.-
src
: aKokkos::View
.
-
-
template <class ViewType> typename ViewType::HostMirror create_mirror(decltype(Kokkos::ViewAllocateWithoutInitializing()), ViewType const& src);
Creates a new host accessible
View
with the same layout and padding assrc
. The new view will have uninitialized data.-
src
: aKokkos::View
.
-
-
template <class Space, class ViewType> ImplMirrorType create_mirror(Space const& space, ViewType const&);
Creates a new
View
with the same layout and padding assrc
but with a device type ofSpace::device_type
.-
src
: aKokkos::View
. -
Space
: a class meeting the requirements ofExecutionSpaceConcept
orMemorySpaceConcept
-
ImplMirrorType
: an implementation defined specialization ofKokkos::View
.
-
-
template <class Space, class ViewType> ImplMirrorType create_mirror(decltype(Kokkos::ViewAllocateWithoutInitializing()), Space const& space, ViewType const&);
Creates a new
View
with the same layout and padding assrc
but with a device type ofSpace::device_type
. The new view will have uninitialized data.-
src
: aKokkos::View
. -
Space
: a class meeting the requirements ofExecutionSpaceConcept
orMemorySpaceConcept
-
ImplMirrorType
: an implementation defined specialization ofKokkos::View
.
-
-
template <class ViewType> typename ViewType::HostMirror create_mirror_view(ViewType const& src);
If
src
is not host accessible (i.e. ifSpaceAccessibility<HostSpace,ViewType::memory_space>::accessible
isfalse
) it creates a new host accessibleView
with the same layout and padding assrc
. Otherwise returnssrc
.-
src
: aKokkos::View
.
-
-
template <class ViewType> typename ViewType::HostMirror create_mirror_view(decltype(Kokkos::ViewAllocateWithoutInitializing()), ViewType const& src);
If
src
is not host accessible (i.e. ifSpaceAccessibility<HostSpace,ViewType::memory_space>::accessible
isfalse
) it creates a new host accessibleView
with the same layout and padding assrc
. The new view will have uninitialized data. Otherwise returnssrc
.-
src
: aKokkos::View
.
-
-
template <class Space, class ViewType> ImplMirrorType create_mirror_view(Space const& space, ViewType const&);
If
std::is_same<typename Space::memory_space, typename ViewType::memory_space>::value
isfalse
, creates a newView
with the same layout and padding assrc
but with a device type ofSpace::device_type
. Otherwise returnssrc
.-
src
: aKokkos::View
. -
Space
: a class meeting the requirements ofExecutionSpaceConcept
orMemorySpaceConcept
-
ImplMirrorType
: an implementation defined specialization ofKokkos::View
.
-
-
template <class Space, class ViewType> ImplMirrorType create_mirror_view(decltype(Kokkos::ViewAllocateWithoutInitializing()), Space const& space, ViewType const&);
If
std::is_same<typename Space::memory_space, typename ViewType::memory_space>::value
isfalse
, creates a newView
with the same layout and padding assrc
but with a device type ofSpace::device_type
. The new view will have uninitialized data. Otherwise returnssrc
.-
src
: aKokkos::View
. -
Space
: a class meeting the requirements ofExecutionSpaceConcept
orMemorySpaceConcept
-
ImplMirrorType
: an implementation defined specialization ofKokkos::View
.
-
-
template <class Space, class ViewType> ImplMirrorType create_mirror_view_and_copy(Space const& space, ViewType const&);
If
std::is_same<typename Space::memory_space, typename ViewType::memory_space>::value
isfalse
, creates a newKokkos::View
with the same layout and padding assrc
but with a device type ofSpace::device_type
and conducts adeep_copy
fromsrc
to the new view if one was created. Otherwise returnssrc
.-
src
: aKokkos::View
. -
Space
: a class meeting the requirements ofExecutionSpaceConcept
orMemorySpaceConcept
-
ImplMirrorType
: an implementation defined specialization ofKokkos::View
.
-
Home:
- Introduction
- Machine Model
- Programming Model
- Compiling
- Initialization
- View
- Parallel Dispatch
- Hierarchical Parallelism
- Custom Reductions
- Atomic Operations
- Subviews
- Interoperability
- Kokkos and Virtual Functions
- Initialization and Finalization
- View
- Data Parallelism
- Execution Policies
- Spaces
- Task Parallelism
- Utilities
- STL Compatibility
- Numerics
- Detection Idiom