MatCL - OpenCL Wrapper

版本 1.0.0.0 (468.7 KB) 作者: Philip Heinisch
OpenCL wrapper for Matlab
380.0 次下载
更新时间 2018/6/9

MatCL is an OpenCL interface for MathWorks Matlab. This MEX-based toolbox aims at providing a simple and easy to use solution to transfer memory and launch OpenCL kernels from Matlab using a single command.
In comparison to other Matlab OpenCL solutions, MatCL is not just an OpenCL API wrapper but encapsulates the low-level host API calls necessary to initialize devices, create OpenCL buffers from Matlab workspace variables and build and launch kernels.
MatCL is primarily intended to help in the development and testing of OpenCL kernels by allowing to transparently pass data from and to Matlab.
Because MatCL handles the entire low-level process, this toolbox makes it possible to execute kernels without in depth knowledge of the host implementation necessary to support the execution of OpenCL kernels.
MatCL is also optimized to allow efficient execution of OpenCL kernels within Matlab to accelerate computationally intensive tasks without having to rely on Nvidia CUDA. In addition to single command kernel execution, MatCL also allows for an independent two-step kernel compilation and launch workflow to save the kernel compile time and allow efficient repetitive kernel execution.
Tested using Nvidia (Tesla, GTX), AMD (Ryzen, Radeon R9, FirePro) and Intel (Xeon, Core, HD Graphics) devices with Matlab R2016b and up.

Usage:

Enumerate OpenCL Devices:
[names,dev_class,max_mem]=cl_get_devices;
names: Names of all available devices
dev_class: The device class (CPU, GPU or Other for other or unknown Accelerators)
max_mem: The available device memory in bytes

Build Kernel:
[comp_time,kernels]=cl_run_kernel(ocl_dev_id,'kernel_url.cl','defines');
ocl_dev_id: ID of the OpenCL device to be used
kernel_url.cl: URL of the kernel file
defines: List of OpenCL compiler defines
kernels: List with names of all available kernels

Run Kernel:
[run_time,copy_time]=cl_run_kernel(ocl_dev_id,','kernel_function',global_range,local_range,in1,out1,[rw_flags]);
ocl_dev_id: ID of the OpenCL device to be used
kernel_function: Name of the kernel function to execute
global_range: Global OpenCL range (see NDRange)
local_range: Local OpenCL range (see NDRange)
in1, out1: List of variables to pass from/to kernel
rw_flags: read/write flag for the Kernel variables, this can either be scalar (all variables are read&write) or a vector with an entry for each variable: 0 - read&write / 1 - kernel read only / 2 - kernel write only

Build & Run Kernel:
[run_time]=cl_run_kernel(ocl_dev_id,' kernel_url.cl ','defines ','kernel_function',global_range,local_range,in1,out1,[rw_flags]);
ocl_dev_id: ID of the OpenCL device to be used
kernel_url.cl: URL of the kernel file
defines: List of OpenCL compiler defines
kernel_function: Name of the kernel function to execute
global_range: Global OpenCL range (see NDRange)
local_range: Local OpenCL range (see NDRange)
in1, out1: List of variables to pass from/to kernel
rw_flags: read/write flag for the Kernel variables, this can either be scalar (all variables are read&write) or a vector with an entry for each variable: 0 - read&write / 1 - kernel read only / 2 - kernel write only

Build & Run Kernel (with Kernel printf redirection):
[run_time]=cl_dbg_kernel(ocl_dev_id,' kernel_url.cl ','defines ','kernel_function',global_range,local_range,in1,out1,[rw_flags]);
ocl_dev_id: ID of the OpenCL device to be used
kernel_url.cl: URL of the kernel file
defines: List of OpenCL compiler defines
kernel_function: Name of the kernel function to execute
global_range: Global OpenCL range (see NDRange)
local_range: Local OpenCL range (see NDRange)
in1, out1: List of variables to pass from/to kernel
rw_flags: read/write flag for the Kernel variables, this can either be scalar (all variables are read&write) or a vector with an entry for each variable: 0 - read&write / 1 - kernel read only / 2 - kernel write only

引用格式

Philip Heinisch (2024). MatCL - OpenCL Wrapper (https://github.com/philipheinisch/MatCL), GitHub. 检索时间: .

MATLAB 版本兼容性
创建方式 R2017a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 GPU Computing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

无法下载基于 GitHub 默认分支的版本

版本 已发布 发行说明
1.0.0.0

Added description
Updated description
Added more tags

要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库
要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库