RsBundle  Diff

Differences From Artifact [672c532f96]:

  • File src/mpi/worker.rs — part of check-in [d02e699a01] at 2023-04-05 21:24:04 on branch mpi — Fix many clippy/linter warnings (user: fifr size: 5509)

To Artifact [4a5d858625]:

  • File src/mpi/worker.rs — part of check-in [39442277b4] at 2023-04-06 15:29:11 on branch mpi — mpi: simplify return message `ReturnType` and `ReturnMsg` to a single enum (user: fifr size: 4643)

11
12
13
14
15
16
17
18

19
20
21
22
23
24
25
11
12
13
14
15
16
17

18
19
20
21
22
23
24
25







-
+







 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see  <http://www.gnu.org/licenses/>
 */

use super::msg::{ResultMsg, ResultType, WorkerMsg};
use super::msg::{ResultMsg, WorkerMsg};
use crate::problem::{FirstOrderProblem, ResultSendError, ResultSender};
use crate::Real;

use flexbuffers;
use log::info;
use mpi::environment::Universe;
use mpi::point_to_point::{Destination, Source};
107
108
109
110
111
112
113

114

115
116
117


118
119

120
121
122
123
124
125



126
127
128

129
130
131
132
133
134
135
136

137
138


139
140
141
142
143
144
145
146
147
148
149
150
151
152





153
154
155
156
157
158
159
160
107
108
109
110
111
112
113
114

115
116


117
118


119






120
121
122



123








124


125
126




127









128
129
130
131
132
133
134
135
136
137
138
139
140







+
-
+

-
-
+
+
-
-
+
-
-
-
-
-
-
+
+
+
-
-
-
+
-
-
-
-
-
-
-
-
+
-
-
+
+
-
-
-
-

-
-
-
-
-
-
-
-
-
+
+
+
+
+








                        .problem
                        .evaluate(i, y, WorkerResultSender { sender: client_tx })
                        .is_err()
                    {
                        panic!("Evaluation error")
                    }

                    let mut done = false;
                    loop {
                    while !done {
                        let cmsg = client_rx.recv().expect("channel receive error");
                        match cmsg {
                            EvalResult::ObjectiveValue(objval) => {
                        let rmsg = match cmsg {
                            EvalResult::ObjectiveValue(objval) => ResultMsg::ObjectiveValue {
                                client.send(&ResultMsg {
                                    index: i,
                                index: i,
                                    typ: ResultType::ObjectiveValue,
                                    n: 1,
                                });
                                client.send(&objval);
                            }
                            EvalResult::Minorant(minorant) => {
                                value: objval,
                            },
                            EvalResult::Minorant(minorant) => ResultMsg::Minorant { index: i, minorant },
                                let mut s = flexbuffers::FlexbufferSerializer::new();
                                minorant.serialize(&mut s).unwrap();

                            EvalResult::Error(err) => ResultMsg::Error { index: i, error: err },
                                client.send(&ResultMsg {
                                    index: i,
                                    typ: ResultType::Minorant,
                                    n: s.view().len(),
                                });
                                client.send(s.view());
                            }
                            EvalResult::Error(_) => {
                            EvalResult::Done => {
                                client.send(&ResultMsg {
                                    index: i,
                                done = true;
                                ResultMsg::Done { index: i }
                                    typ: ResultType::Error,
                                    n: 0,
                                });
                                //client.send(&err);
                            }
                            EvalResult::Done => {
                                client.send(&ResultMsg {
                                    index: i,
                                    typ: ResultType::Done,
                                    n: 0,
                                });
                                break;
                            }
                        }
                        };

                        let mut s = flexbuffers::FlexbufferSerializer::new();
                        rmsg.serialize(&mut s).unwrap();
                        client.send(s.view());
                    }
                }
            }
        }

        info!("Terminate worker process {}", world.rank());
    }
}