|
GGEMS
1.1
GPU GEant4-based Monte Carlo Simulations
|
Go to the documentation of this file.
43 : navigator_name_(navigator_name),
45 is_update_pos_(false),
46 is_update_rot_(false),
51 dose_calculator_(nullptr),
52 is_dosimetry_mode_(false)
54 GGcout(
"GGEMSNavigator",
"GGEMSNavigator", 3) <<
"GGEMSNavigator creating..." <<
GGendl;
77 GGcout(
"GGEMSNavigator",
"GGEMSNavigator", 3) <<
"GGEMSNavigator created!!!" <<
GGendl;
86 GGcout(
"GGEMSNavigator",
"~GGEMSNavigator", 3) <<
"GGEMSNavigator erasing..." <<
GGendl;
107 GGcout(
"GGEMSNavigator",
"~GGEMSNavigator", 3) <<
"GGEMSNavigator erased!!!" <<
GGendl;
177 GGcout(
"GGEMSNavigator",
"CheckParameters", 3) <<
"Checking the mandatory parameters..." <<
GGendl;
181 std::ostringstream oss(std::ostringstream::out);
182 oss <<
"Id of the navigator is not set!!!";
188 std::ostringstream oss(std::ostringstream::out);
189 oss <<
"Output basename not set!!!";
200 GGcout(
"GGEMSNavigator",
"Initialize", 3) <<
"Initializing a GGEMS navigator..." <<
GGendl;
229 cl::CommandQueue* queue = opencl_manager.
GetCommandQueue(thread_index);
230 cl::Event*
event = opencl_manager.
GetEvent(thread_index);
234 std::string device_name = opencl_manager.
GetDeviceName(device_index);
235 std::ostringstream oss(std::ostringstream::out);
236 oss <<
"GGEMSNavigator::ParticleSolidDistance on " << device_name <<
", index " << device_index;
248 cl::NDRange global_wi(number_of_work_items);
249 cl::NDRange local_wi(work_group_size);
258 kernel->setArg(0, number_of_particles);
259 kernel->setArg(1, *primary_particles);
260 kernel->setArg(2, *solid_data);
263 GGint kernel_status = queue->enqueueNDRangeKernel(*kernel, 0, global_wi, local_wi,
nullptr, event);
264 opencl_manager.
CheckOpenCLError(kernel_status,
"GGEMSNavigator",
"ParticleSolidDistance");
281 cl::CommandQueue* queue = opencl_manager.
GetCommandQueue(thread_index);
282 cl::Event*
event = opencl_manager.
GetEvent(thread_index);
286 std::string device_name = opencl_manager.
GetDeviceName(device_index);
287 std::ostringstream oss(std::ostringstream::out);
288 oss <<
"GGEMSNavigator::ProjectToSolid on " << device_name <<
", index " << device_index;
300 cl::NDRange global_wi(number_of_work_items);
301 cl::NDRange local_wi(work_group_size);
310 kernel->setArg(0, number_of_particles);
311 kernel->setArg(1, *primary_particles);
312 kernel->setArg(2, *solid_data);
315 GGint kernel_status = queue->enqueueNDRangeKernel(*kernel, 0, global_wi, local_wi,
nullptr, event);
316 opencl_manager.
CheckOpenCLError(kernel_status,
"GGEMSNavigator",
"ProjectToSolid");
333 cl::CommandQueue* queue = opencl_manager.
GetCommandQueue(thread_index);
334 cl::Event*
event = opencl_manager.
GetEvent(thread_index);
338 std::string device_name = opencl_manager.
GetDeviceName(device_index);
339 std::ostringstream oss(std::ostringstream::out);
340 oss <<
"GGEMSNavigator::TrackThroughSolid on " << device_name <<
", index " << device_index;
361 cl::NDRange global_wi(number_of_work_items);
362 cl::NDRange local_wi(work_group_size);
375 cl::Buffer* histogram =
nullptr;
376 cl::Buffer* scatter_histogram =
nullptr;
378 cl::Buffer* photon_tracking_dosimetry =
nullptr;
379 cl::Buffer* hit_tracking_dosimetry =
nullptr;
380 cl::Buffer* edep_tracking_dosimetry =
nullptr;
381 cl::Buffer* edep_squared_tracking_dosimetry =
nullptr;
382 cl::Buffer* dosimetry_params =
nullptr;
383 if (data_reg_type ==
"HISTOGRAM") {
387 else if (data_reg_type ==
"DOSIMETRY") {
397 kernel->setArg(0, number_of_particles);
398 kernel->setArg(1, *primary_particles);
399 kernel->setArg(2, *randoms);
400 kernel->setArg(3, *solid_data);
401 kernel->setArg(4, *label_data);
402 kernel->setArg(5, *cross_sections);
403 kernel->setArg(6, *materials);
405 if (data_reg_type ==
"HISTOGRAM") {
406 kernel->setArg(8, *histogram);
407 kernel->setArg(9, *scatter_histogram);
409 else if (data_reg_type ==
"DOSIMETRY") {
410 kernel->setArg(8, *dosimetry_params);
411 kernel->setArg(9, *edep_tracking_dosimetry);
412 kernel->setArg(10, *edep_squared_tracking_dosimetry);
413 kernel->setArg(11, *hit_tracking_dosimetry);
414 kernel->setArg(12, *photon_tracking_dosimetry);
418 GGint kernel_status = queue->enqueueNDRangeKernel(*kernel, 0, global_wi, local_wi,
nullptr, event);
419 opencl_manager.
CheckOpenCLError(kernel_status,
"GGEMSNavigator",
"TrackThroughSolid");
444 GGcout(
"GGEMSNavigator",
"PrintInfos", 0) <<
"GGEMSNavigator Infos:" <<
GGendl;
445 GGcout(
"GGEMSNavigator",
"PrintInfos", 0) <<
"---------------------" <<
GGendl;
void PrintInfos(void) const
Print infos about navigator.
static GGEMSSourceManager & GetInstance(void)
Create at first time the Singleton.
virtual void Initialize(void)
void ParticleSolidDistance(GGsize const &thread_index)
Compute distance between particle and solid.
GGsize GetNumberOfParticles(GGsize const &thread_index) const
Get the number of particles on activated device.
GGEMS class handling the cross sections tables.
void Store(GGEMSNavigator *navigator)
storing the navigator pointer to navigator manager
GGsize GetNumberOfActivatedDevice(void) const
get the number of activated devices
cl::Kernel * GetKernelProjectToSolid(GGsize const &thread_index) const
get the pointer to kernel associated to a device
cl::Buffer * GetMaterialTables(GGsize const &thread_index) const
get the pointer on material tables on OpenCL device
GGEMS class handling material(s) for a specific navigator.
cl::Buffer * GetCrossSections(GGsize const &thread_index) const
return the pointer to OpenCL buffer storing cross sections
T AngleUnit(T const &value, std::string const &unit)
Choose best angle unit.
static GGEMSProfilerManager & GetInstance(void)
Create at first time the Singleton.
GGEMS class handling the cross sections tables.
cl::Buffer * GetPhotonTrackingBuffer(GGsize const &thread_index) const
get the buffer for photon tracking in dosimetry mode
Class providing tools storing and computing dose in phantom.
Class providing tools storing and computing dose in phantom.
cl::Buffer * GetSolidData(GGsize const &thread_index) const
get the informations about the solid geometry
GGEMSPseudoRandomGenerator * GetPseudoRandomGenerator(void) const
method returning the OpenCL stack on pseudo random numbers
void CheckOpenCLError(GGint const &error, std::string const &class_name, std::string const &method_name) const
check the OpenCL error
void SetDosimetryCalculator(GGEMSDosimetryCalculator *dosimetry_calculator)
give adress of dosimetry calculator to navigator
std::string output_basename_
virtual void CheckParameters(void) const
GGsize GetBestWorkItem(GGsize const &number_of_elements) const
get the best number of work item
cl::Event * GetEvent(GGsize const &thread_index) const
return an event to activated context
GGEMSNavigator(std::string const &navigator_name)
GGEMSNavigator constructor.
cl::Buffer * GetScatterHistogram(GGsize const &thread_index) const
return the point on scatter histogram
virtual ~GGEMSNavigator(void)
GGEMSNavigator destructor.
cl::Buffer * GetEdepSquaredBuffer(GGsize const &thread_index) const
get the buffer for edep squared in dosimetry mode
void SetThreshold(GGfloat const &threshold, std::string const &unit="keV")
Set the energy threshold to navigator.
cl::Kernel * GetKernelParticleSolidDistance(GGsize const &thread_index) const
get the pointer to kernel associated to a device
void SetNavigatorID(GGsize const &navigator_id)
set the navigator index
static GGEMSNavigatorManager & GetInstance(void)
Create at first time the Singleton.
cl::Buffer * GetEdepBuffer(GGsize const &thread_index) const
get the buffer for edep in dosimetry mode
void Initialize(void)
Initialize the materials for a navigator/phantom.
GGEMSParticles * GetParticles(void) const
method returning the OpenCL stack on particles
GGEMSDosimetryCalculator * dose_calculator_
void TrackThroughSolid(GGsize const &thread_index)
Move particle through solid.
virtual void PrintInfos(void) const =0
printing infos about solid
std::string GetRegisteredDataType(void) const
get the type of registered data
GGEMS class managing profiler data.
GGsize GetWorkGroupSize(void) const
Get the work group size defined in GGEMS on activated OpenCL context.
GGsize number_activated_devices_
cl::Buffer * GetLabelData(GGsize const &thread_index) const
get buffer to label buffer
void ComputeDose(GGsize const &thread_index)
Compute dose in volume.
cl::Buffer * GetHitTrackingBuffer(GGsize const &thread_index) const
get the buffer for hit tracking in dosimetry mode
std::string navigator_name_
cl::Kernel * GetKernelTrackThroughSolid(GGsize const &thread_index) const
get the pointer to kernel associated to a device
cl::Buffer * GetHistogram(GGsize const &thread_index) const
return the point on histogram
GGEMSMaterials * materials_
GGEMS class handling the source(s)
#define NAVIGATOR_NOT_INITIALIZED
void SetRotation(GGfloat const &rx, GGfloat const &ry, GGfloat const &rz, std::string const &unit="deg")
Set the rotation of the global navigator around global axis.
GGEMS class for voxelized solid.
#define GGendl
overload C++ std::endl
Singleton class storing all informations about OpenCL and managing GPU/CPU devices,...
void EnableTracking(void)
Enable tracking during simulation.
void Initialize(GGEMSMaterials const *materials)
Initialize all the activated processes computing tables on OpenCL device.
cl::Buffer * GetDoseParams(GGsize const &thread_index) const
get the buffer storing dosimetry params
T EnergyUnit(T const &value, std::string const &unit)
Choose best energy unit.
std::string GetDeviceName(GGsize const &device_index) const
Get the name of the activated device.
cl::Buffer * GetPseudoRandomNumbers(GGsize const &thread_index) const
return the pointer to OpenCL buffer storing random numbers
GGEMS class managing profiler data.
void PrintInfos(void) const
printing labels and materials infos
GGEMS class handling the source(s)
Class managing the random number in GGEMS.
void HandleEvent(cl::Event event, std::string const &profile_name)
handle an OpenCL event in profile_name type
GGsize GetIndexOfActivatedDevice(GGsize const &thread_index) const
get the index of activated device
GGEMSCrossSections * cross_sections_
void SetPosition(GGfloat const &position_x, GGfloat const &position_y, GGfloat const &position_z, std::string const &unit="mm")
set the position of the global navigator in X, Y and Z
void ProjectToSolid(GGsize const &thread_index)
Project particle to entry of closest solid.
cl::CommandQueue * GetCommandQueue(GGsize const &thread_index) const
Return the command queue to activated context.
void StoreOutput(std::string basename)
Storing the basename and format of the output file.
void ThrowException(std::string const &class_name, std::string const &method_name, std::string const &message)
Throw a C++ exception.
void ComputeDose(GGsize const &thread_index)
computing dose
T DistanceUnit(T const &value, std::string const &unit)
Choose best distance unit.
static GGEMSOpenCLManager & GetInstance(void)
Create at first time the Singleton.
cl::Buffer * GetPrimaryParticles(GGsize const &thread_index) const
return the pointer to OpenCL buffer storing particles