本文介绍了完整的.NET OpenCL的实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找全国各地,但有一点运气。是否有任何的有据可查的.NET绑定OpenCL的实现? (我会采取一些支持CUDA,如果我不得不)。我碰到的各种实现方式,CUDA.NET,OpenCL.NET,OpenTK / Cloo(我知道,他们往往计算器提到),但他们似乎都要么是处于alpha阶段或完全没有可用的例子。 CUDA.NET有一定的帮助文件,但它只是一个图书馆的参考,它并没有真正帮助您开始。

I've been looking all over but have had little luck. Are there any well documented .NET binding implementations for OpenCL? (I'd take something for CUDA if I had to).I've run into a variety of implementations, CUDA.NET, OpenCL.NET, OpenTK / Cloo (I know, they are mentioned often of stackoverflow), but they all seem to either be in alpha stage or have absolutely no available examples. CUDA.NET has some help files, but it's just a library reference, which doesn't really help you get started.

什么,我希望能找到一个的成熟的库在.NET GPU编程。最后,我需要能够写code F#中,但我会采取任何.NET兼容的语言,因为我可以永远只是后来转换和使用任何包含实例启动和运行。

What I'm hoping to find is a mature library for GPU programming in .NET.Eventually I need to be able to write the code in F#, but I would take any .NET compliant language as I could always just convert it later and use whatever examples are included to get up and running.

可能是一个长镜头,因为我已经找遍了,但我希望这只是其中的情况下,我不知道正确的事情来搜索之一。

Probably a long shot since I've searched all over, but I'm hoping this is just one of those case where I don't know the right thing to search for.

任何帮助将是很大的AP preciated。

Any help would be greatly appreciated.

推荐答案

嗯,你说的所有库都是简单包装针对OpenCL本机库。它们所构成相对少量的额外的抽象和非常接近一般的OpenCL功能。所以,如果你熟悉的OpenCL一般你会熟悉这些库在任何时间。

Well, all libraries you've stated are simple wrappers for opencl native libraries. They pose relatively small amount of additional abstractions and are very close to general opencl functions. So if you are familiar with opencl in general you will get familiar with these libraries in no time.

我觉得'OpenCL.NET实施完成后,它是免费的东西,是不是OpenCL的。但是用了几次后,我发现它太低的水平。

I think the 'OpenCL.NET' implementation is complete, it is free of anything that is not OpenCL. But after using it several times I've found it too low level.

我创建我自己的包装它通过大幅这里简化了主机部分提供了我很好的工作是我的一个项目的主机部分(如果你有兴趣,我可以在github上或任何其他的svn服务发布我的OpenCL包装):

I've created my own wrapper it serves me good job by simplifying the host part dramatically here's the host part of one of my projects (if you are interested I can publish my OpenCl wrapper in github or any other svn service):

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>());
            }
        }
    }
}

这篇关于完整的.NET OpenCL的实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 11:09