在 c# 中使用 GPU

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/375011/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 01:05:21  来源:igfitidea点击:

Utilizing the GPU with c#

c#gpugpgpu

提问by

I am trying to get more processing power out of my grid.

我试图从我的网格中获得更多的处理能力。

I am using all cpus/cores, is it possible to utilize the GPU with C#.

我正在使用所有 CPU/内核,是否可以将 GPU 与 C# 一起使用。

Anyone know any libraries or got any sample code?

任何人都知道任何库或有任何示例代码?

回答by Greg Dean

Managed DirectX somehow, might work

以某种方式管理 DirectX,可能会工作

回答by Dave R.

Could I recommend XNA Game Studio as a possible avenue for exploration? It is obviously geared up for writing games, but gives you managed access to your graphics card and much better access to capability enumeration functions and shader development than was previously available in, say, Managed DirectX. There are also ways of combining WinForms and XNA into hybrid applications:

我可以推荐 XNA Game Studio 作为探索的可能途径吗?它显然是为编写游戏而准备的,但可以让您管理访问您的图形卡,并比以前在 Managed DirectX 中提供的功能更好地访问功能枚举功能和着色器开发。还有一些方法可以将 WinForms 和 XNA 组合成混合应用程序:

http://www.ziggyware.com/news.php?readmore=866

http://www.ziggyware.com/news.php?readmore=866

You'll have to put some effort into learning shader programming (XNA supports HLSL), but this may be a simpler approach than learning a vendor-specific solution such as nVidia's CUDA. The advantage is that you can program in a 100% managed environment. Here are some HLSL links:

您必须努力学习着色器编程(XNA 支持 HLSL),但这可能比学习特定于供应商的解决方案(如 nVidia 的 CUDA)更简单。优点是您可以在 100% 托管环境中进行编程。以下是一些 HLSL 链接:

http://www.ziggyware.com/weblinks.php?cat_id=9

http://www.ziggyware.com/weblinks.php?cat_id=9

The GPGPU site is also a recommended destination for general purpose GPU programming:

GPGPU 站点也是通用 GPU 编程的推荐目的地:

http://gpgpu.org/

http://gpgpu.org/

Best of luck!

祝你好运!

回答by Mark Cidade

Microsoft Research Acceleratorwas a .NET GP GPU library.

Microsoft Research Accelerator是一个 .NET GP GPU 库。

回答by Vyas Bharghava

I found Brahma... It also has a GPGPU provider that allows methods to run on the GPU... Thanks for the question... Learnt something new today. :)

我找到了Brahma......它还有一个 GPGPU 提供程序,允许方法在 GPU 上运行......谢谢你的问题......今天学到了一些新东西。:)

回答by Mark Cidade

WPF also uses the GPU and you can add custom shaders using HLSL.

WPF 还使用 GPU,您可以使用 HLSL 添加自定义着色器。

回答by Coderer

If your GPUs are all the same brand, you might be able to get GPGPU support from the vendor, either through Nvidia's CUDA or ATI's Stream. AFAIK, they provide DLLs, which you could use through P/Invoke.

如果您的 GPU 都是同一个品牌,您或许可以通过 Nvidia 的 CUDA 或 ATI 的 Stream 从供应商处获得 GPGPU 支持。AFAIK,他们提供 DLL,您可以通过 P/Invoke 使用它们。

回答by David Cuccia

In addition to Brahma, take a look at C$(pronounced "C Bucks"). From their CodePlex site:

除了 Brahma,看看C$(发音为“C Bucks”)。从他们的 CodePlex网站

The aim of [C$] is creating a unified language and system for seamless parallel programming on modern GPU's and CPU's.

[C$] 的目标是为现代 GPU 和 CPU 上的无缝并行编程创建统一的语言和系统。

It's based on C#, evaluated lazily, and targets multiple accelerator models:

它基于 C#,懒惰评估,并针对多个加速器模型:

Currently the list of intended architectures includes GPU, Multi-core CPU, Multi-GPU (SLI, CrossFire), and Multi-GPU + Multi-CPU Hybrid Architecture.

目前预期的架构列表包括 GPU、多核 CPU、多 GPU(SLI、CrossFire)和多 GPU + 多 CPU 混合架构。

回答by pointernil

How about http://www.tidepowerd.com/GPU.NET ?

如何http://www.tidepowerd.com/GPU.NET?

回答by BlueRaja - Danny Pflughoeft

Here's another one: CUDAfy. It sounds like GPU.Net, in that something as simple as a method-attribute can cause the entire method to run on the GPU. But unlike GPU.Net, CUDAfy is free and open-source.

这是另一个: CUDAfy。这听起来像 GPU.Net,因为像方法属性这样简单的东西可以导致整个方法在 GPU 上运行。但与 GPU.Net 不同的是,CUDAfy 是免费和开源的。

GPU.Net appears to require no boilerplate code, though (According to their docs, it's "injected automatically by the build-tool"), while CUDAfy does.

不过,GPU.Net 似乎不需要样板代码(根据他们的文档,它是“由构建工具自动注入的”),而 CUDAfy 则需要。



Hereis an example of building an application with CUDAfy.

是使用 CUDafy 构建应用程序的示例。

回答by David Cuccia

There's a new Microsoft solution in town - C++ AMP(intro here).

镇上有一个新的 Microsoft 解决方案 - C++ AMP(介绍在这里)。

Use from C# would be via P/Invoke, as demoed herefor desktop apps, and herefor (don't-call-it) Metro apps.

从 C# 中使用将通过 P/Invoke,如此为桌面应用程序演示,此处为(不要调用)Metro 应用程序。

Edit:I should note that C++ AMP has an open specification, which means it's not necessarily just for the MS compiler, or just for Windows.

编辑:我应该注意到 C++ AMP 有一个开放规范,这意味着它不一定只适用于 MS 编译器,或者只适用于 Windows。

Edit:Apparently, the technology is now in "maintenance mode,"meaning they're fixing bugs, but not actively developing.

编辑:显然,该技术现在处于“维护模式”,这意味着他们正在修复错误,但并未积极开发。