Question

Basically I have a school assignment in which I have to write a function which takes in an OpenCL kernel (maybe as a byte buffer, or string), compiles it, executes it, in C#. I am having trouble with the concept of writing a C# function which can compile opencl kernel. Is there an example or links which can help me understand and write the function ?

I already have Intel opencl sdk and opencl.net integrated with my Visual Studio.

Was it helpful?

Solution

There are probably many ways to skin this cat, but one way is a .NET wrapper for OpenCL called cloo. I have an example project available for you to look at on my GitHub repo.

The gist is that cloo interfaces to the unmanaged OpenCL libraries. You actually write your kernel in a string, and use cloo's API to compile and execute it. Take a look at Julia.cs or Mandelbrot.cs in my repo. There are methods in each called CreateGPU which will show you how to work with the API.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top