Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_Details_Ialltofewv.hpp
1// @HEADER
2// *****************************************************************************
3// Tpetra: Templated Linear Algebra Services Package
4//
5// Copyright 2008 NTESS and the Tpetra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#pragma once
11
12#include <memory>
13
14#include <mpi.h>
15
16namespace Tpetra::Details {
17
18struct Ialltofewv {
19 struct Req {
20 const void *sendbuf;
21 const int *sendcounts;
22 const int *sdispls;
23 MPI_Datatype sendtype;
24 void *recvbuf;
25 const int *recvcounts;
26 const int *rdispls;
27 const int *roots;
28 int nroots;
29 MPI_Datatype recvtype;
30 int aggTag;
31 int rootTag;
32 MPI_Comm comm;
33
34 bool devAccess;
35 bool completed;
36 };
37
38 template <bool DevAccess>
39 int post(const void *sendbuf,
40 const int *sendcounts, // how much to each root (length nroots)
41 const int *sdispls, // where data for each root starts (length nroots)
42 MPI_Datatype sendtype,
43 void *recvbuf, // address of recv buffer (significant only at root)
44 const int *recvcounts, // the number of elements recvd from each process
45 // (signficant only at roots)
46 const int *rdispls, // where in `recvbuf` to place incoming data from
47 // process i (signficant only at roots)
48 const int *roots, // list of root ranks (must be same on all procs)
49 int nroots, // size of list of root ranks
50 MPI_Datatype recvtype,
51 int aggTag,
52 int rootTag,
53 MPI_Comm comm,
54 Req *req) {
55 req->sendbuf = sendbuf;
56 req->sendcounts = sendcounts;
57 req->sdispls = sdispls;
58 req->sendtype = sendtype;
59 req->recvbuf = recvbuf;
60 req->recvcounts = recvcounts;
61 req->rdispls = rdispls;
62 req->roots = roots;
63 req->nroots = nroots;
64 req->recvtype = recvtype;
65 req->aggTag = aggTag;
66 req->rootTag = rootTag;
67 req->comm = comm;
68
69 req->devAccess = DevAccess;
70 req->completed = false;
71#ifndef NDEBUG
72 // {
73 // std::stringstream ss;
74 // ss << __FILE__ << ":" << __LINE__ << "\n";
75 // std::cerr << ss.str();
76 // }
77#endif
78 return MPI_SUCCESS;
79 }
80
81 int wait(Req &req);
82
83 int get_status(const Req &req, int *flag, MPI_Status *status) const;
84
85 struct Cache {
86 struct impl;
87 std::shared_ptr<impl> pimpl;
88
89 Cache();
90 ~Cache();
91 };
92
93 private:
94 Cache cache_;
95
96}; // struct Ialltofewv
97} // namespace Tpetra::Details
Nonmember function that computes a residual Computes R = B - A * X.