我们可以用 OpenCL 做什么?

发布于 2024-11-02 01:17:13 字数 338 浏览 7 评论 0原文

我一直在阅读有关 OpenCL 的内容,并发现了这一行:

OpenCL 允许任何应用程序访问图形处理单元以进行非图形计算。

假设我需要在 Java 或 Clojure 中执行 CPU 密集型操作或算法(甚至可能运行 Hadoop MapReduce),我可以使用 OpenCL 在 GPU 中执行该操作吗?如果是的话,我为什么要这么做?

如果我们有CPU,为什么还要使用GPU?

OpenCL应用场景有哪些?

我读到 OpenCL 提供并行编程,这是否意味着它将跨 CPU 和 GPU 划分目标作业?还是单独通过 GPU?

I have been reading about OpenCL and I found this line:

OpenCL gives any application access to the Graphics Processing Unit for non-graphical computing.

Lets say I need to execute a a CPU intensive operation or an algorithm in Java or Clojure (or even maybe running Hadoop MapReduce), could I execute the operation in GPU using OpenCL? if yes, why I would do that?

If we have CPU, why to use GPU?

What are the scenarios of OpenCL applications?

I read that OpenCL provides parallel programming, does this mean it will partition a target job across the CPU and the GPU? or across the GPU alone?

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

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

发布评论

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

评论(3

茶底世界 2024-11-09 01:17:13

OpenCL 为并行机上的编程提供了一个可移植的接口。 OpenCL 程序可以在 CPU 或 GPU 上运行。我还没有见过能够同时在 CPU 和 GPU 上运行代码的技术。

使用 GPU 进行通用计算利用了这样一个事实:GPU 实际上是由数百甚至数千个简单的小型处理元件 (PE) 构建而成。对于某些任务,这种架构可能能够在 CPU 所需时间的一小部分内完成任务。

GPU 的一个缺点是它们实际上是变体 SIMD(单指令多数据)机器;因此,大量的 PE 被迫同时执行相同的操作,但针对不同的数据。这种限制使得程序设计变得更加困难。

GPU 非常适合任何可以并行化且不需要不同线程之间进行大量通信的任务。 NVIDIA CUDA 和 OpenCL 等技术已开始在科学应用和高性能计算中大量使用,这两种技术都相当重视并行性。

OpenCL provides a portable interface for programming on parallel machines. OpenCL programs can be run on the CPU or the GPU. I've not seen technology that will run the code across both the CPU and the GPU at once.

Use of GPUs for general purpose computing leverages the fact that GPUs are actually built from hundreds or even thousands of simple, small processing elements (PEs). For some tasks, this architecture may be able to complete the task in a fraction of the time required by the CPU.

One drawback of GPUs is that they are really mutant SIMD (Single Instruction Multiple Data) machines; thus large groups of the PEs are constrained to be executing the same operation at the same time, but on different data. This constraint makes designing the program a little bit more difficult.

GPUs are very good for any task that can be parallelized without requiring much communication between different threads. Technologies like NVIDIAs CUDA and OpenCL have begun to see significant amounts of use in scientific applications and High-Performance Computing, both of which exploit parallelism rather heavily.

陌路黄昏 2024-11-09 01:17:13

OpenCL 是在科学家发现 GPU 架构能够非常高效地执行线性代数计算后开发的。

线性代数问题往往很容易并行化,并且在单个元素上非常简单。在大多数向量和矩阵运算中,只需要四个基本数学函数 +、-、/ 和 *。此外,还对最大和最小搜索进行了一些比较,并且能够在并行环境中完成大量工作。如果问题规模足够大,以至于数据从 RAM 复制到 GPU 并返回的额外时间远小于 GPU 的速度增益,则性能会大幅提高。

这些技术是从那时起开发的。第一次计算是通过将问题转换为图形问题并返回来进行的。 OpenCL 的开发是为了提供一个干净的计算接口。

OpenCL适合那些可以并行运行、没有太多依赖关系并且需要大量计算能力的问题。线性代数、搜索算法、信号变换和 3D 场景以及碰撞检查都是典型的例子。

OpenCL was developed after scientist found out that the GPU architecture was able to perform Linear Algebra calculations very efficiently.

Linear Algebra problems tend to be very easily to parallelize and to be quite simple on the single elements. In most vector and matrix operations one only needs the four basic mathematical functions +, -, / and *. Additionally, some comparisons for Max and Min searches and one is able to do a lot of work in a parallel environment. If the problem size is large enough that the additional time of data copy from RAM to GPU and back is much smaller than the speed gain of the GPU, one reaches large performance increases.

The techniques were developed since than. The first calculations were performed by converting the problems into graphical problems and back. OpenCL was developed to provide a clean interface for calculations.

OpenCL is suitable for problems which can be run in parallel without too much dependencies and which need a lot of calculation power. Linear Algebra, search algorithms, transformations of signals and 3D scenes and colission checks are classic examples.

记忆之渊 2024-11-09 01:17:13

英特尔对 openCL 的热情肯定不高。我不认为我能够在我的 Linux 系统上安装驱动程序,它们让它变得如此尴尬。还有其他技术,例如德州仪器 (TI) 的数字信号处理芯片。
如果可以的话我会使用 openCL。然而,对于相当多的应用程序来说,使用一组廉价的 ARM 板有一些优势。易于编程非常重要,而不是假设存在但从未实际使用过的东西。

Intel are certainly less than enthusiastic about openCL. I don't think I will be able to install the drivers on my linux system, they have made it so awkward. There are other technologies such as the Digital Signal Processing chips from Texas Instruments.
I would use openCL if I could. However there are some advantages to using say a cluster of cheap ARM boards for quite a lot application. Ease of programming being very important rather than something being hypothetically there but never actually used.

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