File Exchange

image thumbnail

OpenCL Matlab Wrapper

version 1.0.0.0 (17.7 KB) by

OpenCL wrapper for MATLAB that allows for powerful yet simple interfacing

2 Downloads

Updated

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;
obj.CreateFunction(deviceId,code,'KernelName');
obj.Run(globalWorkload,LocalWorkload,scalar,buffer1,MemoryFlagsOfBuffer1,buffer2,MemoryFlagsOfBuffer2);

Comments and Ratings (1)

Axel

Axel (view profile)

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

MATLAB Online Live Editor Challenge

Win cash prizes and have your live script featured on our website

Learn more

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

OpenCLWrapperMATLABMexInterface/