OpenCL 在 Java 中的原生程度如何?

发布于 2024-09-25 06:45:02 字数 149 浏览 4 评论 0原文

我看到有一个针对 Java 的 OpenCL 绑定。这是否使人们能够真正使用 Java 进行编程,使用 CPU / GPU 等作为处理核心,还是仅仅让 Java 应用程序能够访问支持 C++ OpenCL 的方法?

出于兴趣,是否有 .Net 的 OpenCL 绑定?

I see there is an OpenCL binding for Java. Does this enable one to truly program in Java, using CPU / GPU etc. as processing cores, or does it merely give Java apps access to C++ OpenCL enabled methods?

Out of interest, is there an OpenCL binding for .Net?

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

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

发布评论

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

评论(1

魔法唧唧 2024-10-02 06:45:02

支持 C++ OpenCL 的方法到底是什么?在 C++ 中,您可以访问 api 函数来创建上下文/缓冲区/内核/...,但是要在 GPU 上执行的代码必须使用 OpenCL C 语言编写,并作为源代码与应用程序一起分发(这意味着 OpenCL 是也不全是 C++ 原生的)。从我到目前为止所看到的来看,java也是如此(因此在这方面它与c ++一样是本机的或不是本机的,除了c ++比java更接近所使用的C方言(但不兼容)

。应该可以从编译的 java 类创建 OpenCL C 源并将其提供给编译器,创建编译器 java 字节码 <-> OpenCL C 需要相当多的努力,所以我认为这需要一些时间需要更多时间才能出现这种解决方案。此外,可以输入到该系统的代码会受到各种(看似任意的)限制(例如,没有递归),但是如果我没记错的话,Python 的某种本机解决方案已经存在。 ,所以可能不会花那么长时间。

没有“本地”绑定。

当然,我不知道每个 Java 库,并且将 OpenCl 与 java 结合使用现在不在我的待办事项列表中,所以我可能是错误的, 是 .Net 的绑定,例如 http://sourceforge.net/projects/cloo/

What exactly would a C++ OpenCL enabled method be? In c++ you have access to the api functions to create contexts/buffers/kernels/..., but the code to be executed on the gpu has to be written in the OpenCL C language and distributed as source with the application (meaning OpenCL is not all that native in C++ either). From what I have seen so far this is the situation for java too (so its as native or not native as c++ in that regards, except that c++ is a bit closer to the used C dialect then java (but not compatible).

While it should be possible to create a OpenCL C source from a compiled java class and feed that to the compiler, its quite a bit of efford to create a Compiler java bytecode <-> OpenCL C, so I'd think it will take some more time till that kind of solution appears. Furthermore there would be all kind of (seemingly abitrary) restrictions on the code which could be fed into this system (e.g. no recursion). However if I recall correctly a somewhat native solution for python already exists, so it might not take that long.

Of course I don't know every single Java library and using OpenCl with java is not on my to do list right now, so I might be wrong about there not being "native" bindings.

There are bindings for .Net, e.g. http://sourceforge.net/projects/cloo/

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