MCPcopy Create free account
hub / github.com/davisking/dlib / test3_job_driver

Function test3_job_driver

dlib/test/bsp.cpp:224–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222// ----------------------------------------------------------------------------------------
223
224 void test3_job_driver(bsp_context& obj, int& result)
225 {
226
227 obj.broadcast(obj.node_id());
228
229 int accum = 0;
230 int temp = 0;
231 while(obj.try_receive(temp))
232 accum += temp;
233
234 // send to node 1 so it can sum everything
235 if (obj.node_id() != 1)
236 obj.send(accum, 1);
237
238 while(obj.try_receive(temp))
239 accum += temp;
240
241 // Now hop the accum values along the nodes until the value from node 1 gets to
242 // node 0.
243 obj.send(accum, (obj.node_id()+1)%obj.number_of_nodes());
244 obj.receive(accum);
245 obj.send(accum, (obj.node_id()+1)%obj.number_of_nodes());
246 obj.receive(accum);
247 obj.send(accum, (obj.node_id()+1)%obj.number_of_nodes());
248 obj.receive(accum);
249
250 // this whole block is a noop since it doesn't end up doing anything.
251 for (int k = 0; k < 100; ++k)
252 {
253 dlog << LINFO << "k: " << k;
254 for (int i = 0; i < 4; ++i)
255 {
256 obj.send(accum, (obj.node_id()+1)%obj.number_of_nodes());
257 obj.receive(accum);
258 }
259 }
260
261
262 dlog << LINFO << "TERMINATE";
263 if (obj.node_id() == 0)
264 result = accum;
265 }
266
267
268 void test3_job(bsp_context& obj)

Callers 1

test3_jobFunction · 0.85

Calls 6

try_receiveMethod · 0.80
broadcastMethod · 0.45
node_idMethod · 0.45
sendMethod · 0.45
number_of_nodesMethod · 0.45
receiveMethod · 0.45

Tested by

no test coverage detected