编写openCL代码时,它在没有GPU的单核机器上表现如何?

发布于 2024-10-15 05:46:48 字数 416 浏览 1 评论 0原文

嘿大家, 我目前正在将光线追踪器从 FORTRAN 77 移植到 C 语言以进行研究项目。

移植了要点之后,问题是我们如何进行并行化。
在实验室中,我可以使用几台不同的 Opteron 机器,具有 2 到 8 个内核,但没有 GPU(目前)。 我们正在运行 64b gentoo。

GPGPU 版本将是(非常)理想的,但由于项目中只有一名程序员,因此无法选择维护单独的非 GPU 和 GPU 版本。
此外,该代码将采用 GPL,我们希望看到它被其他可能拥有截然不同硬件的人使用。

因此,整个程序必须易于编译/运行,无需 GPU 甚至多核系统。
OpenCl 似乎是一个不错的选择,因为它可以在没有 GPU 的机器上运行,但是此代码在单核或 32b 系统上将如何执行?
是否可以以这样的方式编写代码,使其无需 openCL 即可轻松编译?

Hey all,
I Am currently porting a raytracer from FORTRAN 77 to C for a research project.

After having ported the essentials, the question is how we proceed to parallelization.
In the lab, I have access to a couple of different Opteron machines, with between 2 and 8 cores, but no GPUs (for now).
We are running 64b gentoo.

A GPGPU version would be (very) desirable, but with only one programmer on the project, maintaining separate non-GPU and GPU versions isn't an option.
Also, the code will be GPLed, and we'd like to see it being used by others that may have vastly different hardware.

So the entire program has to be easy to compile/run without having a GPU or even a multicore system.
OpenCl seems like a good option, as it can be run on machines without GPUs, but how will this code perform on a single-core or 32b system?
Would it be possible to write the code in such a way that it can easily be compiled without openCL?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我家小可爱 2024-10-22 05:46:48

目前有四种主要的 OpenCL 实现:AMD、nVidia (Cuda)、Apple、Intel,并且很快可能还会有更多:OpenCL 实现
OpenCL并不是专门针对GPU计算的语言,它被设计为异构设备的通用计算语言。例如,即使没有 GPU 和任何非 AMD CPU(当然是 x86),您也可以使用 AMD 实现。

是否可以编写无需 openCL 即可轻松编译的代码?

正如你所说,这是一个单人项目,我怀疑这是否值得付出努力。

此代码在单核或 32b 系统上的执行情况如何?

与任何本机程序一样好运行。您可以通过 OpenCL 向量类型访问 SIMD。您可以通过工作组配置来处理线程。

但不要指望您可以从具有相同内核/工作组设置的每个设备中获得 100% 的性能。可以进行很多特定于设备的调整(OpenCL CPU 入门教程) 。

我会说选择 OpenCL。它为您的应用程序提供了更多可能性,并且它独立于平台。

Currently there are four major OpenCL implementations: AMD, nVidia (Cuda), Apple, Intel and there will be more soon probably: OpenCL implementations.
OpenCL is not a language specifically targeted at GPU computing, it was designed as generic computing language for heterogeneous devices. E.g. you can use the AMD implementation even with no GPU and any non-AMD CPU (x86 of course).

Would it be possible to write the code in such a way that it can easily be compiled without openCL?

As you say it's a one man project I doubt it will be worth the effort.

How will this code perform on a single-core or 32b system?

As good as any native program would run. You have access to SIMD through OpenCL vector types. And you can handle the threading through the work group configuration.

But don't expect that you can get 100% performance out of every device with the same kernel/ work group settings. There's a lot of device specific tweaking possible (OpenCL CPU Tutorial for a start).

I would say go for OpenCL. It provides more possibilities for your application and it's platform independet.

苍风燃霜 2024-10-22 05:46:48

利用 OpenCL 和 C99 的共性,并使用预处理器来处理差异,这可能是可行的。然后,您将拥有 C99 和 OpenCL 代码库合二为一。这是 SmallPT-GPU 中采用的方法。

但是,CPU 的 OpenCL 实现应该与任何可移植标量 C 代码一样好,如果您使用 OpenCL 的向量类型来允许可移植 SIMD,效果会更好。

It may well be feasible to exploit the commonality of OpenCL and C99, and use the pre-processor to handle the differences. Then, you would have a C99 and OpenCL codebase in one. This is the approach taken in SmallPT-GPU

However, the OpenCL implementations for CPU should be pretty much as good as any portable scalar C code, and better if you are using the vector types of OpenCL to allow portable SIMD.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文