GGEMS  1.1
GPU GEant4-based Monte Carlo Simulations
GGEMSWorld.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 
35 
39 
41 : world_output_basename_("world")
42 {
43  GGcout("GGEMSWorld", "GGEMSWorld", 3) << "GGEMSWorld creating..." << GGendl;
44 
46 
47  dimensions_.x_= 0;
48  dimensions_.y_ = 0;
49  dimensions_.z_ = 0;
50 
51  sizes_.x = -1.0f;
52  sizes_.y = -1.0f;
53  sizes_.z = -1.0f;
54 
55  is_photon_tracking_ = false;
56  is_energy_tracking_ = false;
58  is_momentum_ = false;
59 
61 
62  // Get the number of activated device
65 
66  // Allocating buffer for each activated device
73 
74  GGcout("GGEMSWorld", "GGEMSWorld", 3) << "GGEMSWorld created!!!" << GGendl;
75 }
76 
80 
82 {
83  GGcout("GGEMSWorld", "~GGEMSWorld", 3) << "GGEMSWorld erasing..." << GGendl;
84 
86 
88  if (is_photon_tracking_) {
89  for (GGsize i = 0; i < number_activated_devices_; ++i) {
91  }
92  }
95  }
96 
98  if (is_energy_tracking_) {
99  for (GGsize i = 0; i < number_activated_devices_; ++i) {
101  }
102  }
105  }
106 
109  for (GGsize i = 0; i < number_activated_devices_; ++i) {
111  }
112  }
115  }
116 
118  if (is_momentum_) {
119  for (GGsize i = 0; i < number_activated_devices_; ++i) {
121  }
122  }
123  delete[] world_recording_.momentum_x_;
124  world_recording_.momentum_x_ = nullptr;
125  }
126 
128  if (is_momentum_) {
129  for (GGsize i = 0; i < number_activated_devices_; ++i) {
131  }
132  }
133  delete[] world_recording_.momentum_y_;
134  world_recording_.momentum_y_ = nullptr;
135  }
136 
138  if (is_momentum_) {
139  for (GGsize i = 0; i < number_activated_devices_; ++i) {
141  }
142  }
143  delete[] world_recording_.momentum_z_;
144  world_recording_.momentum_z_ = nullptr;
145  }
146 
147  GGcout("GGEMSWorld", "~GGEMSWorld", 3) << "GGEMSWorld erased!!!" << GGendl;
148 }
149 
153 
154 void GGEMSWorld::SetOutputWorldBasename(std::string const& output_basename)
155 {
156  world_output_basename_ = output_basename;
157 }
158 
162 
164 {
165  GGcout("GGEMSWorld", "CheckParameters", 3) << "Checking the mandatory parameters..." << GGendl;
166 
167  // Checking world dimensions
168  if (dimensions_.x_ == 0 || dimensions_.y_ == 0 || dimensions_.z_ == 0) {
169  std::ostringstream oss(std::ostringstream::out);
170  oss << "Dimensions of world have to be set";
171  GGEMSMisc::ThrowException("GGEMSWorld", "CheckParameters", oss.str());
172  }
173 
174  // Checking elements size in world
175  if (sizes_.x < 0.0 || sizes_.y < 0.0 || sizes_.z < 0.0) {
176  std::ostringstream oss(std::ostringstream::out);
177  oss << "Size of elements in world";
178  GGEMSMisc::ThrowException("GGEMSWorld", "CheckParameters", oss.str());
179  }
180 }
181 
185 
186 void GGEMSWorld::SetDimension(GGsize const& dimension_x, GGsize const& dimension_y, GGsize const& dimension_z)
187 {
188  dimensions_.x_ = dimension_x;
189  dimensions_.y_ = dimension_y;
190  dimensions_.z_ = dimension_z;
191 }
192 
196 
197 void GGEMSWorld::SetElementSize(GGfloat const& size_x, GGfloat const& size_y, GGfloat const& size_z, std::string const& unit)
198 {
199  sizes_.x = DistanceUnit(size_x, unit);
200  sizes_.y = DistanceUnit(size_y, unit);
201  sizes_.z = DistanceUnit(size_z, unit);
202 }
203 
207 
208 void GGEMSWorld::SetPhotonTracking(bool const& is_activated)
209 {
210  is_photon_tracking_ = is_activated;
211 }
212 
216 
217 void GGEMSWorld::SetEnergyTracking(bool const& is_activated)
218 {
219  is_energy_tracking_ = is_activated;
220 }
221 
225 
226 void GGEMSWorld::SetEnergySquaredTracking(bool const& is_activated)
227 {
228  is_energy_squared_tracking_ = is_activated;
229 }
230 
234 
235 void GGEMSWorld::SetMomentum(bool const& is_activated)
236 {
237  is_momentum_ = is_activated;
238 }
239 
243 
245 {
246  tracking_kernel_option_ = " -DGGEMS_TRACKING";
247 }
248 
252 
254 {
255  GGcout("GGEMSWorld", "InitializeKernel", 3) << "Initializing kernel for world tracking..." << GGendl;
256 
257  // Getting OpenCL manager
259 
260  // Storing a kernel for each device
262 
263  // Getting the path to kernel
264  std::string openCL_kernel_path = OPENCL_KERNEL_PATH;
265  std::string world_tracking_filename = openCL_kernel_path + "/WorldTracking.cl";
266 
267  // Compiling the kernels
268  opencl_manager.CompileKernel(world_tracking_filename, "world_tracking", kernel_world_tracking_, nullptr, const_cast<char*>(tracking_kernel_option_.c_str()));
269 }
270 
274 
276 {
277  GGcout("GGEMSWorld", "Initialize", 3) << "Initializing a GGEMS world..." << GGendl;
278 
279  // Checking the parameters of world
280  CheckParameters();
281 
282  // Getting OpenCL manager
284 
285  // Initializing OpenCL buffers
286  GGsize total_number_voxel_world = dimensions_.x_ * dimensions_.y_ * dimensions_.z_;
287 
288  // Loop over the activated device
289  for (GGsize j = 0; j < number_activated_devices_; ++j) {
290  world_recording_.photon_tracking_[j] = is_photon_tracking_ ? opencl_manager.Allocate(nullptr, total_number_voxel_world * sizeof(GGint), j, CL_MEM_READ_WRITE, "GGEMSWorld") : nullptr;
291  if (is_photon_tracking_) opencl_manager.CleanBuffer(world_recording_.photon_tracking_[j], total_number_voxel_world * sizeof(GGint), j);
292 
293  world_recording_.energy_tracking_[j] = is_energy_tracking_ ? opencl_manager.Allocate(nullptr, total_number_voxel_world*sizeof(GGDosiType), j, CL_MEM_READ_WRITE, "GGEMSWorld") : nullptr;
294  if (is_energy_tracking_) opencl_manager.CleanBuffer(world_recording_.energy_tracking_[j], total_number_voxel_world*sizeof(GGDosiType), j);
295 
296  world_recording_.energy_squared_tracking_[j] = is_energy_squared_tracking_ ? opencl_manager.Allocate(nullptr, total_number_voxel_world*sizeof(GGDosiType), j, CL_MEM_READ_WRITE, "GGEMSWorld") : nullptr;
297  if (is_energy_squared_tracking_) opencl_manager.CleanBuffer(world_recording_.energy_squared_tracking_[j], total_number_voxel_world*sizeof(GGDosiType), j);
298 
299  world_recording_.momentum_x_[j] = is_momentum_ ? opencl_manager.Allocate(nullptr, total_number_voxel_world*sizeof(GGDosiType), j, CL_MEM_READ_WRITE, "GGEMSWorld") : nullptr;
300  if (is_momentum_) opencl_manager.CleanBuffer(world_recording_.momentum_x_[j], total_number_voxel_world*sizeof(GGDosiType), j);
301 
302  world_recording_.momentum_y_[j] = is_momentum_ ? opencl_manager.Allocate(nullptr, total_number_voxel_world*sizeof(GGDosiType), j, CL_MEM_READ_WRITE, "GGEMSWorld") : nullptr;
303  if (is_momentum_) opencl_manager.CleanBuffer(world_recording_.momentum_y_[j], total_number_voxel_world*sizeof(GGDosiType), j);
304 
305  world_recording_.momentum_z_[j] = is_momentum_ ? opencl_manager.Allocate(nullptr, total_number_voxel_world*sizeof(GGDosiType), j, CL_MEM_READ_WRITE, "GGEMSWorld") : nullptr;
306  if (is_momentum_) opencl_manager.CleanBuffer(world_recording_.momentum_z_[j], total_number_voxel_world*sizeof(GGDosiType), j);
307  }
308 
309  // Initialize OpenCL kernel tracking particles in world
311 }
312 
316 
317 void GGEMSWorld::Tracking(GGsize const& thread_index)
318 {
319  // Getting the OpenCL manager and infos for work-item launching
321  cl::CommandQueue* queue = opencl_manager.GetCommandQueue(thread_index);
322  cl::Event* event = opencl_manager.GetEvent(thread_index);
323 
324  // Get Device name and storing methode name + device
325  GGsize device_index = opencl_manager.GetIndexOfActivatedDevice(thread_index);
326  std::string device_name = opencl_manager.GetDeviceName(device_index);
327  std::ostringstream oss(std::ostringstream::out);
328  oss << "GGEMSWorld::Tracking in " << device_name << ", index " << device_index;
329 
330  // Pointer to primary particles, and number to particles in buffer
332  cl::Buffer* primary_particles = source_manager.GetParticles()->GetPrimaryParticles(thread_index);
333  GGsize number_of_particles = source_manager.GetParticles()->GetNumberOfParticles(thread_index);
334 
335  // Getting work group size, and work-item number
336  GGsize work_group_size = opencl_manager.GetWorkGroupSize();
337  GGsize number_of_work_items = opencl_manager.GetBestWorkItem(number_of_particles);
338 
339  // Parameters for work-item in kernel
340  cl::NDRange global_wi(number_of_work_items);
341  cl::NDRange local_wi(work_group_size);
342 
343  // Getting kernel, and setting parameters
344  kernel_world_tracking_[thread_index]->setArg(0, number_of_particles);
345  kernel_world_tracking_[thread_index]->setArg(0, number_of_particles);
346  kernel_world_tracking_[thread_index]->setArg(1, *primary_particles);
347  kernel_world_tracking_[thread_index]->setArg(2, *world_recording_.photon_tracking_[thread_index]);
348  kernel_world_tracking_[thread_index]->setArg(3, *world_recording_.energy_tracking_[thread_index]);
349  kernel_world_tracking_[thread_index]->setArg(4, *world_recording_.energy_squared_tracking_[thread_index]);
350  kernel_world_tracking_[thread_index]->setArg(5, *world_recording_.momentum_x_[thread_index]);
351  kernel_world_tracking_[thread_index]->setArg(6, *world_recording_.momentum_y_[thread_index]);
352  kernel_world_tracking_[thread_index]->setArg(7, *world_recording_.momentum_z_[thread_index]);
353  kernel_world_tracking_[thread_index]->setArg(8, dimensions_.x_);
354  kernel_world_tracking_[thread_index]->setArg(9, dimensions_.y_);
355  kernel_world_tracking_[thread_index]->setArg(10, dimensions_.z_);
356  kernel_world_tracking_[thread_index]->setArg(11, sizes_.x);
357  kernel_world_tracking_[thread_index]->setArg(12, sizes_.y);
358  kernel_world_tracking_[thread_index]->setArg(13, sizes_.z);
359 
360  // Launching kernel
361  GGint kernel_status = queue->enqueueNDRangeKernel(*kernel_world_tracking_[thread_index], 0, global_wi, local_wi, nullptr, event);
362  opencl_manager.CheckOpenCLError(kernel_status, "GGEMSWorld", "Tracking");
363 
364  // GGEMS Profiling
366  profiler_manager.HandleEvent(*event, oss.str());
367  queue->finish();
368 }
369 
373 
374 void GGEMSWorld::SaveResults(void) const
375 {
379  if (is_momentum_) SaveMomentum();
380 }
381 
385 
387 {
388  // Get the OpenCL manager
390 
391  GGsize total_number_of_voxels = dimensions_.x_ * dimensions_.y_ * dimensions_.z_;
392  GGint* photon_tracking = new GGint[total_number_of_voxels];
393  std::memset(photon_tracking, 0, total_number_of_voxels*sizeof(GGint));
394 
395  GGEMSMHDImage mhdImage;
396  mhdImage.SetOutputFileName(world_output_basename_ + "_world_photon_tracking.mhd");
397  mhdImage.SetDataType("MET_INT");
398  mhdImage.SetDimensions(dimensions_);
399  mhdImage.SetElementSizes(sizes_);
400 
401  // Loop over all activated device
402  for (GGsize j = 0; j < number_activated_devices_; ++j) {
403  GGint* photon_tracking_device = opencl_manager.GetDeviceBuffer<GGint>(world_recording_.photon_tracking_[j], total_number_of_voxels*sizeof(GGint), j);
404 
405  for (GGsize i = 0; i < total_number_of_voxels; ++i) photon_tracking[i] = photon_tracking_device[i];
406 
407  opencl_manager.ReleaseDeviceBuffer(world_recording_.photon_tracking_[j], photon_tracking_device, j);
408  }
409 
410  // Writing data
411  mhdImage.Write<GGint>(photon_tracking);
412  delete[] photon_tracking;
413 }
414 
418 
420 {
421  // Get the OpenCL manager
423 
424  GGsize total_number_of_voxels = dimensions_.x_ * dimensions_.y_ * dimensions_.z_;
425  GGDosiType* edep_tracking = new GGDosiType[total_number_of_voxels];
426  std::memset(edep_tracking, 0, total_number_of_voxels*sizeof(GGDosiType));
427 
428  GGEMSMHDImage mhdImage;
429  mhdImage.SetOutputFileName(world_output_basename_ + "_world_edep.mhd");
430  if (sizeof(GGDosiType) == 4) mhdImage.SetDataType("MET_FLOAT");
431  else if (sizeof(GGDosiType) == 8) mhdImage.SetDataType("MET_DOUBLE");
432  mhdImage.SetDimensions(dimensions_);
433  mhdImage.SetElementSizes(sizes_);
434 
435  // Loop over all activated device
436  for (GGsize j = 0; j < number_activated_devices_; ++j) {
437  GGDosiType* edep_device = opencl_manager.GetDeviceBuffer<GGDosiType>(world_recording_.energy_tracking_[j], total_number_of_voxels*sizeof(GGDosiType), j);
438 
439  for (GGsize i = 0; i < total_number_of_voxels; ++i) edep_tracking[i] = edep_device[i];
440 
441  opencl_manager.ReleaseDeviceBuffer(world_recording_.energy_tracking_[j], edep_device, j);
442  }
443 
444  // Writing data
445  mhdImage.Write<GGDosiType>(edep_tracking);
446  delete[] edep_tracking;
447 }
448 
452 
454 {
455  // Get the OpenCL manager
457 
458  GGsize total_number_of_voxels = dimensions_.x_ * dimensions_.y_ * dimensions_.z_;
459  GGDosiType* edep_squared_tracking = new GGDosiType[total_number_of_voxels];
460  std::memset(edep_squared_tracking, 0, total_number_of_voxels*sizeof(GGDosiType));
461 
462  GGEMSMHDImage mhdImage;
463  mhdImage.SetOutputFileName(world_output_basename_ + "_world_edep_squared.mhd");
464  if (sizeof(GGDosiType) == 4) mhdImage.SetDataType("MET_FLOAT");
465  else if (sizeof(GGDosiType) == 8) mhdImage.SetDataType("MET_DOUBLE");
466  mhdImage.SetDimensions(dimensions_);
467  mhdImage.SetElementSizes(sizes_);
468 
469  // Loop over all activated device
470  for (GGsize j = 0; j < number_activated_devices_; ++j) {
471  GGDosiType* edep_squared_device = opencl_manager.GetDeviceBuffer<GGDosiType>(world_recording_.energy_squared_tracking_[j], total_number_of_voxels*sizeof(GGDosiType), j);
472 
473  for (GGsize i = 0; i < total_number_of_voxels; ++i) edep_squared_tracking[i] = edep_squared_device[i];
474 
475  opencl_manager.ReleaseDeviceBuffer(world_recording_.energy_squared_tracking_[j], edep_squared_device, j);
476  }
477 
478  // Writing data
479  mhdImage.Write<GGDosiType>(edep_squared_tracking);
480  delete[] edep_squared_tracking;
481 }
482 
486 
487 void GGEMSWorld::SaveMomentum(void) const
488 {
489  // Get the OpenCL manager
491 
492  GGsize total_number_of_voxels = dimensions_.x_ * dimensions_.y_ * dimensions_.z_;
493 
494  GGDosiType* momentum_x = new GGDosiType[total_number_of_voxels];
495  std::memset(momentum_x, 0, total_number_of_voxels*sizeof(GGDosiType));
496 
497  GGDosiType* momentum_y = new GGDosiType[total_number_of_voxels];
498  std::memset(momentum_y, 0, total_number_of_voxels*sizeof(GGDosiType));
499 
500  GGDosiType* momentum_z = new GGDosiType[total_number_of_voxels];
501  std::memset(momentum_z, 0, total_number_of_voxels*sizeof(GGDosiType));
502 
503  GGEMSMHDImage mhdImage_momentum_x;
504  mhdImage_momentum_x.SetOutputFileName(world_output_basename_ + "_world_momentum_x.mhd");
505  if (sizeof(GGDosiType) == 4) mhdImage_momentum_x.SetDataType("MET_FLOAT");
506  else if (sizeof(GGDosiType) == 8) mhdImage_momentum_x.SetDataType("MET_DOUBLE");
507  mhdImage_momentum_x.SetDimensions(dimensions_);
508  mhdImage_momentum_x.SetElementSizes(sizes_);
509 
510  GGEMSMHDImage mhdImage_momentum_y;
511  mhdImage_momentum_y.SetOutputFileName(world_output_basename_ + "_world_momentum_y.mhd");
512  if (sizeof(GGDosiType) == 4) mhdImage_momentum_y.SetDataType("MET_FLOAT");
513  else if (sizeof(GGDosiType) == 8) mhdImage_momentum_y.SetDataType("MET_DOUBLE");
514  mhdImage_momentum_y.SetDimensions(dimensions_);
515  mhdImage_momentum_y.SetElementSizes(sizes_);
516 
517  GGEMSMHDImage mhdImage_momentum_z;
518  mhdImage_momentum_z.SetOutputFileName(world_output_basename_ + "_world_momentum_z.mhd");
519  if (sizeof(GGDosiType) == 4) mhdImage_momentum_z.SetDataType("MET_FLOAT");
520  else if (sizeof(GGDosiType) == 8) mhdImage_momentum_z.SetDataType("MET_DOUBLE");
521  mhdImage_momentum_z.SetDimensions(dimensions_);
522  mhdImage_momentum_z.SetElementSizes(sizes_);
523 
524  // Loop over all activated device
525  for (GGsize j = 0; j < number_activated_devices_; ++j) {
526  GGDosiType* momentum_x_device = opencl_manager.GetDeviceBuffer<GGDosiType>(world_recording_.momentum_x_[j], total_number_of_voxels*sizeof(GGDosiType), j);
527 
528  for (GGsize i = 0; i < total_number_of_voxels; ++i) momentum_x[i] = momentum_x_device[i];
529 
530  opencl_manager.ReleaseDeviceBuffer(world_recording_.momentum_x_[j], momentum_x_device, j);
531  }
532 
533  // Writing data
534  mhdImage_momentum_x.Write<GGDosiType>(momentum_x);
535  delete[] momentum_x;
536 
537  // Loop over all activated device
538  for (GGsize j = 0; j < number_activated_devices_; ++j) {
539  GGDosiType* momentum_y_device = opencl_manager.GetDeviceBuffer<GGDosiType>(world_recording_.momentum_y_[j], total_number_of_voxels*sizeof(GGDosiType), j);
540 
541  for (GGsize i = 0; i < total_number_of_voxels; ++i) momentum_y[i] = momentum_y_device[i];
542 
543  opencl_manager.ReleaseDeviceBuffer(world_recording_.momentum_y_[j], momentum_y_device, j);
544  }
545 
546  // Writing data
547  mhdImage_momentum_y.Write<GGDosiType>(momentum_y);
548  delete[] momentum_y;
549 
550  // Loop over all activated device
551  for (GGsize j = 0; j < number_activated_devices_; ++j) {
552  GGDosiType* momentum_z_device = opencl_manager.GetDeviceBuffer<GGDosiType>(world_recording_.momentum_z_[j], total_number_of_voxels*sizeof(GGDosiType), j);
553 
554  for (GGsize i = 0; i < total_number_of_voxels; ++i) momentum_z[i] = momentum_z_device[i];
555 
556  opencl_manager.ReleaseDeviceBuffer(world_recording_.momentum_z_[j], momentum_z_device, j);
557  }
558 
559  // Writing data
560  mhdImage_momentum_z.Write<GGDosiType>(momentum_z);
561  delete[] momentum_z;
562 }
563 
567 
569 {
570  return new(std::nothrow) GGEMSWorld();
571 }
572 
576 
577 void set_dimension_ggems_world(GGEMSWorld* world, GGsize const dimension_x, GGsize const dimension_y, GGsize const dimension_z)
578 {
579  world->SetDimension(dimension_x, dimension_y, dimension_z);
580 }
581 
585 
586 void set_size_ggems_world(GGEMSWorld* world, GGfloat const size_x, GGfloat const size_y, GGfloat const size_z, char const* unit)
587 {
588  world->SetElementSize(size_x, size_y, size_z, unit);
589 }
590 
594 
595 void photon_tracking_ggems_world(GGEMSWorld* world, bool const is_activated)
596 {
597  world->SetPhotonTracking(is_activated);
598 }
599 
603 
604 void set_output_ggems_world(GGEMSWorld* world, char const* world_output_basename)
605 {
606  world->SetOutputWorldBasename(world_output_basename);
607 }
608 
612 
613 void energy_tracking_ggems_world(GGEMSWorld* world, bool const is_activated)
614 {
615  world->SetEnergyTracking(is_activated);
616 }
617 
621 
622 void energy_squared_tracking_ggems_world(GGEMSWorld* world, bool const is_activated)
623 {
624  world->SetEnergySquaredTracking(is_activated);
625 }
626 
630 
631 void momentum_ggems_world(GGEMSWorld* world, bool const is_activated)
632 {
633  world->SetMomentum(is_activated);
634 }
GGEMSWorld::CheckParameters
void CheckParameters(void) const
check parameters for world volume
Definition: GGEMSWorld.cc:163
GGEMSWorld::SetEnergyTracking
void SetEnergyTracking(bool const &is_activated)
activating energy tracking in world
Definition: GGEMSWorld.cc:217
GGEMSSourceManager::GetInstance
static GGEMSSourceManager & GetInstance(void)
Create at first time the Singleton.
Definition: GGEMSSourceManager.hh:67
GGEMSWorld::SaveMomentum
void SaveMomentum(void) const
save sum of momentum
Definition: GGEMSWorld.cc:487
GGEMSWorld::is_energy_tracking_
bool is_energy_tracking_
Definition: GGEMSWorld.hh:217
GGEMSWorld::SaveEnergySquaredTracking
void SaveEnergySquaredTracking(void) const
save energy squared tracking
Definition: GGEMSWorld.cc:453
GGEMSMHDImage
I/O class handling MHD file.
Definition: GGEMSMHDImage.hh:47
GGEMSWorld::SavePhotonTracking
void SavePhotonTracking(void) const
save photon tracking from world
Definition: GGEMSWorld.cc:386
GGEMSNavigatorManager.hh
GGEMS class handling the navigators (detector + phantom) in GGEMS.
GGEMSParticles::GetNumberOfParticles
GGsize GetNumberOfParticles(GGsize const &thread_index) const
Get the number of particles on activated device.
Definition: GGEMSParticles.hh:116
GGDosiType
#define GGDosiType
Definition: GGEMSTypes.hh:290
GGEMSWorldRecording_t::momentum_y_
cl::Buffer ** momentum_y_
Definition: GGEMSWorld.hh:47
GGEMSWorld::SetMomentum
void SetMomentum(bool const &is_activated)
activating sum of momentum in world
Definition: GGEMSWorld.cc:235
GGEMSWorld::SetDimension
void SetDimension(GGsize const &dimension_x, GGsize const &dimension_y, GGsize const &dimension_z)
set the dimension of the world in X, Y and Z
Definition: GGEMSWorld.cc:186
energy_tracking_ggems_world
void energy_tracking_ggems_world(GGEMSWorld *world, bool const is_activated)
storing results about energy tracking
Definition: GGEMSWorld.cc:613
GGEMSWorldRecording_t::energy_tracking_
cl::Buffer ** energy_tracking_
Definition: GGEMSWorld.hh:43
GGEMSOpenCLManager::GetNumberOfActivatedDevice
GGsize GetNumberOfActivatedDevice(void) const
get the number of activated devices
Definition: GGEMSOpenCLManager.hh:167
GGEMSMHDImage::SetDataType
void SetDataType(std::string const &data_type)
set the type of data
Definition: GGEMSMHDImage.cc:111
GGEMSProfilerManager::GetInstance
static GGEMSProfilerManager & GetInstance(void)
Create at first time the Singleton.
Definition: GGEMSProfilerManager.hh:66
GGEMSWorld::world_output_basename_
std::string world_output_basename_
Definition: GGEMSWorld.hh:213
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
GGEMSMHDImage::SetElementSizes
void SetElementSizes(GGfloat3 const &element_sizes)
set the size of the elements
Definition: GGEMSMHDImage.cc:102
GGEMSWorldRecording_t::photon_tracking_
cl::Buffer ** photon_tracking_
Definition: GGEMSWorld.hh:45
GGEMSOpenCLManager::GetBestWorkItem
GGsize GetBestWorkItem(GGsize const &number_of_elements) const
get the best number of work item
Definition: GGEMSOpenCLManager.cc:1030
GGEMSWorld::tracking_kernel_option_
std::string tracking_kernel_option_
Definition: GGEMSWorld.hh:220
GGEMSOpenCLManager::GetEvent
cl::Event * GetEvent(GGsize const &thread_index) const
return an event to activated context
Definition: GGEMSOpenCLManager.hh:230
GGEMSOpenCLManager::Deallocate
void Deallocate(cl::Buffer *buffer, GGsize size, GGsize const &thread_index, std::string const &class_name="Undefined")
Deallocation of OpenCL memory.
Definition: GGEMSOpenCLManager.cc:981
set_output_ggems_world
void set_output_ggems_world(GGEMSWorld *world, char const *world_output_basename)
set output basename storing world tracking results
Definition: GGEMSWorld.cc:604
GGEMSOpenCLManager::ReleaseDeviceBuffer
void ReleaseDeviceBuffer(cl::Buffer *const device_ptr, T *host_ptr, GGsize const &thread_index)
Get the device pointer on host to write on it. Mandatory after a GetDeviceBufferWrite ou GetDeviceBuf...
Definition: GGEMSOpenCLManager.hh:495
GGEMSWorld::dimensions_
GGsize3 dimensions_
Definition: GGEMSWorld.hh:214
GGEMSNavigatorManager::GetInstance
static GGEMSNavigatorManager & GetInstance(void)
Create at first time the Singleton.
Definition: GGEMSNavigatorManager.hh:60
GGEMSWorld::number_activated_devices_
GGsize number_activated_devices_
Definition: GGEMSWorld.hh:223
GGEMSWorld::is_photon_tracking_
bool is_photon_tracking_
Definition: GGEMSWorld.hh:216
GGsize
#define GGsize
Definition: GGEMSTypes.hh:252
set_size_ggems_world
void set_size_ggems_world(GGEMSWorld *world, GGfloat const size_x, GGfloat const size_y, GGfloat const size_z, char const *unit)
set the element sizes of the world
Definition: GGEMSWorld.cc:586
GGEMSMHDImage::Write
void Write(cl::Buffer *image, GGsize const &thread_index) const
Write mhd header/raw file.
Definition: GGEMSMHDImage.cc:223
GGint
#define GGint
Definition: GGEMSTypes.hh:224
GGEMSSourceManager::GetParticles
GGEMSParticles * GetParticles(void) const
method returning the OpenCL stack on particles
Definition: GGEMSSourceManager.hh:162
GGEMSMHDImage::SetOutputFileName
void SetOutputFileName(std::string const &basename)
set the output filename (*.mhd)
Definition: GGEMSMHDImage.cc:77
GGEMSWorld::SaveResults
void SaveResults(void) const
save all results from world
Definition: GGEMSWorld.cc:374
GGEMSOpenCLManager::CleanBuffer
void CleanBuffer(cl::Buffer *buffer, GGsize const &size, GGsize const &thread_index)
Cleaning buffer on OpenCL device.
Definition: GGEMSOpenCLManager.cc:998
GGEMSWorld::GGEMSWorld
GGEMSWorld(void)
GGEMSWorld constructor.
Definition: GGEMSWorld.cc:40
energy_squared_tracking_ggems_world
void energy_squared_tracking_ggems_world(GGEMSWorld *world, bool const is_activated)
storing results about energy squared tracking
Definition: GGEMSWorld.cc:622
GGEMSProfilerManager
GGEMS class managing profiler data.
Definition: GGEMSProfilerManager.hh:48
GGsize3_t::z_
GGsize z_
Definition: GGEMSTypes.hh:270
GGEMSOpenCLManager::GetWorkGroupSize
GGsize GetWorkGroupSize(void) const
Get the work group size defined in GGEMS on activated OpenCL context.
Definition: GGEMSOpenCLManager.hh:198
GGEMSOpenCLManager::Allocate
cl::Buffer * Allocate(void *host_ptr, GGsize const &size, GGsize const &thread_index, cl_mem_flags flags, std::string const &class_name="Undefined")
Allocation of OpenCL memory.
Definition: GGEMSOpenCLManager.cc:945
GGEMSWorld
GGEMS class handling global world (space between navigators) in GGEMS.
Definition: GGEMSWorld.hh:56
GGEMSWorld::SetElementSize
void SetElementSize(GGfloat const &size_x, GGfloat const &size_y, GGfloat const &size_z, std::string const &unit="mm")
set the size of elements of the world in X, Y and Z
Definition: GGEMSWorld.cc:197
GGEMSWorld::sizes_
GGfloat3 sizes_
Definition: GGEMSWorld.hh:215
GGEMSWorld::EnableTracking
void EnableTracking(void)
Enable tracking during simulation.
Definition: GGEMSWorld.cc:244
GGEMSOpenCLManager::CompileKernel
void CompileKernel(std::string const &kernel_filename, std::string const &kernel_name, cl::Kernel **kernel_list, char *const custom_options=nullptr, char *const additional_options=nullptr)
Compile the OpenCL kernel on the activated device.
Definition: GGEMSOpenCLManager.cc:849
GGEMSWorld::~GGEMSWorld
~GGEMSWorld(void)
GGEMSWorld destructor.
Definition: GGEMSWorld.cc:81
GGcout
GGEMSStream GGcout
Definition: GGEMSPrint.cc:34
GGEMSWorld::InitializeKernel
void InitializeKernel(void)
Initialize kernel for world tracking.
Definition: GGEMSWorld.cc:253
GGEMSWorld::Tracking
void Tracking(GGsize const &thread_index)
track particles through world
Definition: GGEMSWorld.cc:317
GGEMSSourceManager.hh
GGEMS class handling the source(s)
GGEMSMHDImage::SetDimensions
void SetDimensions(GGsize3 const &dimensions)
set the dimensions of the image
Definition: GGEMSMHDImage.cc:120
GGEMSWorld::is_momentum_
bool is_momentum_
Definition: GGEMSWorld.hh:219
GGsize3_t::x_
GGsize x_
Definition: GGEMSTypes.hh:268
GGEMSOpenCLManager::GetDeviceBuffer
T * GetDeviceBuffer(cl::Buffer *device_ptr, GGsize const &size, GGsize const &thread_index)
Get the device pointer on host to write on it. ReleaseDeviceBuffer must be used after this method!...
Definition: GGEMSOpenCLManager.hh:480
GGendl
#define GGendl
overload C++ std::endl
Definition: GGEMSPrint.hh:60
GGEMSWorld::is_energy_squared_tracking_
bool is_energy_squared_tracking_
Definition: GGEMSWorld.hh:218
momentum_ggems_world
void momentum_ggems_world(GGEMSWorld *world, bool const is_activated)
storing sum of momentum in world
Definition: GGEMSWorld.cc:631
GGEMSNavigatorManager::StoreWorld
void StoreWorld(GGEMSWorld *world)
storing the world pointer
Definition: GGEMSNavigatorManager.cc:110
GGEMSOpenCLManager
Singleton class storing all informations about OpenCL and managing GPU/CPU devices,...
Definition: GGEMSOpenCLManager.hh:54
GGEMSWorld::SetPhotonTracking
void SetPhotonTracking(bool const &is_activated)
activating photon tracking in world
Definition: GGEMSWorld.cc:208
GGEMSWorld::SetEnergySquaredTracking
void SetEnergySquaredTracking(bool const &is_activated)
activating energy squared tracking in world
Definition: GGEMSWorld.cc:226
create_ggems_world
GGEMSWorld * create_ggems_world(void)
Get the GGEMSWorld pointer for python user.
Definition: GGEMSWorld.cc:568
GGEMSOpenCLManager::GetDeviceName
std::string GetDeviceName(GGsize const &device_index) const
Get the name of the activated device.
Definition: GGEMSOpenCLManager.hh:145
GGEMSWorld::kernel_world_tracking_
cl::Kernel ** kernel_world_tracking_
Definition: GGEMSWorld.hh:222
GGEMSProfilerManager.hh
GGEMS class managing profiler data.
photon_tracking_ggems_world
void photon_tracking_ggems_world(GGEMSWorld *world, bool const is_activated)
storing results about photon tracking
Definition: GGEMSWorld.cc:595
GGEMSSourceManager
GGEMS class handling the source(s)
Definition: GGEMSSourceManager.hh:49
GGEMSWorld::world_recording_
GGEMSWorldRecording world_recording_
Definition: GGEMSWorld.hh:221
GGEMSWorld::Initialize
void Initialize(void)
initialize and check parameters for world
Definition: GGEMSWorld.cc:275
GGEMSProfilerManager::HandleEvent
void HandleEvent(cl::Event event, std::string const &profile_name)
handle an OpenCL event in profile_name type
Definition: GGEMSProfilerManager.cc:75
GGEMSWorld::SaveEnergyTracking
void SaveEnergyTracking(void) const
save energy tracking
Definition: GGEMSWorld.cc:419
GGEMSOpenCLManager::GetIndexOfActivatedDevice
GGsize GetIndexOfActivatedDevice(GGsize const &thread_index) const
get the index of activated device
Definition: GGEMSOpenCLManager.hh:175
set_dimension_ggems_world
void set_dimension_ggems_world(GGEMSWorld *world, GGsize const dimension_x, GGsize const dimension_y, GGsize const dimension_z)
set the dimenstions of the world in X, Y and Z
Definition: GGEMSWorld.cc:577
GGEMSWorld::SetOutputWorldBasename
void SetOutputWorldBasename(std::string const &output_basename)
set output basename storing world tracking
Definition: GGEMSWorld.cc:154
GGEMSMHDImage.hh
I/O class handling MHD image file.
GGEMSOpenCLManager::GetCommandQueue
cl::CommandQueue * GetCommandQueue(GGsize const &thread_index) const
Return the command queue to activated context.
Definition: GGEMSOpenCLManager.hh:222
GGEMSWorldRecording_t::momentum_z_
cl::Buffer ** momentum_z_
Definition: GGEMSWorld.hh:48
GGEMSMisc::ThrowException
void ThrowException(std::string const &class_name, std::string const &method_name, std::string const &message)
Throw a C++ exception.
Definition: GGEMSTools.cc:61
DistanceUnit
T DistanceUnit(T const &value, std::string const &unit)
Choose best distance unit.
Definition: GGEMSSystemOfUnits.hh:243
GGfloat
#define GGfloat
Definition: GGEMSTypes.hh:273
GGEMSOpenCLManager::GetInstance
static GGEMSOpenCLManager & GetInstance(void)
Create at first time the Singleton.
Definition: GGEMSOpenCLManager.hh:72
GGEMSWorldRecording_t::momentum_x_
cl::Buffer ** momentum_x_
Definition: GGEMSWorld.hh:46
GGsize3_t::y_
GGsize y_
Definition: GGEMSTypes.hh:269
GGEMSParticles::GetPrimaryParticles
cl::Buffer * GetPrimaryParticles(GGsize const &thread_index) const
return the pointer to OpenCL buffer storing particles
Definition: GGEMSParticles.hh:100
GGEMSWorldRecording_t::energy_squared_tracking_
cl::Buffer ** energy_squared_tracking_
Definition: GGEMSWorld.hh:44