MCPcopy Create free account
hub / github.com/Geant4/geant4 / BcastCommand

Method BcastCommand

examples/extended/parallel/MPI/source/src/G4MPImanager.cc:540–577  ·  view source on GitHub ↗

====================================================================

Source from the content-addressed store, hash-verified

538
539// ====================================================================
540G4String 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// ====================================================================
580void G4MPImanager::ExecuteMacroFile(const G4String& fname, G4bool qbatch)

Callers 3

SessionStartMethod · 0.80
TryForcedTerminateMethod · 0.80
SessionStartMethod · 0.80

Calls 4

WaitFunction · 0.85
G4StringClass · 0.50
copyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected