PLSSVM - Parallel Least Squares Support Vector Machine
2.0.0
A Least Squares Support Vector Machine implementation using different backends.
|
Namespace containing OpenCL backend specific implementation details. Should not directly be used by users. More...
Classes | |
class | command_queue |
RAII wrapper class around a cl_command_queue. More... | |
class | context |
RAII wrapper class around a cl_context. More... | |
class | device_ptr |
Small wrapper class around an OpenCL device pointer together with commonly used device functions. More... | |
class | error_code |
Class wrapping an OpenCL error code. More... | |
class | kernel |
RAII wrapper class around a cl_kernel. More... | |
Enumerations | |
enum class | compute_kernel_name { q_kernel , svm_kernel , w_kernel , predict_kernel } |
Enum class for all different OpenCL compute kernels. More... | |
Functions | |
std::ostream & | operator<< (std::ostream &out, error_code ec) |
Output the error code encapsulated by ev to the given output-stream out . More... | |
bool | operator== (error_code lhs, error_code rhs) noexcept |
Compares two error codes for equality. More... | |
bool | operator!= (error_code lhs, error_code rhs) noexcept |
Compares two error codes for inequality. More... | |
void | device_assert (error_code code, std::string_view msg="") |
Check the OpenCL error code . If code signals an error, throw a plssvm::opencl::backend_exception. More... | |
std::pair< std::vector< context >, target_platform > | get_contexts (target_platform target) |
Returns the context listing all devices matching the target platform target and the actually used target platform (only interesting if the provided target was automatic). More... | |
void | device_synchronize (const command_queue &queue) |
Wait for the compute device associated with queue to finish. More... | |
std::string | get_device_name (const command_queue &queue) |
Get the name of the device associated with the OpenCL command queue queue . More... | |
std::vector< std::pair< compute_kernel_name, std::string > > | kernel_type_to_function_names (kernel_function_type kernel) |
Convert the kernel type kernel to the device function names and return the plssvm::opencl::detail::compute_kernel_name identifier. More... | |
std::vector< command_queue > | create_command_queues (const std::vector< context > &contexts, target_platform target, const std::vector< std::pair< compute_kernel_name, std::string >> &kernel_names) |
Create command queues for all devices in the OpenCL contexts with respect to target given and the associated compute kernels with respect to the given source files and kernel function names. Always builds kernels for float and double precision floating point types. More... | |
template<typename... Args> | |
void | set_kernel_args (cl_kernel kernel, Args... args) |
Set all arguments in the parameter pack args for the kernel kernel . More... | |
template<typename... Args> | |
void | run_kernel (const command_queue &queue, cl_kernel kernel, const std::vector< std::size_t > &grid_size, const std::vector< std::size_t > &block_size, Args &&...args) |
Run the 1D kernel on the queue with the additional parameters args . More... | |
template<typename... Args> | |
void | run_kernel (const command_queue &queue, cl_kernel kernel, std::size_t grid_size, std::size_t block_size, Args &&...args) |
Run the 1D kernel on the queue with the additional parameters args . More... | |
Namespace containing OpenCL backend specific implementation details. Should not directly be used by users.
|
strong |
Enum class for all different OpenCL compute kernels.
Used to distinguish kernels in the plssvm::opencl::detail::command_queue class.
std::ostream& plssvm::opencl::detail::operator<< | ( | std::ostream & | out, |
error_code | ec | ||
) |
Output the error code encapsulated by ev
to the given output-stream out
.
Example output of an error code:
[in,out] | out | the output-stream to write the error code to |
[in] | ec | the error code |
|
noexcept |
Compares two error codes for equality.
[in] | lhs | the first error code |
[in] | rhs | the second error code |
true
if both error codes are equal, false
otherwise ([[nodiscard]]
)
|
noexcept |
Compares two error codes for inequality.
[in] | lhs | the first error code |
[in] | rhs | the second error code |
true
if both error codes are unequal, false
otherwise ([[nodiscard]]
) void plssvm::opencl::detail::device_assert | ( | error_code | code, |
std::string_view | msg = "" |
||
) |
Check the OpenCL error code
. If code
signals an error, throw a plssvm::opencl::backend_exception.
The exception contains the following message: "OpenCL assert 'OPENCL_ERROR_NAME' (OPENCL_ERROR_CODE): OPTIONAL_OPENCL_ERROR_STRING".
[in] | code | the OpenCL error code to check |
[in] | msg | optional message printed if the error code check failed |
plssvm::opencl::backend_exception | if the error code signals a failure |
std::pair<std::vector<context>, target_platform> plssvm::opencl::detail::get_contexts | ( | target_platform | target | ) |
Returns the context listing all devices matching the target platform target
and the actually used target platform (only interesting if the provided target
was automatic).
If the selected target platform is plssvm::target_platform::automatic the selector tries to find devices according to plssvm::determine_default_target_platform.
[in] | target | the target platform for which the devices must match |
[[nodiscard]]
) void plssvm::opencl::detail::device_synchronize | ( | const command_queue & | queue | ) |
Wait for the compute device associated with queue
to finish.
[in] | queue | the command queue to synchronize |
std::string plssvm::opencl::detail::get_device_name | ( | const command_queue & | queue | ) |
Get the name of the device associated with the OpenCL command queue queue
.
[in] | queue | the OpenCL command queue |
[[nodiscard]]
) std::vector<std::pair<compute_kernel_name, std::string> > plssvm::opencl::detail::kernel_type_to_function_names | ( | kernel_function_type | kernel | ) |
Convert the kernel type kernel
to the device function names and return the plssvm::opencl::detail::compute_kernel_name identifier.
[in] | kernel | the kernel type |
[[nodiscard]]
) std::vector<command_queue> plssvm::opencl::detail::create_command_queues | ( | const std::vector< context > & | contexts, |
target_platform | target, | ||
const std::vector< std::pair< compute_kernel_name, std::string >> & | kernel_names | ||
) |
Create command queues for all devices in the OpenCL contexts
with respect to target
given and the associated compute kernels with respect to the given source files and kernel function names. Always builds kernels for float
and double
precision floating point types.
Manually caches the OpenCL JIT compiled code in the current $TEMP
directory (no special means to prevent race conditions are implemented). The cached binaries are reused if:
A custom SHA256 implementation is used to detect changes in the OpenCL kernel source files. Additionally, adds the path to the currently used OpenCL library as a comment to the kernel source string (before the checksum calculation) to detect changes in the used OpenCL implementation and trigger a kernel rebuild.
[in] | contexts | the used OpenCL contexts |
[in] | target | the target platform |
[in] | kernel_names | all kernel name for which an OpenCL cl_kernel should be build |
plssvm::invalid_file_format_exception | if the file couldn't be read using std::ifstream::read |
[[nodiscard]]
)
|
inline |
Set all arguments in the parameter pack args
for the kernel kernel
.
Args | the types of the arguments |
[in] | kernel | the OpenCL kernel to set the arguments |
[in] | args | the arguments to set |
|
inline |
Run the 1D kernel
on the queue
with the additional parameters args
.
Args | the types of the arguments |
[in] | queue | the command queue on which the kernel should be executed |
[in] | kernel | the kernel to run |
[in] | grid_size | the number of global work-items (possibly multi-dimensional) |
[in] | block_size | the number of work-items that make up a work-group (possibly multi-dimensional) |
[in] | args | the arguments to set |
|
inline |
Run the 1D kernel
on the queue
with the additional parameters args
.
Args | the types of the arguments |
[in] | queue | the command queue on which the kernel should be executed |
[in] | kernel | the kernel to run |
[in] | grid_size | the number of global work-items |
[in] | block_size | the number of work-items that make up a work-group |
[in] | args | the arguments to set |