vicviper's picture

OpenCL support

Hi, I would like to port an existing project from C++ to c# as the current c++ branch is a maintenance nightmare.

The project relies heavily on Open CL , so, before porting it, I would like to know which is the state of the OpenCL wrapper; it is stable / tested? or it's still in beta?

I haven't seen any OpenTK + OpenCL project arround beyond the wrapper itself, is there something arround worth to take a look?

Thanks in advance

V


Comments

Comment viewing options

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

Check the Cloo project. Though not official OpenTK, the two work good together.
On paper the project is in alpha because I haven't bothered updating the status. So it's more like advanced beta. Or it could be sold as fully stable if it was commercial :)

kwaegel's picture

I have been using it as part of some ray tracing research, and I can say that it does work. You can look at my (unpolished, experimental and somewhat embarrassing) code at this gitHub page if you are interested.

That said, I have been getting some odd memory access exceptions from the Cloo library that I have not been able to trace down yet. In addition, my project will, starting at a recent commit (ab2e88, I believe), run on an 8600GT but crash on a GTX 470. In these cases, all I get is a terminated program and a memory access exception. Keep in mind that these issues may be due to my use of CL/GL interop, so you may not encounter any of them. Most of these issues occur during program shutdown, not execution.

Basically, Cloo is a great library (and I love programming in C# over C++) but, until I figure out if the above issues are in my code or Cloo, I can't really talk about how stable it is just yet. Your best bet, as always, is to try it out yourself with some simple kernels. It is more fun that way anyway.

Hopefully I will have some time this semester to figure out what is causing my memory issues and send nythrix a bug report/patch if necessary.

nythrix's picture
Quote:

That said, I have been getting some odd memory access exceptions from the Cloo library that I have not been able to trace down yet. In addition, my project will, starting at a recent commit (ab2e88, I believe), run on an 8600GT but crash on a GTX 470. In these cases, all I get is a terminated program and a memory access exception. Keep in mind that these issues may be due to my use of CL/GL interop, so you may not encounter any of them. Most of these issues occur during program shutdown, not execution.

I've had these sort of reports coming from different people. There IS something wrong but I can't figure out what. Sometimes problems go away when resources are freed manually. I'm "almost sure" Cloo leaves no garbage behind. I tested this several times. So, a problem might be the order of disposing objects. Also things on Mono aren't brilliant. And sometimes it's just the bloody drivers. This I have no way of telling, since it's hard to reproduce most of the cases in C/C++ (no Garbage Collector) and send them to nVidia/AMD/Intel.

Chances are bugs were introduced with 0.8. If going back to 0.7 solves your problem, then it's definitely Cloo's fault.

kwaegel's picture

Well, I just tried it out and I can get the same error to occur back to Cloo revision 3493ef (just after release 0.7.2). Before that, my program won't compile due to API changes. So much for that idea. It would have been a nice excuse to try git's bisect command. :p

Your comment about manually freeing resources is interesting. That seemed to work for me at one point (although not any more). The biggest issues I had there was that if something else in my code caused an error, it would "magically" turn into an AccessViolationException by the time it reached the visual studio debugger, leaving me with no idea what the original error was (typically a syntax error thrown by the openCL compiler).

I'll try writing a simple test case that exhibits this problem.

kwaegel's picture

I believe I have found the issue. To avoid further hijacking of this thread (sorry about that vicviper), I have started a new thread describing my results.

vicviper's picture

No problem on my side, I have not started yet the porting of my project, so any improvement/bugfix to CLOO is welcome.