OpenCL Matlab Wrapper


Allowing Powerful And Simple Interfacing with Matlab

Overview

OpenCL Matlab Wrapper was developed by MESC Labs. It was released on Matlab Central File Exchange under the the BSD License.

The wrapper provides an interface between MATLAB and OpenCL in a way similar to that of Mathematica's OpenCLLink. Where you can control everything in the environment, copy data back and forth and launch threads in an intuitive fashion.

All of that is organized inside of a class and excuted by simple function interface. Where it takes only two calls to compile a kernel, copy buffers, launch threads and read the data back.

Files Listing

The pack includes the following files:


class_handle.hpp
Compile.m
Makefile
OpenCLInterface.m
OpenCLMexWrapper.cpp
OpenCLWrapper.cpp
OpenCLWrapper.h
SampleRun.m
TestKernel.cl

Class Contents

obj = OpenCLInterface

Constructor which queries all available devices.

obj.PrintDevices

Print all available devices.

obj.GetGPUDevices

Get classs of all GPU devices.

obj.GetCPUDevices

Get classs 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);