File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -104,6 +104,7 @@ class Generator : public FairGenerator
104104
105105 // Number of parallel sub-generator clones a Hyperloop-aware generator expands into
106106 // (currently used by the external-generator-to-hybrid expansion in GeneratorFactory).
107+ // 8 matches the standard core counts of Grid/Hyperloop nodes
107108 static constexpr int NHyperloopParallelGenerators = 8 ;
108109
109110 /* * other **/
Original file line number Diff line number Diff line change @@ -60,6 +60,11 @@ namespace eventgen
6060// using the configured GeneratorExternalParam. This makes the simulation parallelisation automatic
6161// on Hyperloop.
6262// To-do: Define the behaviour with ini configuration which are already definining a hybrid gen
63+ //
64+ // Note on GeneratorHybrid.num_workers: expanding to 8 sub-generators does not by itself raise
65+ // the number of TBB workers that actually run them in parallel. This is controlled by
66+ // the parameter GeneratorHybrid.num_workers. On Hyperloop this will be part
67+ // of the standard train configuration
6368std::string buildHyperloopExternalHybridConfig (GeneratorExternalParam const & extparams)
6469{
6570 rapidjson::Document doc;
@@ -84,10 +89,12 @@ std::string buildHyperloopExternalHybridConfig(GeneratorExternalParam const& ext
8489 doc.AddMember (" generators" , generators, alloc);
8590 doc.AddMember (" fractions" , fractions, alloc);
8691
92+ // The generated config file is deliberatelly left on disk for possible inspection after the process ran.
8793 std::string path = " hyperloop_exttohybrid_" + std::to_string (getpid ()) + " .json" ;
8894 std::ofstream ofs (path);
8995 if (!ofs.is_open ()) {
9096 LOG (fatal) << " Failed to open " << path << " for writing the Hyperloop hybrid generator configuration" ;
97+ exit (1 );
9198 }
9299 rapidjson::OStreamWrapper osw (ofs);
93100 rapidjson::Writer<rapidjson::OStreamWrapper> writer (osw);
Original file line number Diff line number Diff line change @@ -122,6 +122,13 @@ GeneratorHybrid::GeneratorHybrid(const std::string& inputgens)
122122 mGens .push_back (gen);
123123 } else if (gen.compare (" external" ) == 0 ) {
124124 int confextIndex = std::stoi (mConfigs [index].substr (9 ));
125+ // Hybrid configs can clone the same external generator config multiple times so
126+ // an external macro that self-seeds from gRandom could sample the same seed.
127+ // For this reason the shared RNG state is advanced as a precaution
128+ // mirroring what GeneratorPythia8::seedGenerator() does for multiple Pythia8 instances.
129+ if (std::count (mGens .begin (), mGens .end (), " external" ) > 0 ) {
130+ gRandom ->Rndm ();
131+ }
125132 // we need analyse the ini file to update the config key param
126133 if (mExternalGenConfigs [confextIndex]->iniFile .size () > 0 ) {
127134 LOG (info) << " Setting up external gen using the given INI file" ;
You can’t perform that action at this time.
0 commit comments