Message: Re: Can I ignore the output from Thread ID -1 Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Idea Re: Can I ignore the output from Thread ID -1  

Forum: Multithreading
Re: None Can I ignore the output from Thread ID -1
Date: 16 Oct, 2014
From: Andrea Dotti <Andrea Dotti>

Hello, the "thread" with ID == -1 is the master thread. From your report I understand you initialize AnalysisImageManager in the RunAction and that you create an instance of it also for the master, i.e. probably implementing the method: G4VUserActionInitialization::BuildForMaster() const

This behavior is thus correct, you can safely ignore the output of th exile with -1. Alternatively, if you do not want this file to be produced at all for the master, you can modify your code as follows:

void AnalysisImageManager::writeImages(G4String dir) const{
   if ( ! G4Threading::IsWorkerThread() ) return;
   G4int threadID = G4Threading::G4GetThreadId();
  //...
}

If you want to create a general MT independent code and use it also in a sequential build with meaningful file names you can modify the code as:

void AnalysisImageManager::writeImages(G4String dir) const{
    if ( G4Threading::IsMultithreadedApplication() && ! G4Threading::IsWorkerThread() ) return;   
   G4int threadID = G4Threading::IsMultithreadedApplication() ? G4Threading::G4GetThreadId() : 0;
   //...
}

Hope this helps, Andrea

 Add Message Add Message
to: "Re: Can I ignore the output from Thread ID -1 "

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews