LKeene's picture

Some basic confusion about OpenTK/OpenCL

Hello all, I happened across this corner of the web while researching GPGPU tools. I'm a little confused about how to use OpenTK to write OpenCL-capable apps using C#/.NET. Do I simply install Nvidia's OpenCL driver for my video card, download/install OpenTK...and then start writing an OpenCL app? Also, are there any OpenCL tutorials on this forum?

Thanks in advance,
-L


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jimstein's picture

YES, you only need to install the latest drivers for your graphics card, they will have support for OpenCL 1.0

a good starging point for OpenCL is to have a look at http://www.multicoreinfo.com/2009/08/parprog-part-9/ and the links to papers and videos on that page.

To get OpenCL example running in OpenTk you need to open the file VectorAdd.cs in the OpenTK Solution and add #define EXPERIMENTAL, then compile and run and you will have the example to pick from the list. The support for OpenCL is as you can tell EXPERIMENTAL in the current version of OpenTk, but so is also Cloo http://sourceforge.net/projects/cloo/

LKeene's picture

Thanks for the reply! I'll take a look at the link asap.

One question, though: I don't quite understand the "#define EXPERIMENTAL" declaration...what is this doing? By "The support for OpenCL is as you can tell EXPERIMENTAL in the current version", do you mean Beta? Do I need to "#define EXPERIMENTAL" for my own apps when I start playing around with OpenTK.OpenCL?

Lastly, when I go to the Documentation portion of the OpenTK website, I see there isn't any documentation listed for the OpenCL namespace. Is there documentation included in the download?

Thanks,
-L

the Fiddler's picture

As nythrix said, pretty much. OpenTK 1.0 does not include OpenCL, so you'll have to check out OpenTK from trunk or download Cloo, which provides a much cleaner, object-oriented OpenCL API.

nythrix's picture

I think that you have to build OpenTK from source with a defined EXPERIMENTAL token to enable the OpenCL bindings. You don't have to define it for your app. There's also an OpenTK 1.1 available at sourceforge but I have no idea if it carries the bindings. Fiddler might tell you more on this.

If you want a kick-start, Cloo includes example bits, embedded documentation (intellisense) and by accident distributes a prebuild OpenCL enabled OpenTK.dll (since its built atop of it).

Edit: beaten :)

the Fiddler's picture

OpenTK from trunk does not need the EXPERIMENTAL #define, OpenCL is enabled by default. Then again, Cloo is much easier to work with (that's why it was developed ;) ).

LKeene's picture

Hmm...lot's of people bringing up Cloo. I took a look at the webpage and it looks like it's in its very early stages (version 0.2.x). I like the idea of it being easier to use with examples, but based on peoples experience how stable/mature is it? And what's the outlook for that project i.e. is it very active?

Thanks for all the great feedback, I appreciate it!
-L

nythrix's picture

The existing version (0.5.1) is fine. Apart from image support and CL/GL sharing you get pretty much everything else.

Right now I'm putting together 0.6.0 and it is a major overhaul of the current release. It will be feature complete with its target being OpenCL 1.0.
Due out in three weeks, max.
And that answers your last question: Coding activity is peeking right now at ~50 commits in the past 7 days.

LKeene's picture

Cloo sounds great! Looking forward to version 1.0.

-L

jimstein's picture

So we are going so have two different wrappers for openCL, one in OpenTK and one in Cloo or will this projects be combined? It was because Tao Framework provided a complete unified package that I have preferred it over OpenTK.

Anyhow, I am also awaiting Cloo 0.6 eagerly before I start using openCL seriously as I don’t want to produce too much deprecated code.

Keep up the good work!

nythrix's picture

OpenTK offers the straight OpenCL functions as found in the official Khronos specs. Cloo adds a friendlier, .NETish API on top of it.
Right now we're focusing on getting the final versions of each project out. Their merge has been discussed and, I'm fairly sure, will be discussed again. But for the next two or three months nothing will change, I guess.