Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed V8 in OpenCL application?

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?

like image 390
KernelJS Avatar asked Nov 16 '10 02:11

KernelJS


1 Answers

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.

like image 179
EnabrenTane Avatar answered Oct 20 '22 10:10

EnabrenTane