12 #ifdef HAVE_TPETRACORE_MPI
30 computeKokkosComplexMpiDatatypeImpl (const ::Kokkos::complex<T>& z)
32 static_assert (MpiTypeTraits<T>::isSpecialized,
"This function only "
33 "works if MpiTypeTraits<T>::isSpecialized.");
34 static_assert (! MpiTypeTraits<T>::needsFree,
"This function requires "
35 "! MpiTypeTraits<T>::needsFree, since otherwise it would "
39 MPI_Datatype innerDatatype = MpiTypeTraits<T>::getType (z.real ());
40 MPI_Datatype outerDatatype;
47 if (
sizeof ( ::Kokkos::complex<T>) == 2 *
sizeof (T)) {
48 (void) MPI_Type_contiguous (2, innerDatatype, &outerDatatype);
56 MPI_Aint arrayOfDisplacements[3];
57 MPI_Datatype arrayOfTypes[3];
60 static_assert (
sizeof (MyComplex<T>) ==
sizeof ( ::Kokkos::complex<T>),
61 "Attempt to construct a struct of the same size and layout "
62 "as Kokkos::complex<T> failed.");
63 ::Teuchos::Details::Impl::MyComplex<T> z2;
72 arrayOfDisplacements[0] =
reinterpret_cast<uintptr_t
> (&z2.re) - reinterpret_cast<uintptr_t> (&z2);
73 arrayOfTypes[0] = innerDatatype;
77 arrayOfDisplacements[1] =
reinterpret_cast<uintptr_t
> (&z2.im) - reinterpret_cast<uintptr_t> (&z2);
78 arrayOfTypes[1] = innerDatatype;
83 arrayOfDisplacements[2] =
sizeof (MyComplex<T>);
84 arrayOfTypes[2] = MPI_UB;
85 #endif // MPI_VERSION < 2
89 (void) MPI_Type_struct (3, blockLengths, arrayOfDisplacements,
90 arrayOfTypes, &outerDatatype);
93 (void) MPI_Type_create_struct (2, blockLengths, arrayOfDisplacements,
94 arrayOfTypes, &outerDatatype);
95 #endif // MPI_VERSION < 2
98 MPI_Type_commit (&outerDatatype);
104 computeKokkosComplexMpiDatatype (const ::Kokkos::complex<double>& z)
107 return computeKokkosComplexMpiDatatypeImpl<double> (z);
112 computeKokkosComplexMpiDatatype (const ::Kokkos::complex<float>& z)
114 return computeKokkosComplexMpiDatatypeImpl<float> (z);
120 MpiTypeTraits< ::Kokkos::complex<double> >::
121 getType (const ::Kokkos::complex<double>& z)
125 return MPI_C_DOUBLE_COMPLEX;
127 return MPI_DATATYPE_NULL;
128 #endif // MPI_VERSION >= 3
131 return Impl::computeKokkosComplexMpiDatatype (z);
136 MpiTypeTraits< ::Kokkos::complex<double> >::
141 return MPI_C_DOUBLE_COMPLEX;
143 return MPI_DATATYPE_NULL;
144 #endif // MPI_VERSION >= 3
149 ::Kokkos::complex<double> z (3.0, 4.0);
150 return Impl::computeKokkosComplexMpiDatatype (z);
155 MpiTypeTraits< ::Kokkos::complex<float> >::
156 getType (const ::Kokkos::complex<float>& z)
160 return MPI_C_FLOAT_COMPLEX;
162 return MPI_DATATYPE_NULL;
163 #endif // MPI_VERSION >= 3
166 return Impl::computeKokkosComplexMpiDatatype (z);
171 MpiTypeTraits< ::Kokkos::complex<float> >::
176 return MPI_C_FLOAT_COMPLEX;
178 return MPI_DATATYPE_NULL;
179 #endif // MPI_VERSION >= 3
184 ::Kokkos::complex<float> z (3.0, 4.0);
185 return Impl::computeKokkosComplexMpiDatatype (z);
193 #endif // HAVE_TPETRACORE_MPI
Add specializations of Teuchos::Details::MpiTypeTraits for Kokkos::complex<float> and Kokkos::complex...