File Exchange

image thumbnail

OpenCL Matlab Wrapper

version (17.7 KB) by MESC Labs
OpenCL wrapper for MATLAB that allows for powerful yet simple interfacing


Updated 02 Jun 2014

View License

This wrapper provides an interface between MATLAB and OpenCL in a fashion similar to that of Mathematica's OpenCLLink. Control everything in the environment, copy data back and forth, launch threads in an intuitive fashion, all organized in a class and done by simple function interface. It takes only 2 calls to compile a kernel, copy buffers, launch threads and read the data back. The class includes:
obj = OpenCLInterface - Constructor which queries all available devices.
obj.PrintDevices - Print all available devices.
obj.GetGPUDevices - Get ids of all GPU devices.
obj.GetCPUDevices - Get ids of all CPU devices.
obj.CreateFunction - Read kernel code from file or string, compile it and cache it.
obj.Run - Launch the kernel with the specified local and global workloads, scalars and buffers with their memory flags. Buffers specified as Outputs will contain the result data after execution.
Sample Program layout:
obj = OpenCLInterface;

Cite As

MESC Labs (2021). OpenCL Matlab Wrapper (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)


We currently assess the functionality of this wrapper against the older (unmaintained) opencl toolbox. It seems that we identified a major limitation. It seems to be required to allocate for every device buffer a host buffer. Is there a way to avoid that?

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!