uci_grad
uci_grad

Reputation: 69

Can I use external OpenCl libraries?

I want to use some external libraries (http://trac.osgeo.org/geos/) to perform some analytical tasks on Geometry objects(GIS). I want to perform these task using OpenCL on Cuda so that I can use the paralel power of GPU to perform these tasks in parallel on large set of data.So my question is:

  1. Can I write kernel using these libraries?

  2. Also How can I pass the objects of complex data structures of these libraries as an argument to the kernel/(in specific How can I create buffer of these complex objects??

Upvotes: 3

Views: 2401

Answers (2)

Ani
Ani

Reputation: 10896

An OpenCL program mostly consists of two parts

  1. Host code - This is regular C/C++ code that calls functions in the OpenCL runtime and works just like any other code. This code needs to interface with any third-party libraries that may provide your program with (complex) data. It will also need to translate these complex data types to a set of simple data types (scalar, vector, other) that can be processed by piece 2.
  2. Kernel code - The consists of a compiler that can convert a text/binary representation of a restricted kernel language (based on C99) to object code that can run on the target platform. This language and compiler has many restrictions including the fact that you cannot include/link in external libraries (maybe possible with native kernel that is runnable on the host CPU)

It is upto your host code to compile/setup the kernel, fetch/set up the data from any library/source, translate it into the appropriate scalar, vector or other data types permissible in an OpenCL kernel, run the kernel(s) that process the data and get the results back from the compute device to the host (if necessary) and then translate those simple data types back to whatever form required for consumption by the rest of the code.

So no - you cannot directly use a regular C++ library from inside the kernel. But you can do whatever you want to in the host code.

Upvotes: 8

RolandXu
RolandXu

Reputation: 3678

No, you can't use external libraries in OpenCL kernels. Remember, any kernels is required to be compiled when the OpenCl application runs because it can't know what platform it is running on beforehand.

Upvotes: 6

Related Questions