====================================================================
| 538 | |
| 539 | // ==================================================================== |
| 540 | G4String G4MPImanager::BcastCommand(const G4String& command) |
| 541 | { |
| 542 | // Do nothing if not processing worker |
| 543 | if (is_extra_worker_) return G4String("exit"); |
| 544 | |
| 545 | enum |
| 546 | { |
| 547 | kBUFF_SIZE = 512 |
| 548 | }; |
| 549 | static char sbuff[kBUFF_SIZE]; |
| 550 | command.copy(sbuff, kBUFF_SIZE); |
| 551 | G4int len = command.size(); |
| 552 | sbuff[len] = '\0'; // no boundary check |
| 553 | |
| 554 | // "command" is not yet fixed in slaves at this time. |
| 555 | |
| 556 | // waiting message exhausts CPU in LAM! |
| 557 | |
| 558 | // another implementation |
| 559 | if (is_master_) { |
| 560 | for (G4int islave = 1; islave < size_; islave++) { |
| 561 | MPI_Send(sbuff, kBUFF_SIZE, MPI_CHAR, islave, kTAG_G4COMMAND, COMM_G4COMMAND_); |
| 562 | } |
| 563 | } |
| 564 | else { |
| 565 | // try non-blocking receive |
| 566 | MPI_Request request; |
| 567 | MPI_Irecv(sbuff, kBUFF_SIZE, MPI_CHAR, kRANK_MASTER, kTAG_G4COMMAND, COMM_G4COMMAND_, &request); |
| 568 | |
| 569 | int flag = 0; |
| 570 | while (!flag) { |
| 571 | MPI_Test(&request, &flag, MPI_STATUS_IGNORE); |
| 572 | ::Wait(1000); |
| 573 | } |
| 574 | } |
| 575 | |
| 576 | return G4String(sbuff); |
| 577 | } |
| 578 | |
| 579 | // ==================================================================== |
| 580 | void G4MPImanager::ExecuteMacroFile(const G4String& fname, G4bool qbatch) |
no test coverage detected