GGEMS  1.1
GPU GEant4-based Monte Carlo Simulations
GGEMSProfilerManager.cc
Go to the documentation of this file.
1 // ************************************************************************
2 // * This file is part of GGEMS. *
3 // * *
4 // * GGEMS is free software: you can redistribute it and/or modify *
5 // * it under the terms of the GNU General Public License as published by *
6 // * the Free Software Foundation, either version 3 of the License, or *
7 // * (at your option) any later version. *
8 // * *
9 // * GGEMS is distributed in the hope that it will be useful, *
10 // * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 // * GNU General Public License for more details. *
13 // * *
14 // * You should have received a copy of the GNU General Public License *
15 // * along with GGEMS. If not, see <https://www.gnu.org/licenses/>. *
16 // * *
17 // ************************************************************************
18 
33 
37 
39 {
40  GGcout("GGEMSProfilerManager", "GGEMSProfilerManager", 3) << "GGEMSProfilerManager creating..." << GGendl;
41 
42  profilers_.clear();
43 
44  GGcout("GGEMSProfilerManager", "GGEMSProfilerManager", 3) << "GGEMSProfilerManager created!!!" << GGendl;
45 }
46 
50 
52 {
53  GGcout("GGEMSProfilerManager", "~GGEMSProfilerManager", 3) << "GGEMSProfilerManager erasing!!!" << GGendl;
54 
55  profilers_.clear();
56 
57  GGcout("GGEMSProfilerManager", "~GGEMSProfilerManager", 3) << "GGEMSProfilerManager erased!!!" << GGendl;
58 }
59 
63 
65 {
66  GGcout("GGEMSProfilerManager", "Clean", 3) << "GGEMSProfilerManager cleaning..." << GGendl;
67 
68  GGcout("GGEMSProfilerManager", "Clean", 3) << "GGEMSProfilerManager cleaned!!!" << GGendl;
69 }
70 
74 
75 void GGEMSProfilerManager::HandleEvent(cl::Event event, std::string const& profile_name)
76 {
77  mutex.lock();
78 
79  // Checking if profile exists already, if not, creating one
80  if (profilers_.find(profile_name) == profilers_.end()) {
81  GGEMSProfiler profiler;
82  profilers_.insert(std::make_pair(profile_name, profiler));
83  }
84 
85  // Storing event data in correct profiler
86  profilers_[profile_name].HandleEvent(event);
87 
88  mutex.unlock();
89 }
90 
94 
96 {
97  for (auto&& p: profilers_) GGEMSChrono::DisplayTime(p.second.GetSummaryTime(), p.first);
98 }
99 
103 
105 {
106  profilers_.clear();
107 }
108 
112 
114 {
116 }
117 
121 
123 {
124  profiler_manager->PrintSummaryProfile();
125 }
get_instance_profiler_manager
GGEMSProfilerManager * get_instance_profiler_manager(void)
Get the GGEMSProfilerManager pointer for python user.
Definition: GGEMSProfilerManager.cc:113
print_summary_profiler_manager
void print_summary_profiler_manager(GGEMSProfilerManager *profiler_manager)
Print summary of profiler.
Definition: GGEMSProfilerManager.cc:122
GGEMSChrono::DisplayTime
void DisplayTime(DurationNano const &duration, std::string const &displayed_text)
Print the execution time.
Definition: GGEMSChrono.cc:38
GGEMSProfilerManager::~GGEMSProfilerManager
~GGEMSProfilerManager(void)
Unable the destructor for the user.
Definition: GGEMSProfilerManager.cc:51
GGEMSProfilerManager::GetInstance
static GGEMSProfilerManager & GetInstance(void)
Create at first time the Singleton.
Definition: GGEMSProfilerManager.hh:66
GGEMSProfiler
GGEMS class handling a specific profiler type.
Definition: GGEMSProfiler.hh:41
GGEMSProfilerManager::GGEMSProfilerManager
GGEMSProfilerManager(void)
Unable the constructor for the user.
Definition: GGEMSProfilerManager.cc:38
GGEMSProfilerManager
GGEMS class managing profiler data.
Definition: GGEMSProfilerManager.hh:48
GGcout
GGEMSStream GGcout
Definition: GGEMSPrint.cc:34
GGEMSProfilerManager::PrintSummaryProfile
void PrintSummaryProfile(void) const
print summary profile
Definition: GGEMSProfilerManager.cc:95
GGEMSProfilerManager::profilers_
ProfilerUMap profilers_
Definition: GGEMSProfilerManager.hh:127
GGEMSProfilerManager::Reset
void Reset(void)
reset all profile already registered
Definition: GGEMSProfilerManager.cc:104
GGEMSProfilerManager::Clean
void Clean(void)
clean OpenCL data
Definition: GGEMSProfilerManager.cc:64
GGendl
#define GGendl
overload C++ std::endl
Definition: GGEMSPrint.hh:60
GGEMSPrint.hh
Print a custom std::cout end std::cerr handling verbosity.
GGEMSProfilerManager.hh
GGEMS class managing profiler data.
anonymous_namespace{GGEMSPrint.hh}::mutex
std::mutex mutex
Definition: GGEMSPrint.hh:43
GGEMSProfilerManager::HandleEvent
void HandleEvent(cl::Event event, std::string const &profile_name)
handle an OpenCL event in profile_name type
Definition: GGEMSProfilerManager.cc:75