GGEMS  1.1
GPU GEant4-based Monte Carlo Simulations
GGEMSProfilerItem.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 {
41 
42  // Get time infos from event
43  opencl_manager.CheckOpenCLError(clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_START, sizeof(GGulong), &times_[GGEMSEventInfo::START], nullptr), "GGEMSProfilerItem", "GGEMSProfilerItem");
44  opencl_manager.CheckOpenCLError(clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_END, sizeof(GGulong), &times_[GGEMSEventInfo::END], nullptr), "GGEMSProfilerItem", "GGEMSProfilerItem");
45 
46  times_[GGEMSEventInfo::ELAPSED] = times_[GGEMSEventInfo::END] - times_[GGEMSEventInfo::START];
47 }
48 
52 
53 void GGEMSProfilerItem::UpdateEvent(cl_event event)
54 {
55  // Get time infos from event
57  opencl_manager.CheckOpenCLError(clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_START, sizeof(GGulong), &times_[GGEMSEventInfo::START], nullptr), "GGEMSProfilerItem", "UpdateEvent");
58  opencl_manager.CheckOpenCLError(clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_END, sizeof(GGulong), &times_[GGEMSEventInfo::END], nullptr), "GGEMSProfilerItem", "UpdateEvent");
59  times_[GGEMSEventInfo::ELAPSED] += times_[GGEMSEventInfo::END] - times_[GGEMSEventInfo::START];
60 }
GGulong
#define GGulong
Definition: GGEMSTypes.hh:245
GGEMSOpenCLManager::CheckOpenCLError
void CheckOpenCLError(GGint const &error, std::string const &class_name, std::string const &method_name) const
check the OpenCL error
Definition: GGEMSOpenCLManager.cc:1048
GGEMSProfilerItem::times_
GGulong times_[3]
Definition: GGEMSProfilerItem.hh:109
GGEMSProfilerItem::UpdateEvent
void UpdateEvent(cl_event event)
Update elapsed time in OpenCL command.
Definition: GGEMSProfilerItem.cc:53
GGEMSProfilerItem.hh
GGEMS class handling a specific item profiler.
GGEMSOpenCLManager.hh
Singleton class storing all informations about OpenCL and managing GPU/CPU devices,...
GGEMSOpenCLManager
Singleton class storing all informations about OpenCL and managing GPU/CPU devices,...
Definition: GGEMSOpenCLManager.hh:54
GGEMSProfilerItem::GGEMSProfilerItem
GGEMSProfilerItem(cl_event event)
GGEMSProfilerItem constructor.
Definition: GGEMSProfilerItem.cc:38
GGEMSOpenCLManager::GetInstance
static GGEMSOpenCLManager & GetInstance(void)
Create at first time the Singleton.
Definition: GGEMSOpenCLManager.hh:72