46 #ifdef HAVE_TPETRACORE_MPI
64 computeKokkosComplexMpiDatatypeImpl (const ::Kokkos::complex<T>& z)
66 static_assert (MpiTypeTraits<T>::isSpecialized,
"This function only "
67 "works if MpiTypeTraits<T>::isSpecialized.");
68 static_assert (! MpiTypeTraits<T>::needsFree,
"This function requires "
69 "! MpiTypeTraits<T>::needsFree, since otherwise it would "
73 MPI_Datatype innerDatatype = MpiTypeTraits<T>::getType (z.real ());
74 MPI_Datatype outerDatatype;
81 if (
sizeof ( ::Kokkos::complex<T>) == 2 *
sizeof (T)) {
82 (void) MPI_Type_contiguous (2, innerDatatype, &outerDatatype);
90 MPI_Aint arrayOfDisplacements[3];
91 MPI_Datatype arrayOfTypes[3];
94 static_assert (
sizeof (MyComplex<T>) ==
sizeof ( ::Kokkos::complex<T>),
95 "Attempt to construct a struct of the same size and layout "
96 "as Kokkos::complex<T> failed.");
97 ::Teuchos::Details::Impl::MyComplex<T> z2;
106 arrayOfDisplacements[0] =
reinterpret_cast<uintptr_t
> (&z2.re) - reinterpret_cast<uintptr_t> (&z2);
107 arrayOfTypes[0] = innerDatatype;
111 arrayOfDisplacements[1] =
reinterpret_cast<uintptr_t
> (&z2.im) - reinterpret_cast<uintptr_t> (&z2);
112 arrayOfTypes[1] = innerDatatype;
117 arrayOfDisplacements[2] =
sizeof (MyComplex<T>);
118 arrayOfTypes[2] = MPI_UB;
119 #endif // MPI_VERSION < 2
123 (void) MPI_Type_struct (3, blockLengths, arrayOfDisplacements,
124 arrayOfTypes, &outerDatatype);
127 (void) MPI_Type_create_struct (2, blockLengths, arrayOfDisplacements,
128 arrayOfTypes, &outerDatatype);
129 #endif // MPI_VERSION < 2
132 MPI_Type_commit (&outerDatatype);
133 return outerDatatype;
138 computeKokkosComplexMpiDatatype (const ::Kokkos::complex<double>& z)
141 return computeKokkosComplexMpiDatatypeImpl<double> (z);
146 computeKokkosComplexMpiDatatype (const ::Kokkos::complex<float>& z)
148 return computeKokkosComplexMpiDatatypeImpl<float> (z);
154 MpiTypeTraits< ::Kokkos::complex<double> >::
155 getType (const ::Kokkos::complex<double>& z)
159 return MPI_C_DOUBLE_COMPLEX;
161 return MPI_DATATYPE_NULL;
162 #endif // MPI_VERSION >= 3
165 return Impl::computeKokkosComplexMpiDatatype (z);
170 MpiTypeTraits< ::Kokkos::complex<double> >::
175 return MPI_C_DOUBLE_COMPLEX;
177 return MPI_DATATYPE_NULL;
178 #endif // MPI_VERSION >= 3
183 ::Kokkos::complex<double> z (3.0, 4.0);
184 return Impl::computeKokkosComplexMpiDatatype (z);
189 MpiTypeTraits< ::Kokkos::complex<float> >::
190 getType (const ::Kokkos::complex<float>& z)
194 return MPI_C_FLOAT_COMPLEX;
196 return MPI_DATATYPE_NULL;
197 #endif // MPI_VERSION >= 3
200 return Impl::computeKokkosComplexMpiDatatype (z);
205 MpiTypeTraits< ::Kokkos::complex<float> >::
210 return MPI_C_FLOAT_COMPLEX;
212 return MPI_DATATYPE_NULL;
213 #endif // MPI_VERSION >= 3
218 ::Kokkos::complex<float> z (3.0, 4.0);
219 return Impl::computeKokkosComplexMpiDatatype (z);
227 #endif // HAVE_TPETRACORE_MPI
Add specializations of Teuchos::Details::MpiTypeTraits for Kokkos::complex<float> and Kokkos::complex...