Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Kokkos_TeuchosCommAdapters_UQ_PCE.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef KOKKOS_TEUCHOS_COMM_ADAPTERS_UQ_PCE_HPP
11 #define KOKKOS_TEUCHOS_COMM_ADAPTERS_UQ_PCE_HPP
12 
13 #include "Stokhos_ConfigDefs.h"
14 #if defined(HAVE_STOKHOS_TEUCHOSKOKKOSCOMM)
15 
16 #include "Sacado_UQ_PCE.hpp"
17 #include "Kokkos_View_UQ_PCE.hpp"
18 #include "Kokkos_TeuchosCommAdapters.hpp"
19 
20 //----------------------------------------------------------------------------
21 // Overloads of Teuchos Comm View functions for Sacado::UQ::PCE scalar type
22 //----------------------------------------------------------------------------
23 
24 namespace Teuchos {
25 
27 template<typename Ordinal, typename D, typename ... P>
28 typename std::enable_if<Kokkos::is_view_uq_pce< Kokkos::View<D,P...> >::value>::type
29 send (const Kokkos::View<D,P...>& sendBuffer,
30  const Ordinal count,
31  const int destRank,
32  const int tag,
33  const Comm<Ordinal>& comm)
34 {
35  typedef Kokkos::View<D,P...> view_type;
36  typedef typename Kokkos::FlatArrayType<view_type>::type flat_array_type;
37 
38  flat_array_type array = sendBuffer;
39  Ordinal array_count = count * Kokkos::dimension_scalar(sendBuffer);
40  send(array, array_count, destRank, tag, comm);
41 }
42 
44 template<typename Ordinal, typename D, typename ... P>
45 typename std::enable_if<Kokkos::is_view_uq_pce< Kokkos::View<D,P...> >::value>::type
46 ssend (const Kokkos::View<D,P...>& sendBuffer,
47  const Ordinal count,
48  const int destRank,
49  const int tag,
50  const Comm<Ordinal>& comm)
51 {
52  typedef Kokkos::View<D,P...> view_type;
53  typedef typename Kokkos::FlatArrayType<view_type>::type flat_array_type;
54 
55  flat_array_type array = sendBuffer;
56  Ordinal array_count = count * Kokkos::dimension_scalar(sendBuffer);
57  ssend(array, array_count, destRank, tag, comm);
58 }
59 
61 template<typename Ordinal, typename D, typename ... P>
62 typename std::enable_if<Kokkos::is_view_uq_pce< Kokkos::View<D,P...> >::value>::type
63 readySend (const Kokkos::View<D,P...>& sendBuffer,
64  const Ordinal count,
65  const int destRank,
66  const int tag,
67  const Comm<Ordinal>& comm)
68 {
69  typedef Kokkos::View<D,P...> view_type;
70  typedef typename Kokkos::FlatArrayType<view_type>::type flat_array_type;
71 
72  flat_array_type array = sendBuffer;
73  Ordinal array_count = count * Kokkos::dimension_scalar(sendBuffer);
74  readySend(array, array_count, destRank, tag, comm);
75 }
76 
78 template<typename Ordinal, typename D, typename ... P>
79 typename std::enable_if<Kokkos::is_view_uq_pce< Kokkos::View<D,P...> >::value, RCP<CommRequest<Ordinal> > >::type
80 isend (const Kokkos::View<D,P...>& sendBuffer,
81  const int destRank,
82  const int tag,
83  const Comm<Ordinal>& comm)
84 {
85  typedef Kokkos::View<D,P...> view_type;
86  typedef typename Kokkos::FlatArrayType<view_type>::type flat_array_type;
87 
88  flat_array_type array = sendBuffer;
89  return isend(array, destRank, tag, comm);
90 }
91 
93 template<typename Ordinal, typename D, typename ... P>
94 typename std::enable_if<Kokkos::is_view_uq_pce< Kokkos::View<D,P...> >::value, RCP<CommRequest<Ordinal> > >::type
95 ireceive (const Kokkos::View<D,P...>& recvBuffer,
96  const int sourceRank,
97  const int tag,
98  const Comm<Ordinal>& comm)
99 {
100  typedef Kokkos::View<D,P...> view_type;
101  typedef typename Kokkos::FlatArrayType<view_type>::type flat_array_type;
102 
103  flat_array_type array = recvBuffer;
104  return ireceive(array, sourceRank, tag, comm);
105 }
106 
107 }
108 
109 #endif
110 
111 #endif /* #ifndef KOKKOS_TEUCHOS_COMM_ADAPTERS_UQ_PCE_HPP */
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< View< T, P...> >::value, unsigned >::type dimension_scalar(const View< T, P...> &view)
void send(const Packet sendBuffer[], const Ordinal count, const int destRank, const int tag, const Comm< Ordinal > &comm)
RCP< CommRequest< Ordinal > > ireceive(const ArrayRCP< Packet > &recvBuffer, const int sourceRank, const int tag, const Comm< Ordinal > &comm)
RCP< Teuchos::CommRequest< int > > isend(const ArrayRCP< const double > &sendBuffer, const int destRank, const int tag, const Comm< int > &comm)
void ssend(const Packet sendBuffer[], const Ordinal count, const int destRank, const int tag, const Comm< Ordinal > &comm)
void readySend(const Packet sendBuffer[], const Ordinal count, const int destRank, const int tag, const Comm< Ordinal > &comm)