ezp
Loading...
Searching...
No Matches
solver.full.hpp
1/*******************************************************************************
2 * Copyright (C) 2025 Theodore Chang
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 ******************************************************************************/
17
18#ifndef SOLVER_FULL_HPP
19#define SOLVER_FULL_HPP
20
21#include <ezp/ezp>
22#include <mpl/mpl.hpp>
23
24inline const auto& comm_world{mpl::environment::comm_world()};
25inline const auto& parent = mpl::inter_communicator::parent();
26
27template<ezp::data_t DT, ezp::index_t IT, typename solver_t> int run(const int N, const int NRHS) {
28 std::vector<DT> A, B;
29
30 if(0 == comm_world.rank()) {
31 A.resize(N * N);
32 B.resize(N * NRHS);
33
34 mpl::irequest_pool requests;
35
36 requests.push(parent.irecv(A, 0, mpl::tag_t{0}));
37 requests.push(parent.irecv(B, 0, mpl::tag_t{1}));
38
39 requests.waitall();
40 }
41
42 const auto error = solver_t().solve({N, N, A.data()}, {N, NRHS, B.data()});
43
44 if(0 == comm_world.rank()) {
45 parent.send(error, 0);
46 if(0 == error) parent.send(B, 0);
47 }
48
49 return 0;
50}
51
52#endif // SOLVER_FULL_HPP