OpenClManager Class Reference
|
Space-ng SDK
|
#include <sol3/opencl/opencl_manager.h>
Public Member Functions | |
| cl::Context const & | context () const |
| Get OpenCL context. More... | |
| cl::Device const & | device () const |
| Get OpenCL device. More... | |
| std::vector< cl::Device > const & | devices () const |
| Get list of all devices. More... | |
| cl::CommandQueue | createCommandQueue () const |
| cl::Kernel | createKernel (cpp::fs::path const &source_cl_file, std::string const &kernel_name, std::string const &compiler_opts="") |
| cl::Program | getOrCompileProgramFile (cpp::fs::path const &source_cl_file, std::string const &compiler_opts="") |
| cl::Program | getOrCompileProgramSource (std::string const &name, std::string const &source, std::string const &compiler_opts="") |
| cl::Buffer | mapBufferToGpu (core::IBufferMutable &buffer) |
| cl::Buffer | mapBufferToGpu (core::IBufferConst const &buffer) |
Static Public Member Functions | |
| static OpenClManager & | instance () |
| Get singleton instance (thread-safe) More... | |
Detailed Description
Singleton OpenCL manager.
Manages OpenCL resources which can be shared for all kernels within a single process: platform, device, context, compiled programs, etc.
Member Function Documentation
◆ context()
|
inline |
Get OpenCL context.
◆ createCommandQueue()
|
inline |
◆ createKernel()
| cl::Kernel sol3::opencl::OpenClManager::createKernel | ( | cpp::fs::path const & | source_cl_file, |
| std::string const & | kernel_name, | ||
| std::string const & | compiler_opts = "" |
||
| ) |
Create a new kernel from a named function within an OpenCL source file. This function will load and compile the program if needed. Thread-safe.
◆ device()
|
inline |
Get OpenCL device.
◆ devices()
|
inline |
Get list of all devices.
◆ getOrCompileProgramFile()
| cl::Program sol3::opencl::OpenClManager::getOrCompileProgramFile | ( | cpp::fs::path const & | source_cl_file, |
| std::string const & | compiler_opts = "" |
||
| ) |
Get or compile an OpenCL program by passing a path to an OpenCL source file. Thread-safe.
◆ getOrCompileProgramSource()
| cl::Program sol3::opencl::OpenClManager::getOrCompileProgramSource | ( | std::string const & | name, |
| std::string const & | source, | ||
| std::string const & | compiler_opts = "" |
||
| ) |
Get or compile an OpenCL program by passing raw source code.
Programs are cached by name. If already compiled, returns cached version. Throws sol3::log::InvalidResource on compilation failure. Thread-safe.
◆ instance()
|
static |
Get singleton instance (thread-safe)
◆ mapBufferToGpu() [1/2]
| cl::Buffer sol3::opencl::OpenClManager::mapBufferToGpu | ( | core::IBufferConst const & | buffer | ) |
◆ mapBufferToGpu() [2/2]
| cl::Buffer sol3::opencl::OpenClManager::mapBufferToGpu | ( | core::IBufferMutable & | buffer | ) |
Map IBuffer to OpenCL buffer
- Parameters
-
buffer Buffer to map
- Returns
- OpenCL buffer object
On unified memory systems (e.g. qrb5165), this will perform a lightweight "wrapping" operation around the existing DMA memory (zero copy).
On x64/Nvidia heterogeneous systems, this mapBufferToGpu() call will copy the contents of the buffer to VRAM.
From the Khronos docs:
"clCreateBuffer with CL_MEM_USE_HOST_PTR does not perform any data transfer at buffer creation time. Data is transferred from host to device using DMA before the first actual device usage. [...] After the first usage, data will remain on device until the user requests the data back to host using a Map operation."
The documentation for this class was generated from the following file:
- /workspaces/astro/sol3-sdk/cpp/sol3/opencl/opencl_manager.h
Generated by