且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在编写openCL代码时,它如何在没有GPU的单核计算机上执行?

更新时间:2022-12-23 08:53:36

当前有四个主要的OpenCL实现:AMD,nVidia(Cuda),Apple,Intel,并且很快就会出现:OpenCL实施. OpenCL不是专门针对GPU计算的语言,它是为异构设备设计的通用计算语言.例如.您甚至可以在没有GPU和任何非AMD CPU(当然是x86)的情况下使用AMD实现.

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).

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

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.

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

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

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

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.

但是,不要指望在具有相同内核/工作组设置的每台设备上都能获得100%的性能.有许多特定于设备的调整( OpenCL CPU入门指南)

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).

我会说选择OpenCL.它为您的应用程序和平***立性提供了更多可能性.

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