在 OpenCL 应用程序中嵌入 V8?
我正在使用 OpenCL 编写针对 NVidia CUDA 运行时的 GPGPU 内核。我最近在阅读 V8 并发现了描述 V8 嵌入技术的页面:
http://code .google.com/apis/v8/embed.html
是否可以将所有 OpenCL 函数“包装”在 V8“模板”中,以便我可以用 JavaScript 编写内核逻辑?
作为参考,Khronos 网站上有 OpenCL 1.1 C++ 绑定的链接。
我主要担心的是 OpenCL 严重依赖 OpenGL。 V8 OpenCL 包装器是否需要包装大部分 OpenGL(或者封闭源代码 CUDA 运行时)?或者根本不可能协调 V8 虚拟机和 CUDA 运行时?
I am using OpenCL to write GPGPU kernels which target the NVidia CUDA runtime. I was recently reading up on V8 and found the page describing V8 embedding techniques:
http://code.google.com/apis/v8/embed.html
Is it possible to 'wrap' all the OpenCL functions in V8 'templates' so that I can write kernel logic in JavaScript?
For reference, links to the OpenCL 1.1 C++ bindings are on the Khronos web site.
My main concern is that OpenCL relies heavily on OpenGL. Would a V8 OpenCL wrapper entail wrapping large portions of OpenGL (or prohibitively, the closed-source CUDA runtime) as well? Or is it simply impossible to reconcile the V8 virtual machine and CUDA runtimes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是“可能的”,但很可能是不可行和不切实际的。解释器本质上是串行处理器。您必须为每个线程(或至少使用共享内存的每个线程组生成一个解释器,但是如果它们使用相同的解释器实例,您将必须处理相互踩踏的线程)。大多数显卡没有内存来执行此操作。我想你可以映射共享主机内存来解决这个问题。
底线。
可能是的,但是你会违背 OpenCL 快速的目的,它实际上会慢数百倍甚至数百万倍,并且极其难以实现。
It may be "possible" but most likely infeasible and impractical. Interpreters are inherently serial processors. You would have to spawn an interpreter for each Thread ( or at least each Thread Group using shared memory, but then you would have to deal with threads stomping on each other if they used the same interpreter instance ). Most video cards do not have the memory to do this. I suppose you could map shared Host memory to get around this.
Bottom Line.
Possible yes, But you would defeat the purpose of OpenCL being fast and it would be literally hundreds if not millions of times slower and extremely hard to implement.