![]() |
|
|||
File indexing completed on 2025-08-05 08:19:19
0001 /******************************************************************************* 0002 * Copyright (c) The JETSCAPE Collaboration, 2018 0003 * 0004 * Modular, task-based framework for simulating all aspects of heavy-ion collisions 0005 * 0006 * For the list of contributors see AUTHORS. 0007 * 0008 * Report issues at https://github.com/JETSCAPE/JETSCAPE/issues 0009 * 0010 * or via email to bugs.jetscape@gmail.com 0011 * 0012 * Distributed under the GNU General Public License 3.0 (GPLv3 or later). 0013 * See COPYING for details. 0014 ******************************************************************************/ 0015 0016 /** TaskSupport instance class (meant as singelton) 0017 * Keeps track of every created task in a thread-safe manner 0018 * and provides resources that depend on such information 0019 * Initial reason was to provide tasks with random seeds 0020 * such that reproducible running is possible 0021 * It provides a random engine factory. 0022 * That way individual random engines can be used where necessary 0023 * but by default all can use the same 0024 * (the state of mersenne twister can be rather large) 0025 * 0026 * Note that (apart from Microsoft VS2013), magic statics should ensure that 0027 * the Instance() method is automagically thread safe 0028 * 0029 * Note 2: make_unique doesn't work for some reason. "new" does the trick here though. 0030 */ 0031 0032 #ifndef JETSCAPETASKSUPPORT_H 0033 #define JETSCAPETASKSUPPORT_H 0034 0035 #include "InitialState.h" 0036 #include "JetEnergyLoss.h" 0037 #include "JetEnergyLossManager.h" 0038 #include "FluidDynamics.h" 0039 #include "HardProcess.h" 0040 #include "JetScapeWriter.h" 0041 0042 #include <iostream> 0043 #include <atomic> 0044 #include <memory> 0045 #include <random> 0046 #include <thread> 0047 0048 using std::atomic_int; 0049 0050 namespace Jetscape { 0051 0052 class 0053 JetScapeTaskSupport //: public sigslot::has_slots<sigslot::multi_threaded_local> 0054 { 0055 0056 public: 0057 static JetScapeTaskSupport *Instance(); 0058 // void CleanUp(); 0059 0060 /// Tasks should call this method at creation and 0061 /// remember the answer as their task id 0062 /// This could co a lot more, like keep a map of numbers to task.id (essentially the name of the task) 0063 /// But for now keep it simple 0064 int RegisterTask(); 0065 0066 /// Initialize random engine functionality from the XML file 0067 static void ReadSeedFromXML(); 0068 0069 /// Return a handle to a mersenne twister 0070 /// Usually this should be just one shared by everybody 0071 /// but if reproducible seeds are requested, 0072 /// every task gets their own 0073 shared_ptr<std::mt19937> GetMt19937Generator(int TaskId); 0074 0075 // Getters 0076 static unsigned int GetRandomSeed() { return random_seed_; }; 0077 0078 protected: 0079 static bool one_generator_per_task_; 0080 0081 private: 0082 JetScapeTaskSupport() : CurrentTaskNumber(0){}; 0083 0084 static JetScapeTaskSupport *m_pInstance; 0085 0086 atomic_int CurrentTaskNumber; 0087 static unsigned int random_seed_; 0088 static bool initialized_; 0089 0090 static shared_ptr<std::mt19937> one_for_all_; 0091 }; 0092 0093 } // end namespace Jetscape 0094 0095 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |