如何解决完整的.NET OpenCL实现
| 关闭。这个问题是题外话。它当前不接受答案。解决方法
好吧,您已经说过的所有库都是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>());
}
}
}
}
,OpenTK还有另一个绑定库,网址为http://sourceforge.net/projects/cloo/。
他们将其定位为“与原始绑定相比(与原始绑定相比,它提供了更简洁的OpenCL API(如果需要它们也可以提供)”)和“ Cloo是开放源代码,易于使用的托管库,可启用.NET / Mono应用程序可充分利用OpenCL框架。”
样品看起来很有希望。
,我也有一组开源的OpenCL绑定。净。我主要是为自己编写的,因此在与.NET友好的同时,它会忠实地反映OpenCL API。该库永远不会有任何OOP抽象,并且性能相当不错。
http://openclnet.codeplex.com
希望这可以帮助。
,这些年来,我使用了一些不同的C#OpenCL包装器,现在正在使用NOpenCL。它写得很好,并已获得MIT许可。
https://github.com/tunnelvisionlabs/NOpenCL
,我同意olegz的回答。
我只是开始使用OpenCL,但Cloo似乎是一个很好的选择。我发现它非常易于使用,并且从许多来源得知它的功能也非常丰富。
请访问以下网站,其中还包括Cloo的一些示例:
http://www.cmsoft.com.br/
,我一直在使用OpenCLTemplate。
您可以在这里找到很棒的教程:
http://www.cmsoft.com.br/index.php?option=com_content&view=category&layout=blog&id=41&Itemid=75
对我来说很好。我建议您也应该检查Cloo。
,对于F#,我发现了这一点:https://github.com/GabrieleCocco/FSCL.Compiler(从FSharp到OpenCL编译器)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。