message: adds dispatch for distributed vector
diff: @@ -34,8 +34,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  #define GKO_PUBLIC_CORE_BASE_PRECISION_DISPATCH_HPP_
  +#include <ginkgo/config.hpp>
  #include <ginkgo/core/base/math.hpp>
  #include <ginkgo/core/base/temporary_conversion.hpp>
  +#include <ginkgo/core/distributed/vector.hpp>
  #include <ginkgo/core/matrix/dense.hpp>
  @@ -330,6 +332,97 @@ void mixed_precision_dispatch_real_complex(Function fn, const LinOp* in,
  }
  +#if GINKGO_BUILD_MPI
  +
  +
  +template <typename ValueType>
  +detail::temporary_conversion<distributed::Vector<ValueType>>
  +make_temporary_conversion_distributed(LinOp* matrix)
  +{
  + auto result = detail::temporary_conversion<distributed::Vector<ValueType>>::
  + template create<distributed::Vector<next_precision<ValueType>>>(matrix);
  + if (!result) {
  + GKO_NOT_SUPPORTED(matrix);
  + }
  + return result;
  +}
  +
  +
  +template <typename ValueType>
  +detail::temporary_conversion<const distributed::Vector<ValueType>>
  +make_temporary_conversion_distributed(const LinOp* matrix)
  +{
  + auto result =
  + detail::temporary_conversion<const distributed::Vector<ValueType>>::
  + template create<distributed::Vector<next_precision<ValueType>>>(
  + matrix);
  + if (!result) {
  + GKO_NOT_SUPPORTED(matrix);
  + }
  + return result;
  +}
  +
  +
  +template <typename ValueType, typename Function, typename... Args>
  +void precision_dispatch_distributed(Function fn, Args*... linops)
  +{
  + fn(make_temporary_conversion_distributed<ValueType>(linops).get()...);
  +}
  +
  +
  +template <typename ValueType, typename Function>
  +void precision_dispatch_real_complex_distributed(Function fn, const LinOp* in,
  + LinOp* out)
  +{
  + if (dynamic_cast<const distributed::DistributedBase*>(in)) {
  + precision_dispatch_distributed<ValueType>(fn, in, out);
  + } else {
  + precision_dispatch_real_complex<ValueType>(fn, in, out);
  + }
  +}
  +
  +
  +template <typename ValueType, typename Function>
  +void precision_dispatch_real_complex_distributed(Function fn,
  + const LinOp* alpha,
  + const LinOp* in,
  + const LinOp* beta, LinOp* out)
  +{
  + if (dynamic_cast<const distributed::DistributedBase*>(in)) {
  + fn(make_temporary_conversion<ValueType>(alpha).get(),
  + make_temporary_conversion_distributed<ValueType>(in).get(),
  + make_temporary_conversion<ValueType>(beta).get(),
  + make_temporary_conversion_distributed<ValueType>(out).get());
  + } else {
  + precision_dispatch_real_complex<ValueType>(fn, alpha, in, beta, out);
  + }
  +}
  +
  +
  +#else
  +
  +
  +template <typename ValueType, typename Function>
  +void precision_dispatch_real_complex_distributed(Function fn, const LinOp* in,
  + LinOp* out)
  +{
  + precision_dispatch_real_complex<ValueType>(fn, in, out);
  +}
  +
  +
  +template <typename ValueType, typename Function>
  +void precision_dispatch_real_complex_distributed(Function fn,
  + const LinOp* alpha,
  + const LinOp* in,
  + const LinOp* beta, LinOp* out)
  +{
  + precision_dispatch_real_complex<ValueType>(fn, alpha, in, beta, out);
  +}
  +
  +
  +#endif
  +
  +
  } // namespace gko
  