Message: Multithreading and random generators Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Multithreading and random generators 

Forum: Multithreading
Date: 06 Jun, 2014
From: Stefano Caiazza <Stefano Caiazza>

Dear G4 Experts and developers I recently tried to add a more modern Random Generator engine to the set used by G4. I developed my class then wrapped it as a descendant in the HepRandomEngine hierarchy. Everything works fine when I use my classes stand-alone, within or outside G4. When I switch on the multithreading, though I receive a runtime exception :

"Unknown type of RNG Engine - Can cope only with HepJamesRandom, Ranecu, Ranlux64, MTwistEngine, DualRand, Ranlux or Ranshi. Cannot clone this type of RNG engine, as required for this thread"

I went through the code and I found out that the reason for this problem is in the G4UserWorkerThreadInitialization::SetupRNGEngine method.

In this method due to the lack of a polymorphic creation function in the engine interface, the developer decided to place a switch clause to find which is the engine used in the master thread. Obviously this system limits the choice only to the engines already available and known to the developer but doesn't allow any extension.

In fact the developer himself comments:

"Does a new method, such as aNewRng->newEngine() exist to clone it ?"

Is this a known issue? Are there plans to solve this problem? Technically it would be quite easy but it would require a change of the HepRandomEngine interface, or, more simply but less clean, the addition of a "generic clonable engine", derived from HepRandomEngine, as a base class for additional custom engines, which introduces the Create or Clone abstract function to be implemented by the user

Best Stefano

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Idea: Re: Multithreading and random generators   (Andrea Dotti - 06 Jun, 2014)
(_ Ok: Re: Multithreading and random generators   (Stefano Caiazza - 06 Jun, 2014)
(_ Question: Re: Multithreading and random generators   (panda - 11 Dec, 2016)
 Add Message Add Message
to: "Multithreading and random generators"

 Subscribe Subscribe

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