好吧,您所说的所有库都是 opencl 本机库的简单包装器。它们构成了相对少量的附加抽象,并且非常接近一般的 opencl 函数。因此,如果您总体上熟悉 opencl,您将很快熟悉这些库。
我认为“OpenCL.NET”的实现是完整的,它没有任何不是 OpenCL 的东西。但是用了几次之后,我发现它的水平太低了。
我已经创建了自己的包装器,它通过显着简化主机部分为我提供了很好的服务,这是我的一个项目的主机部分(如果您有兴趣,我可以在 github 或任何其他 svn 服务中发布我的 OpenCl 包装器):
using System;
using System.Net;
using System.Collections.Generic;
using System.IO;
using Shared;
using Shared.IO;
using Shared.OpenCL;
namespace Testing
{
public class ApplicationClass
{
static Random rand = new Random();
static Single[] RandomArray(Int32 length)
{
Single[] result = new Single[length];
for (int i = 0; i < result.Length; i++)
{
result[i] = (Single)rand.NextDouble();
}
return result;
}
static void Main(string[] args)
{
DeviceGlobalMemory output = new Byte[4096];
DeviceGlobalMemory indeces = RandomArray(102400);
DeviceGlobalMemory ops = new Byte[3072];
DeviceGlobalMemory data = RandomArray(1048576);
Console.Write("Creating kernel...");
Kernel kernel = Kernel.Create("Kernel", File.ReadAllText("Test.c"), data, indeces, ops, output);
Console.Write("Executing kernel...");
Event e = kernel.Execute(256, 256);
kernel.CommandQueue.Finish();
Console.WriteLine("done, operation took {0}", Profiler.DurationSeconds(e));
UnmanagedReader reader = new UnmanagedReader(new DeviceBufferStream(output));
for (int i = 0; i < 256; i++)
{
if (i % 4 == 0) Console.WriteLine();
if (i % 16 == 0) Console.WriteLine();
Console.Write("{0}\t", reader.Read<Single>());
}
}
}
}