English 中文(简体)
GPGPU图书馆所需咨询
原标题:Advice needed regarding GPGPU library

我正在撰写一份申请,最后还有相当平行的部分:

two dimensional float initialData and result arrays
for each cell (a, b) in result array:
    for each cell (i, j) in initialData:
        result(a, b) += someComputation(initialData(i, j), a, b, i, j, some global data...);

关于算法的更多细节:

  • I d like to make the first loop s iterations to run concurrently (perhaps there is better approach?)
  • Initial data is accessed in read-only way
  • someComputation is fairly simple, it involves multiplication, addition, cosine computing, so it could be accomplished by GPU, however, it needs the indexes of elements it is currently working on
  • Arrays won t exceed ~4000 in any dimension

图书馆性质:

  • Program is going to be written in C# (with WPF), so it would be nice if it (already) had easy-to-use .NET bindings
  • If there is no GPU found, algorithm should run on CPU
  • Program is going to be Windows-only and Windows XP support is highly preferable.
  • Algorithm can be rewritten in OpenCL, however, I believe it is not as widely supported as pixel shaders. But, if there are no alternatives, OpenCL would be fine. (AFAIK CUDA runs only on nVidia GPU s and OpenCL covers both nVidia s and AMD s GPU s)

I have tried to look at Microsoft Accelerator library, but I haven t found a way to pass in array indexes. Any help would be apprectiated and excuse me for my english.

问题回答

There is low-level OpenCL bindings: OpenCL.NET: http://openclnet.codeplex.com/. Also, exists OpenCL.NET based bindings for F#: https://github.com/YaccConstructor/Brahma.FSharp

它允许你通过开放式法律在万国邮联上写“本国”F#代码。 例如,矩阵重复法(没有供应商配置):

//Code for run on GPU
let command = 
    <@
        fun (r:_2D) columns (a:array<_>) (b:array<_>) (c:array<_>) -> 
            let tx = r.GlobalID0
            let ty = r.GlobalID1
            let mutable buf = c.[ty * columns + tx]
            for k in 0 .. columns - 1 do
                buf <- buf + (a.[ty * columns + k] * b.[k * columns + tx])
            c.[ty * columns + tx] <- buf
    @>

//compile code and configure kernel
let kernel, kernelPrepare, kernelRun = provider.Compile command
let d =(new _2D(rows, columns, localWorkSize, localWorkSize))
kernelPrepare d columns aValues bValues cParallel
//run computations on GPU
let _ = commandQueue.Add(kernelRun()).Finish()            

//read result back
let _ = commandQueue.Add(cParallel.ToHost(kernel)).Finish()




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签