opencl矩阵库

发布于 2024-12-03 03:27:08 字数 380 浏览 1 评论 0原文

我想使用 OpenCL 将物理模拟算法移植到 GPU 上以提高性能;我没有 OpenCL 经验,我正在四处寻找。计算主要是小密集矩阵(3x3)和向量积、叉积等。

  1. 是否有一些“标准”/推荐的库用于此类基本操作?我当然不想自己编写矩阵乘法和求逆(不花时间,而且效率低下)

  2. 由于 OpenCL 没有类、运算符重载等,我是否必须编写 mmul(a,mtrans (b)) 而不是 a*b.transpose() 例如?

  3. OpenCL(或预处理器)是否有一些(计划中的)扩展/演进,以使符号更像数学?我的印象是回到了fortran年代。 (我知道有 CUDA,但它受供应商限制)

I would like to port a physics simulation algorithm to GPU using OpenCL for performance; I have no experience with OpenCL, and I am looking around. The computations are mostly small dense matrix (3x3) and vector products, cross-products and so on.

  1. Is there some "standard"/recommended library for such basic operations? I certainly don't want to code matrix multiplications and inversions myself (not time, and it would be inefficent)

  2. As OpenCL does not have classes, operator overloading etc, do I have to write mmul(a,mtrans(b)) instead of a*b.transpose() for instance?

  3. Are there some (planned) extensions/evolution of OpenCL (or pre-processor, for that matter) to make the notation more math-like? I have the impression of going back to fortran years. (I know there is CUDA, but it is vendor-bound)

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

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

发布评论

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

评论(2

回眸一笑 2024-12-10 03:27:08

回答你的问题:

  1. 据我所知
  2. ,是的,OpenCL 严格限于 C99 语法,因此没有类,没有运算符重载,并且对您想要的各种操作进行严格的过程调用。 OpenCL 支持对其本机向量类型进行元素明智操作,但没有比这更复杂的了。矩阵乘法、行列式、转置等都需要自己实现。
  3. 据我所知,这又不是。 [顺便说一句,我不会在这种情况下嘲笑 Fortran,F90 和更高版本具有内在的矩阵和向量运算,这使得您所询问的各种运算比 C99 或 C++ 更容易编写]。

To answer your questions:

  1. Not that I am aware of
  2. Yes, OpenCL is strictly limited to C99 syntax, so no classes, no operator overloading, and strictly procedural calls for the sorts of operations you have in mind. OpenCL supports element wise operations on its native vector types, but nothing more sophisticated than that. Matrix multiplication, determinant, transpose, etc. will all have to be implement yourself.
  3. Again not that I am aware of. [As an aside, I would not deride Fortran in this context, F90 and later versions have intrinsic matrix and vector operations which make the sorts of operations you are asking about far easier to write than C99 or C++].
世界如花海般美丽 2024-12-10 03:27:08

如果您知道自己仅限于 3 维对象,那么您可能会考虑使用 double3 类型(如果您的 GPU 不支持双精度,则使用 float3 类型)。

到目前为止,仅支持向量,因此您必须自己对矩阵乘法或求逆的任何使用进行一些编码。但是,您可能对以下内置 几何函数。特别是,dot 产品和 <定义了 href="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/cross.html" rel="noreferrer">交叉 产品。

您可能还有兴趣知道有 保留用于矩阵未来实现的数据类型:例如,参见 double n x m。就您的情况而言,如果将来可用,您将能够对矩阵使用 double3x3 类型。

If you know for a fact that you are limited to 3-dimensional objects, then you might consider using the double3 type (or float3 if your gpu doesn't support double precision).

So far, only vectors are supported, so you will have to do some coding yourself regarding any use of matrix multiplication or inversion. However, you might be interested in the following built-in geometric functions. In particular, dot products and cross products are defined.

You might also be interested to know that there are reserved data types for futures implentations of matrices: see for example double n x m. In your case, if available in the future, you will be able to use double3x3 types for your matrices.

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