As promised screenshot of OpenCL on an Nvidia GTX 470:
Thanks. I probably should have posted the Cloo OpenCL code it was designed to replicate for comparison:
int count = 10; float[] arrA = new float[count]; float[] arrB = new float[count]; float[] arrC = new float[count]; Random rand = new Random(); for (int i = 0; i < count; i++) { arrA[i] = (float)(rand.NextDouble() * 100); arrB[i] = (float)(rand.NextDouble() * 100); } ComputeBuffer<float> a = new ComputeBuffer<float>(context, ComputeMemoryFlags.ReadOnly | ComputeMemoryFlags.CopyHostPointer, arrA); ComputeBuffer<float> b = new ComputeBuffer<float>(context, ComputeMemoryFlags.ReadOnly | ComputeMemoryFlags.CopyHostPointer, arrB); ComputeBuffer<float> c = new ComputeBuffer<float>(context, ComputeMemoryFlags.WriteOnly, arrC.Length); ComputeProgram program = new ComputeProgram(context, kernelSource); program.Build(null, null, null, IntPtr.Zero); ComputeKernel kernel = program.CreateKernel("VectorAdd"); kernel.SetMemoryArgument(0, a); kernel.SetMemoryArgument(1, b); kernel.SetMemoryArgument(2, c); ComputeCommandQueue commands = new ComputeCommandQueue(context, context.Devices[0], ComputeCommandQueueFlags.None); ICollection<ComputeEventBase> events = new Collection<ComputeEventBase>(); commands.Execute(kernel, null, new long[] { count }, null, events); arrC = new float[count]; GCHandle arrCHandle = GCHandle.Alloc(arrC, GCHandleType.Pinned); commands.Read(c, true, 0, count, arrCHandle.AddrOfPinnedObject(), events); arrCHandle.Free();
It then compares the result of the OpenCL kernel function and the labview addition function - if all went well the difference should be zero.
Yes, that is actually the reason we got an Nvidia card in the project computer. There were two main reasons for me using OpenCL instead of that though:
That implementation only works on 32 bit windows - I want to use (and am using) 64 bit windows (even though we did dual boot that computer with both 32bit and 64 bit windows so we could use CUDA if we chose to).
I have an ATI card at home so I wanted to be able to dev my code at home and in uni, CUDA only works on Nvidia cards. + The ATI SDK lets you run OpenCL on the CPU which is useful it I only have my laptop.
N/P this is only work in progress (the main subset of features implemented, minimal documentation) , but functional enough to let people play with. I'm really just throwing this out there because when I was looking for something to let me do OpenCL in LabVIEW all I saw were people asking if it would be supported, so I decided to release it early in a somewhat un-polished state so at least there's something to get people started.