| 312 | // ---------------------------------------------------------------------------------------- |
| 313 | |
| 314 | void test4_job_driver(bsp_context& obj, int& result) |
| 315 | { |
| 316 | |
| 317 | obj.broadcast(obj.node_id()); |
| 318 | |
| 319 | int accum = 0; |
| 320 | int temp = 0; |
| 321 | while(obj.try_receive(temp)) |
| 322 | accum += temp; |
| 323 | |
| 324 | // send to node 1 so it can sum everything |
| 325 | if (obj.node_id() != 1) |
| 326 | obj.send(accum, 1); |
| 327 | |
| 328 | while(obj.try_receive(temp)) |
| 329 | accum += temp; |
| 330 | |
| 331 | // Now hop the accum values along the nodes until the value from node 1 gets to |
| 332 | // node 0. |
| 333 | obj.send(accum, (obj.node_id()+1)%obj.number_of_nodes()); |
| 334 | obj.receive(accum); |
| 335 | obj.send(accum, (obj.node_id()+1)%obj.number_of_nodes()); |
| 336 | obj.receive(accum); |
| 337 | obj.send(accum, (obj.node_id()+1)%obj.number_of_nodes()); |
| 338 | obj.receive(accum); |
| 339 | |
| 340 | // this whole block is a noop since it doesn't end up doing anything. |
| 341 | for (int k = 0; k < 40; ++k) |
| 342 | { |
| 343 | dlog << LINFO << "k: " << k; |
| 344 | for (int i = 0; i < 4; ++i) |
| 345 | { |
| 346 | obj.send(accum, (obj.node_id()+1)%obj.number_of_nodes()); |
| 347 | obj.receive(accum); |
| 348 | |
| 349 | obj.receive(); |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | |
| 354 | dlog << LINFO << "TERMINATE"; |
| 355 | if (obj.node_id() == 0) |
| 356 | result = accum; |
| 357 | } |
| 358 | |
| 359 | |
| 360 | void test4_job(bsp_context& obj) |
no test coverage detected