|
GGEMS
1.1
GPU GEant4-based Monte Carlo Simulations
|
Go to the documentation of this file.
41 : number_of_particles_(nullptr),
42 primary_particles_(nullptr),
43 kernel_alive_(nullptr)
45 GGcout(
"GGEMSParticles",
"GGEMSParticles", 3) <<
"GGEMSParticles creating..." <<
GGendl;
47 GGcout(
"GGEMSParticles",
"GGEMSParticles", 3) <<
"GGEMSParticles created!!!" <<
GGendl;
56 GGcout(
"GGEMSParticles",
"~GGEMSParticles", 3) <<
"GGEMSParticles erasing..." <<
GGendl;
81 GGcout(
"GGEMSParticles",
"~GGEMSParticles", 3) <<
"GGEMSParticles erased!!!" <<
GGendl;
99 GGcout(
"GGEMSParticles",
"InitializeKernel", 3) <<
"Initializing kernel..." <<
GGendl;
102 std::string openCL_kernel_path = OPENCL_KERNEL_PATH;
103 std::string filename = openCL_kernel_path +
"/IsAlive.cl";
122 GGcout(
"GGEMSParticles",
"Initialize", 1) <<
"Initialization of GGEMSParticles..." <<
GGendl;
146 cl::CommandQueue* queue = opencl_manager.
GetCommandQueue(thread_index);
147 cl::Event*
event = opencl_manager.
GetEvent(thread_index);
151 std::string device_name = opencl_manager.
GetDeviceName(device_index);
152 std::ostringstream oss(std::ostringstream::out);
153 oss <<
"GGEMSParticles::IsAlive on " << device_name <<
", index " << device_index;
157 cl::Buffer* status =
status_[thread_index];
164 cl::NDRange global_wi(number_of_work_items);
165 cl::NDRange local_wi(work_group_size);
173 GGint kernel_status = queue->enqueueNDRangeKernel(*
kernel_alive_[thread_index], 0, global_wi, local_wi,
nullptr, event);
174 opencl_manager.
CheckOpenCLError(kernel_status,
"GGEMSParticles",
"IsAlive");
184 GGint status_from_device = status_device[0];
202 GGcout(
"GGEMSParticles",
"AllocatePrimaryParticles", 1) <<
"Allocation of primary particles..." <<
GGendl;
213 status_[i] = opencl_manager.
Allocate(
nullptr,
sizeof(
GGint), i, CL_MEM_READ_WRITE,
"GGEMSParticles");
GGEMS class handling RAM memory.
GGEMSParticles(void)
GGEMSParticles constructor.
void AllocatePrimaryParticles(void)
Allocate memory for primary particles.
bool IsAlive(GGsize const &thread_index) const
check if some particles are alive in OpenCL particle buffer
GGsize GetNumberOfActivatedDevice(void) const
get the number of activated devices
void Initialize(void)
Initialize the GGEMSParticles object.
Structure storing informations about primary particles.
static GGEMSProfilerManager & GetInstance(void)
Create at first time the Singleton.
cl::Buffer ** primary_particles_
void CheckOpenCLError(GGint const &error, std::string const &class_name, std::string const &method_name) const
check the OpenCL error
GGsize * number_of_particles_
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
void Deallocate(cl::Buffer *buffer, GGsize size, GGsize const &thread_index, std::string const &class_name="Undefined")
Deallocation of OpenCL memory.
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...
void SetNumberOfParticles(GGsize const &thread_index, GGsize const &number_of_particles)
Set the number of particles in buffer.
~GGEMSParticles(void)
GGEMSParticles destructor.
void CleanBuffer(cl::Buffer *buffer, GGsize const &size, GGsize const &thread_index)
Cleaning buffer on OpenCL device.
GGsize number_activated_devices_
GGEMS class managing profiler data.
GGsize GetWorkGroupSize(void) const
Get the work group size defined in GGEMS on activated OpenCL context.
Structure storing the primary particle buffers for both OpenCL and GGEMS.
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.
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.
void InitializeKernel(void)
Initialize kernel for particle in OpenCL.
GGEMS class handling the source(s)
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
Singleton class storing all informations about OpenCL and managing GPU/CPU devices,...
std::string GetDeviceName(GGsize const &device_index) const
Get the name of the activated device.
GGEMS class managing profiler data.
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
cl::Kernel ** kernel_alive_
cl::CommandQueue * GetCommandQueue(GGsize const &thread_index) const
Return the command queue to activated context.
static GGEMSOpenCLManager & GetInstance(void)
Create at first time the Singleton.