GGEMS
1.1
GPU GEant4-based Monte Carlo Simulations
|
Singleton class storing all informations about OpenCL and managing GPU/CPU devices, contexts, kernels, command queues and events. In GGEMS the strategy is 1 context = 1 device. More...
#include "GGEMSOpenCLManager.hh"
Public Member Functions | |
GGEMSOpenCLManager (GGEMSOpenCLManager const &opencl_manager)=delete | |
Avoid copy of the singleton by reference. More... | |
GGEMSOpenCLManager & | operator= (GGEMSOpenCLManager const &opencl_manager)=delete |
Avoid assignement of the singleton by reference. More... | |
GGEMSOpenCLManager (GGEMSOpenCLManager const &&opencl_manager)=delete | |
Avoid copy of the singleton by rvalue reference. More... | |
GGEMSOpenCLManager & | operator= (GGEMSOpenCLManager const &&opencl_manager)=delete |
Avoid copy of the singleton by rvalue reference. More... | |
void | CheckOpenCLError (GGint const &error, std::string const &class_name, std::string const &method_name) const |
check the OpenCL error More... | |
void | PrintPlatformInfos (void) const |
print all the informations about the platform More... | |
void | PrintDeviceInfos (void) const |
print all informations about devices More... | |
void | PrintBuildOptions (void) const |
print global build options used during kernel compilation More... | |
void | PrintActivatedDevices (void) const |
print infos about activated devices More... | |
std::string | GetDeviceName (GGsize const &device_index) const |
Get the name of the activated device. More... | |
cl_device_type | GetDeviceType (GGsize const &device_index) const |
Get the type of the activated device. More... | |
GGsize | GetNumberOfDetectedDevice (void) const |
get the number of detected devices More... | |
GGsize | GetNumberOfActivatedDevice (void) const |
get the number of activated devices More... | |
GGsize | GetIndexOfActivatedDevice (GGsize const &thread_index) const |
get the index of activated device More... | |
GGsize | GetMaxBufferAllocationSize (GGsize const &device_index) const |
Get the max buffer size in bytes on activated OpenCL device. More... | |
GGsize | GetRAMMemory (GGsize const &device_index) const |
Get the RAM in bytes on OpenCL device. More... | |
GGsize | GetWorkGroupSize (void) const |
Get the work group size defined in GGEMS on activated OpenCL context. More... | |
GGsize | GetBestWorkItem (GGsize const &number_of_elements) const |
get the best number of work item More... | |
cl::Context * | GetContext (GGsize const &thread_index) const |
return the activated context More... | |
cl::CommandQueue * | GetCommandQueue (GGsize const &thread_index) const |
Return the command queue to activated context. More... | |
cl::Event * | GetEvent (GGsize const &thread_index) const |
return an event to activated context More... | |
void | DeviceToActivate (GGsize const &device_id) |
set the index of the device to activate More... | |
void | DeviceToActivate (std::string const &device_type, std::string const &device_vendor="") |
activate specific device More... | |
void | DeviceBalancing (std::string const &device_balancing) |
change the device balancing, by default device balancing is the same for each device More... | |
GGfloat | GetDeviceBalancing (GGsize const &thread_index) const |
return the device load for a device More... | |
GGsize | GetNumberDeviceLoads (void) const |
return the size of device load vector More... | |
bool | IsReady (void) const |
check if an OpenCL device is activated More... | |
void | Clean (void) |
clean OpenCL data More... | |
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. More... | |
template<typename T > | |
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!!! More... | |
template<typename T > | |
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 GetDeviceBufferRead!!! More... | |
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. More... | |
void | Deallocate (cl::Buffer *buffer, GGsize size, GGsize const &thread_index, std::string const &class_name="Undefined") |
Deallocation of OpenCL memory. More... | |
void | CleanBuffer (cl::Buffer *buffer, GGsize const &size, GGsize const &thread_index) |
Cleaning buffer on OpenCL device. More... | |
bool | IsDoublePrecisionAtomicAddition (GGsize const &device_index) const |
checking double precision atomic addition on OpenCL device More... | |
Static Public Member Functions | |
static GGEMSOpenCLManager & | GetInstance (void) |
Create at first time the Singleton. More... | |
Private Member Functions | |
GGEMSOpenCLManager (void) | |
Unable the constructor for the user. More... | |
~GGEMSOpenCLManager (void) | |
Unable the destructor for the user. More... | |
std::string | ErrorType (GGint const &error) const |
get the error description More... | |
GGsize | CheckKernel (std::string const &kernel_name, std::string const &compilation_options) const |
check if a kernel has been already compiled More... | |
bool | IsDoublePrecision (GGsize const &device_index) const |
checking double precision on OpenCL device More... | |
Singleton class storing all informations about OpenCL and managing GPU/CPU devices, contexts, kernels, command queues and events. In GGEMS the strategy is 1 context = 1 device.
Definition at line 53 of file GGEMSOpenCLManager.hh.
|
private |
Unable the constructor for the user.
Definition at line 44 of file GGEMSOpenCLManager.cc.
|
private |
Unable the destructor for the user.
Definition at line 340 of file GGEMSOpenCLManager.cc.
|
delete |
Avoid copy of the singleton by reference.
opencl_manager | - reference on the singleton |
|
delete |
Avoid copy of the singleton by rvalue reference.
opencl_manager | - rvalue reference on the singleton |
cl::Buffer * GGEMSOpenCLManager::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.
host_ptr | - pointer to buffer in host memory |
size | - size of the buffer in bytes |
thread_index | - index of the thread (= activated device index) |
flags | - mode to open the buffer |
class_name | - name of class allocating memory |
Definition at line 945 of file GGEMSOpenCLManager.cc.
|
private |
check if a kernel has been already compiled
kernel_name | - name of the kernel |
compilation_options | - arguments of compilation |
Definition at line 828 of file GGEMSOpenCLManager.cc.
void GGEMSOpenCLManager::CheckOpenCLError | ( | GGint const & | error, |
std::string const & | class_name, | ||
std::string const & | method_name | ||
) | const |
check the OpenCL error
error | - error index |
class_name | - name of the class |
method_name | - name of the method |
Definition at line 1048 of file GGEMSOpenCLManager.cc.
void GGEMSOpenCLManager::Clean | ( | void | ) |
clean OpenCL data
Definition at line 351 of file GGEMSOpenCLManager.cc.
void GGEMSOpenCLManager::CleanBuffer | ( | cl::Buffer * | buffer, |
GGsize const & | size, | ||
GGsize const & | thread_index | ||
) |
Cleaning buffer on OpenCL device.
buffer | - pointer to buffer in host memory |
size | - size of the buffer in bytes |
thread_index | - index of the thread (= activated device index) |
Definition at line 998 of file GGEMSOpenCLManager.cc.
void GGEMSOpenCLManager::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.
kernel_filename | - filename where is declared the kernel |
kernel_name | - name of the kernel |
kernel_list | - list of kernel by device |
custom_options | - new compilation option for the kernel |
additional_options | - additionnal compilation option |
Definition at line 849 of file GGEMSOpenCLManager.cc.
void GGEMSOpenCLManager::Deallocate | ( | cl::Buffer * | buffer, |
GGsize | size, | ||
GGsize const & | thread_index, | ||
std::string const & | class_name = "Undefined" |
||
) |
Deallocation of OpenCL memory.
buffer | - pointer to buffer in host memory |
size | - size of the buffer in bytes |
thread_index | - index of the thread (= activated device index) |
class_name | - name of class deallocating memory |
Definition at line 981 of file GGEMSOpenCLManager.cc.
void GGEMSOpenCLManager::DeviceBalancing | ( | std::string const & | device_balancing | ) |
change the device balancing, by default device balancing is the same for each device
device_balancing | - device balancing |
Definition at line 785 of file GGEMSOpenCLManager.cc.
void GGEMSOpenCLManager::DeviceToActivate | ( | GGsize const & | device_id | ) |
set the index of the device to activate
device_id | - device index |
Definition at line 739 of file GGEMSOpenCLManager.cc.
void GGEMSOpenCLManager::DeviceToActivate | ( | std::string const & | device_type, |
std::string const & | device_vendor = "" |
||
) |
activate specific device
device_type | - type of device : all, gpu or cpu |
device_vendor | - vendor : nvidia, intel, or amd |
Definition at line 682 of file GGEMSOpenCLManager.cc.
|
private |
get the error description
error | - error index from OpenCL library |
Definition at line 1059 of file GGEMSOpenCLManager.cc.
get the best number of work item
number_of_elements | - number of elements for the kernel computation |
Definition at line 1030 of file GGEMSOpenCLManager.cc.
|
inline |
Return the command queue to activated context.
thread_index | - index of the thread (= activated device index) |
Definition at line 222 of file GGEMSOpenCLManager.hh.
|
inline |
return the activated context
thread_index | - index of the thread (= activated device index) |
Definition at line 214 of file GGEMSOpenCLManager.hh.
return the device load for a device
thread_index | - index of the thread (= activated device index) |
Definition at line 261 of file GGEMSOpenCLManager.hh.
T * GGEMSOpenCLManager::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!!!
device_ptr | - pointer on device memory |
size | - size of region to map |
thread_index | - index of the thread (= activated device index) |
T | - type of the returned pointer on host memory |
Definition at line 480 of file GGEMSOpenCLManager.hh.
|
inline |
Get the name of the activated device.
device_index | - index of device |
Definition at line 145 of file GGEMSOpenCLManager.hh.
|
inline |
Get the type of the activated device.
device_index | - index of device |
Definition at line 153 of file GGEMSOpenCLManager.hh.
|
inline |
return an event to activated context
thread_index | - index of the thread (= activated device index) |
Definition at line 230 of file GGEMSOpenCLManager.hh.
get the index of activated device
thread_index | - index of the thread (= activated device index) |
Definition at line 175 of file GGEMSOpenCLManager.hh.
|
inlinestatic |
Create at first time the Singleton.
Definition at line 72 of file GGEMSOpenCLManager.hh.
Get the max buffer size in bytes on activated OpenCL device.
device_index | - index of activated devices |
Definition at line 183 of file GGEMSOpenCLManager.hh.
|
inline |
return the size of device load vector
Definition at line 268 of file GGEMSOpenCLManager.hh.
|
inline |
get the number of activated devices
Definition at line 167 of file GGEMSOpenCLManager.hh.
|
inline |
get the number of detected devices
Definition at line 160 of file GGEMSOpenCLManager.hh.
Get the RAM in bytes on OpenCL device.
device_index | - index of activated devices |
Definition at line 191 of file GGEMSOpenCLManager.hh.
|
inline |
Get the work group size defined in GGEMS on activated OpenCL context.
Definition at line 198 of file GGEMSOpenCLManager.hh.
|
private |
checking double precision on OpenCL device
device_index | - index of the device |
Definition at line 1010 of file GGEMSOpenCLManager.cc.
bool GGEMSOpenCLManager::IsDoublePrecisionAtomicAddition | ( | GGsize const & | device_index | ) | const |
checking double precision atomic addition on OpenCL device
device_index | - index of device |
Definition at line 1020 of file GGEMSOpenCLManager.cc.
|
inline |
check if an OpenCL device is activated
Definition at line 275 of file GGEMSOpenCLManager.hh.
|
delete |
Avoid copy of the singleton by rvalue reference.
opencl_manager | - rvalue reference on the singleton |
|
delete |
Avoid assignement of the singleton by reference.
opencl_manager | - reference on the singleton |
void GGEMSOpenCLManager::PrintActivatedDevices | ( | void | ) | const |
print infos about activated devices
Definition at line 655 of file GGEMSOpenCLManager.cc.
void GGEMSOpenCLManager::PrintBuildOptions | ( | void | ) | const |
print global build options used during kernel compilation
Definition at line 646 of file GGEMSOpenCLManager.cc.
void GGEMSOpenCLManager::PrintDeviceInfos | ( | void | ) | const |
print all informations about devices
Definition at line 479 of file GGEMSOpenCLManager.cc.
void GGEMSOpenCLManager::PrintPlatformInfos | ( | void | ) | const |
print all the informations about the platform
Definition at line 461 of file GGEMSOpenCLManager.cc.
void GGEMSOpenCLManager::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 GetDeviceBufferRead!!!
device_ptr | - pointer on device memory |
host_ptr | - pointer on host memory mapped on device memory |
thread_index | - index of the thread (= activated device index) |
T | - type of host memory pointer to release |
Definition at line 495 of file GGEMSOpenCLManager.hh.
|
private |
list of default option to OpenCL compiler
Definition at line 463 of file GGEMSOpenCLManager.hh.
|
private |
OpenCL contexts
Definition at line 466 of file GGEMSOpenCLManager.hh.
|
private |
Address Bits
Definition at line 418 of file GGEMSOpenCLManager.hh.
|
private |
Flag on device availability
Definition at line 419 of file GGEMSOpenCLManager.hh.
|
private |
Device balancing
Definition at line 460 of file GGEMSOpenCLManager.hh.
|
private |
Flag on compiler availability
Definition at line 420 of file GGEMSOpenCLManager.hh.
|
private |
Double precision capability
Definition at line 423 of file GGEMSOpenCLManager.hh.
|
private |
Driver version of the device
Definition at line 402 of file GGEMSOpenCLManager.hh.
|
private |
Endian little
Definition at line 424 of file GGEMSOpenCLManager.hh.
|
private |
Error correction support
Definition at line 426 of file GGEMSOpenCLManager.hh.
|
private |
Execution capabilities
Definition at line 427 of file GGEMSOpenCLManager.hh.
|
private |
Extensions
Definition at line 425 of file GGEMSOpenCLManager.hh.
|
private |
Global memory cache size
Definition at line 428 of file GGEMSOpenCLManager.hh.
|
private |
Global memory cache type
Definition at line 429 of file GGEMSOpenCLManager.hh.
|
private |
Global memory cache line size
Definition at line 430 of file GGEMSOpenCLManager.hh.
|
private |
Global memory size
Definition at line 431 of file GGEMSOpenCLManager.hh.
|
private |
Half precision capability
Definition at line 421 of file GGEMSOpenCLManager.hh.
|
private |
Host unified memory
Definition at line 434 of file GGEMSOpenCLManager.hh.
|
private |
Max height of image 2D
Definition at line 439 of file GGEMSOpenCLManager.hh.
|
private |
Max width of image 2D
Definition at line 438 of file GGEMSOpenCLManager.hh.
|
private |
Max depth of image 3D
Definition at line 442 of file GGEMSOpenCLManager.hh.
|
private |
Max height of image 3D
Definition at line 441 of file GGEMSOpenCLManager.hh.
|
private |
Max width of image 3D
Definition at line 440 of file GGEMSOpenCLManager.hh.
|
private |
Max size of image array
Definition at line 435 of file GGEMSOpenCLManager.hh.
|
private |
Max size of image buffer
Definition at line 436 of file GGEMSOpenCLManager.hh.
|
private |
Image support
Definition at line 437 of file GGEMSOpenCLManager.hh.
|
private |
Index of the activated device
Definition at line 392 of file GGEMSOpenCLManager.hh.
|
private |
Local memory size
Definition at line 432 of file GGEMSOpenCLManager.hh.
|
private |
Local memory type
Definition at line 433 of file GGEMSOpenCLManager.hh.
|
private |
Max frequency of device
Definition at line 445 of file GGEMSOpenCLManager.hh.
|
private |
Max compute units
Definition at line 446 of file GGEMSOpenCLManager.hh.
|
private |
Max constant arguments in kernel
Definition at line 447 of file GGEMSOpenCLManager.hh.
|
private |
Max constant buffer size
Definition at line 448 of file GGEMSOpenCLManager.hh.
|
private |
Max memory allocation size
Definition at line 449 of file GGEMSOpenCLManager.hh.
|
private |
Max Parameter size in kernel
Definition at line 450 of file GGEMSOpenCLManager.hh.
|
private |
Max read image read by kernel in same time
Definition at line 443 of file GGEMSOpenCLManager.hh.
|
private |
Max number of samplers in kernel
Definition at line 451 of file GGEMSOpenCLManager.hh.
|
private |
Max Work group size
Definition at line 452 of file GGEMSOpenCLManager.hh.
|
private |
Maximum work item dimensions
Definition at line 453 of file GGEMSOpenCLManager.hh.
|
private |
Maximum work item sizes
Definition at line 454 of file GGEMSOpenCLManager.hh.
|
private |
Max write image read by kernel in same time
Definition at line 444 of file GGEMSOpenCLManager.hh.
|
private |
Alignment memory
Definition at line 455 of file GGEMSOpenCLManager.hh.
|
private |
Name of the device
Definition at line 397 of file GGEMSOpenCLManager.hh.
|
private |
Native vector for char integer
Definition at line 404 of file GGEMSOpenCLManager.hh.
|
private |
Native vector for double precision
Definition at line 410 of file GGEMSOpenCLManager.hh.
|
private |
Native vector for single precision
Definition at line 409 of file GGEMSOpenCLManager.hh.
|
private |
Native vector for half precision
Definition at line 408 of file GGEMSOpenCLManager.hh.
|
private |
Native vector for int integer
Definition at line 406 of file GGEMSOpenCLManager.hh.
|
private |
Native vector for long integer
Definition at line 407 of file GGEMSOpenCLManager.hh.
|
private |
Native vector for short integer
Definition at line 405 of file GGEMSOpenCLManager.hh.
|
private |
OpenCL C version
Definition at line 403 of file GGEMSOpenCLManager.hh.
|
private |
Partition affinity domain
Definition at line 457 of file GGEMSOpenCLManager.hh.
|
private |
Partition affinity domain
Definition at line 458 of file GGEMSOpenCLManager.hh.
|
private |
Preferred vector for char integer
Definition at line 411 of file GGEMSOpenCLManager.hh.
|
private |
Preferred vector for double precision
Definition at line 417 of file GGEMSOpenCLManager.hh.
|
private |
Preferred vector for single precision
Definition at line 416 of file GGEMSOpenCLManager.hh.
|
private |
Preferred vector for half precision
Definition at line 415 of file GGEMSOpenCLManager.hh.
|
private |
Preferred vector for int integer
Definition at line 413 of file GGEMSOpenCLManager.hh.
|
private |
Preferred vector for long integer
Definition at line 414 of file GGEMSOpenCLManager.hh.
|
private |
Preferred vector for short integer
Definition at line 412 of file GGEMSOpenCLManager.hh.
|
private |
Size of buffer for printf in kernel
Definition at line 456 of file GGEMSOpenCLManager.hh.
|
private |
Profile of the device
Definition at line 400 of file GGEMSOpenCLManager.hh.
|
private |
Timer resolution
Definition at line 459 of file GGEMSOpenCLManager.hh.
|
private |
Single precision capability
Definition at line 422 of file GGEMSOpenCLManager.hh.
|
private |
Type of device
Definition at line 396 of file GGEMSOpenCLManager.hh.
|
private |
Vendor of the device
Definition at line 398 of file GGEMSOpenCLManager.hh.
|
private |
Vendor ID of the device
Definition at line 399 of file GGEMSOpenCLManager.hh.
|
private |
Version of the device
Definition at line 401 of file GGEMSOpenCLManager.hh.
|
private |
List of detected device
Definition at line 391 of file GGEMSOpenCLManager.hh.
|
private |
OpenCL events
Definition at line 468 of file GGEMSOpenCLManager.hh.
|
private |
List of compilation options for kernel
Definition at line 472 of file GGEMSOpenCLManager.hh.
|
private |
List of kernels for each device
Definition at line 471 of file GGEMSOpenCLManager.hh.
|
private |
List of the extension names
Definition at line 388 of file GGEMSOpenCLManager.hh.
|
private |
Platform name
Definition at line 386 of file GGEMSOpenCLManager.hh.
|
private |
OpenCL profile
Definition at line 384 of file GGEMSOpenCLManager.hh.
|
private |
Vendor of the platform
Definition at line 387 of file GGEMSOpenCLManager.hh.
|
private |
OpenCL version supported by the implementation
Definition at line 385 of file GGEMSOpenCLManager.hh.
|
private |
List of detected platform
Definition at line 382 of file GGEMSOpenCLManager.hh.
|
private |
OpenCL command queues
Definition at line 467 of file GGEMSOpenCLManager.hh.
|
private |
UMap storing vendor name and an alias
Definition at line 394 of file GGEMSOpenCLManager.hh.
|
private |
Work group size by GGEMS, here 64
Definition at line 393 of file GGEMSOpenCLManager.hh.