|
GGEMS
1.1
GPU GEant4-based Monte Carlo Simulations
|
Go to the documentation of this file.
41 : world_output_basename_(
"world")
43 GGcout(
"GGEMSWorld",
"GGEMSWorld", 3) <<
"GGEMSWorld creating..." <<
GGendl;
74 GGcout(
"GGEMSWorld",
"GGEMSWorld", 3) <<
"GGEMSWorld created!!!" <<
GGendl;
83 GGcout(
"GGEMSWorld",
"~GGEMSWorld", 3) <<
"GGEMSWorld erasing..." <<
GGendl;
147 GGcout(
"GGEMSWorld",
"~GGEMSWorld", 3) <<
"GGEMSWorld erased!!!" <<
GGendl;
165 GGcout(
"GGEMSWorld",
"CheckParameters", 3) <<
"Checking the mandatory parameters..." <<
GGendl;
169 std::ostringstream oss(std::ostringstream::out);
170 oss <<
"Dimensions of world have to be set";
176 std::ostringstream oss(std::ostringstream::out);
177 oss <<
"Size of elements in world";
255 GGcout(
"GGEMSWorld",
"InitializeKernel", 3) <<
"Initializing kernel for world tracking..." <<
GGendl;
264 std::string openCL_kernel_path = OPENCL_KERNEL_PATH;
265 std::string world_tracking_filename = openCL_kernel_path +
"/WorldTracking.cl";
277 GGcout(
"GGEMSWorld",
"Initialize", 3) <<
"Initializing a GGEMS world..." <<
GGendl;
321 cl::CommandQueue* queue = opencl_manager.
GetCommandQueue(thread_index);
322 cl::Event*
event = opencl_manager.
GetEvent(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;
340 cl::NDRange global_wi(number_of_work_items);
341 cl::NDRange local_wi(work_group_size);
392 GGint* photon_tracking =
new GGint[total_number_of_voxels];
393 std::memset(photon_tracking, 0, total_number_of_voxels*
sizeof(
GGint));
405 for (
GGsize i = 0; i < total_number_of_voxels; ++i) photon_tracking[i] = photon_tracking_device[i];
412 delete[] photon_tracking;
426 std::memset(edep_tracking, 0, total_number_of_voxels*
sizeof(
GGDosiType));
439 for (
GGsize i = 0; i < total_number_of_voxels; ++i) edep_tracking[i] = edep_device[i];
446 delete[] edep_tracking;
460 std::memset(edep_squared_tracking, 0, total_number_of_voxels*
sizeof(
GGDosiType));
473 for (
GGsize i = 0; i < total_number_of_voxels; ++i) edep_squared_tracking[i] = edep_squared_device[i];
480 delete[] edep_squared_tracking;
495 std::memset(momentum_x, 0, total_number_of_voxels*
sizeof(
GGDosiType));
498 std::memset(momentum_y, 0, total_number_of_voxels*
sizeof(
GGDosiType));
501 std::memset(momentum_z, 0, total_number_of_voxels*
sizeof(
GGDosiType));
528 for (
GGsize i = 0; i < total_number_of_voxels; ++i) momentum_x[i] = momentum_x_device[i];
541 for (
GGsize i = 0; i < total_number_of_voxels; ++i) momentum_y[i] = momentum_y_device[i];
554 for (
GGsize i = 0; i < total_number_of_voxels; ++i) momentum_z[i] = momentum_z_device[i];
579 world->
SetDimension(dimension_x, dimension_y, dimension_z);
void CheckParameters(void) const
check parameters for world volume
void SetEnergyTracking(bool const &is_activated)
activating energy tracking in world
static GGEMSSourceManager & GetInstance(void)
Create at first time the Singleton.
void SaveMomentum(void) const
save sum of momentum
void SaveEnergySquaredTracking(void) const
save energy squared tracking
I/O class handling MHD file.
void SavePhotonTracking(void) const
save photon tracking from world
GGEMS class handling the navigators (detector + phantom) in GGEMS.
GGsize GetNumberOfParticles(GGsize const &thread_index) const
Get the number of particles on activated device.
cl::Buffer ** momentum_y_
void SetMomentum(bool const &is_activated)
activating sum of momentum in world
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
void energy_tracking_ggems_world(GGEMSWorld *world, bool const is_activated)
storing results about energy tracking
cl::Buffer ** energy_tracking_
GGsize GetNumberOfActivatedDevice(void) const
get the number of activated devices
void SetDataType(std::string const &data_type)
set the type of data
static GGEMSProfilerManager & GetInstance(void)
Create at first time the Singleton.
std::string world_output_basename_
void CheckOpenCLError(GGint const &error, std::string const &class_name, std::string const &method_name) const
check the OpenCL error
void SetElementSizes(GGfloat3 const &element_sizes)
set the size of the elements
cl::Buffer ** photon_tracking_
GGsize GetBestWorkItem(GGsize const &number_of_elements) const
get the best number of work item
std::string tracking_kernel_option_
cl::Event * GetEvent(GGsize const &thread_index) const
return an event to activated context
void Deallocate(cl::Buffer *buffer, GGsize size, GGsize const &thread_index, std::string const &class_name="Undefined")
Deallocation of OpenCL memory.
void set_output_ggems_world(GGEMSWorld *world, char const *world_output_basename)
set output basename storing world tracking results
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...
static GGEMSNavigatorManager & GetInstance(void)
Create at first time the Singleton.
GGsize number_activated_devices_
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
void Write(cl::Buffer *image, GGsize const &thread_index) const
Write mhd header/raw file.
GGEMSParticles * GetParticles(void) const
method returning the OpenCL stack on particles
void SetOutputFileName(std::string const &basename)
set the output filename (*.mhd)
void SaveResults(void) const
save all results from world
void CleanBuffer(cl::Buffer *buffer, GGsize const &size, GGsize const &thread_index)
Cleaning buffer on OpenCL device.
GGEMSWorld(void)
GGEMSWorld constructor.
void energy_squared_tracking_ggems_world(GGEMSWorld *world, bool const is_activated)
storing results about energy squared tracking
GGEMS class managing profiler data.
GGsize GetWorkGroupSize(void) const
Get the work group size defined in GGEMS on activated OpenCL context.
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.
GGEMS class handling global world (space between navigators) in GGEMS.
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
void EnableTracking(void)
Enable tracking during simulation.
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.
~GGEMSWorld(void)
GGEMSWorld destructor.
void InitializeKernel(void)
Initialize kernel for world tracking.
void Tracking(GGsize const &thread_index)
track particles through world
GGEMS class handling the source(s)
void SetDimensions(GGsize3 const &dimensions)
set the dimensions of the image
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!...
#define GGendl
overload C++ std::endl
bool is_energy_squared_tracking_
void momentum_ggems_world(GGEMSWorld *world, bool const is_activated)
storing sum of momentum in world
void StoreWorld(GGEMSWorld *world)
storing the world pointer
Singleton class storing all informations about OpenCL and managing GPU/CPU devices,...
void SetPhotonTracking(bool const &is_activated)
activating photon tracking in world
void SetEnergySquaredTracking(bool const &is_activated)
activating energy squared tracking in world
GGEMSWorld * create_ggems_world(void)
Get the GGEMSWorld pointer for python user.
std::string GetDeviceName(GGsize const &device_index) const
Get the name of the activated device.
cl::Kernel ** kernel_world_tracking_
GGEMS class managing profiler data.
void photon_tracking_ggems_world(GGEMSWorld *world, bool const is_activated)
storing results about photon tracking
GGEMS class handling the source(s)
GGEMSWorldRecording world_recording_
void Initialize(void)
initialize and check parameters for world
void HandleEvent(cl::Event event, std::string const &profile_name)
handle an OpenCL event in profile_name type
void SaveEnergyTracking(void) const
save energy tracking
GGsize GetIndexOfActivatedDevice(GGsize const &thread_index) const
get the index of activated device
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
void SetOutputWorldBasename(std::string const &output_basename)
set output basename storing world tracking
I/O class handling MHD image file.
cl::CommandQueue * GetCommandQueue(GGsize const &thread_index) const
Return the command queue to activated context.
cl::Buffer ** momentum_z_
void ThrowException(std::string const &class_name, std::string const &method_name, std::string const &message)
Throw a C++ exception.
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 ** momentum_x_
cl::Buffer * GetPrimaryParticles(GGsize const &thread_index) const
return the pointer to OpenCL buffer storing particles
cl::Buffer ** energy_squared_tracking_