matlab共享c++库和 OpenCL

发布于 2024-09-08 02:24:04 字数 124 浏览 4 评论 0原文

我有一个需要大量图像处理的项目,并且想要添加 GPU 支持来加快处理速度。

我想知道如果我将 matlab 编译成 C++ 共享库并从 OpenCL 程序中调用它,这是否意味着 matlab 代码将在 GPU 上运行?

I have a project that requires lots of image processing and wanted to add GPU support to speed things up.

I was wondering if i compiled my matlab into c++ shared library and called it from within OpenCL program, does that mean that the matlab code is going to be run on GPU?

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

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

发布评论

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

评论(4

塔塔猫 2024-09-15 02:24:04

我自己(半受过教育)的猜测是,你会发现这很难做到。但是,其他人也走了同样的道路。 本文可能是开始研究的好地方。谷歌搜索后发现了 Accelereyes 以及对 Mathworks File Exchange 上您可能想要关注的项目的一些引用向上。

My own (semi-educated) guess is that you are going to find this very difficult to do. But, others have trodden the same path. This paper might be a good place to start your research. And Googling turned up Accelereyes and a couple of references to items on the Mathworks File Exchange which you might want to follow up.

凉世弥音 2024-09-15 02:24:04

Jacket 中的所有内容都是用 c/c++/cuda 编写的。
事实上,我们现在有一个测试版 libjacket (http://www.accelereyes.com/downloadLibjacket),如果您愿意,它不仅可以用于扩展 matlab,还可以用于扩展其他语言。

@OSaad
我们的大多数功能都是最快的选项。无论是C语言还是matlab语言。

Everything in jacket is written in c/ c++ / cuda.
Infact we now have a beta version libjacket (http://www.accelereyes.com/downloadLibjacket) which can be used to extend not just matlab but other languages if you are willing.

@OSaad
Most of our functions are the fastest options out there. Be it in C or matlab.

夜还是长夜 2024-09-15 02:24:04

即将发布的 R2010b(9 月 1 日发布)中的并行计算工具箱支持多种功能的 GPU 处理。不幸的是,它只支持 CUDA(版本 1.3 及更高版本),因此对于 ATI 显卡,你就不走运了。然而,无论如何,您可能只想购买专用 GPU。

The Parallel Computing Toolbox in the upcoming release R2010b (due September 1st) supports GPU processing for several functions. Unfortunately, it only supports CUDA (version 1.3 and later), so with an ATI graphics card, you're out of luck. However, you may just want to buy a dedicated GPU, anyway.

如梦初醒的夏天 2024-09-15 02:24:04

通常,如果您可以以“矢量化”方式编写 Matlab 代码,那么像 AccelerEyes 和 Jacket 这样的软件包就有合理的机会让代码在 GPU 上运行。您可以通过检查 Matlab 本身是否能够在 CPU 上的多个内核上运行来预先在一定程度上验证这一点(现在,如果事物以明显的方式可并行化,Matlab 将使用多个内核)。

如果这不起作用,那么您需要通过 mex 转到 C/C++,然后从那里自己调用 OpenCL。 Mex 是 Matlab 与 C 代码对话的方式,因此您编写由 Matlab 调用的 C 代码(并接收矩阵等),然后初始化并调用 OpenCL。这是更多的工作,但可能是您唯一的途径(并且,即使自动化包在某种程度上起作用,这种方法仍然可以提供更多的加速,因为您可以更智能地进行内存管理,例如,如果您知道自己在做什么)。

Typically, if you can write your Matlab code in a "vectorized" way, then the packages like AccelerEyes and Jacket have a reasonable chance of making things run on the GPU. You can verify this to some extent beforehand by checking whether Matlab itself is able to run on multiple cores on the CPU (these days Matlab will use multiple cores if things are parallelizable in an obvious way).

If that doesn't work, then you need to drop down to C/C++ via mex and then, from there, call OpenCL yourself. Mex is how Matlab talks to C code, so you write C code that is called by Matlab (and receives the matrices, etc), then initialises and calls OpenCL. This is more work, but may be your only route (and, even if the automated packages work to some extent, this approach can still give more speedups because you can be smarter about memory management, for example, if you know what your are doing).

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