Javascript opencl to webcl

203 views
Skip to first unread message

wolfviking0

unread,
Mar 27, 2013, 6:37:25 AM3/27/13
to emscripte...@googlegroups.com
HI guys,

i m working on opencl library inside emscripten, i m starting to have some result but i have a very weird problem with parameter

C Part :

    int err;                            // error code returned from api calls
    cl_device_id device_id;             // compute device id
    cl_uint device_num;                    // compute device num
    int gpu = 1;
    err = clGetDeviceIDs(NULL, gpu ? CL_DEVICE_TYPE_GPU : CL_DEVICE_TYPE_CPU , 1, &device_id, &device_num);

Javascript Part

  clGetDeviceIDs: function(platform, device_type, num_entries, devices, num_devices) {
    console.log("platform : "+platform);
    console.log("device_type : "+device_type);
    console.log("num_entries : "+num_entries);
    console.log("devices : "+devices);
    console.log("num_devices : "+num_devices);
 },

If i do that my parameter are wrong, the console says :

[11:07:08,842] platform : 0 -> OK
[11:07:08,842] device_type : 4 -> OK
[11:07:08,842] num_entries : 0 -> WRONG
[11:07:08,842] devices : 1 -> WRONG
[11:07:08,842] num_devices : 8240 -> WRONG

if i change my number of parameter in javascript (i add empty), the console give the good result it's weird !!!!!

Javascript Part

  clGetDeviceIDs: function(platform, device_type, empty, num_entries, devices, num_devices) {
    console.log("platform : "+platform);
    console.log("device_type : "+device_type);
    console.log("num_entries : "+num_entries);
    console.log("devices : "+devices);
    console.log("num_devices : "+num_devices);
 },

[11:03:32,140] platform : 0 -> OK
[11:03:32,140] device_type : 4 -> OK
[11:03:32,140] num_entries : 1 -> OK
[11:03:32,140] devices : 8240 -> OK
[11:03:32,140] num_devices : 8244 -> OK


If somebody have an idea why i have this problem with this function.

Thanks

Tony

wolfviking0

unread,
Mar 27, 2013, 5:36:24 PM3/27/13
to emscripte...@googlegroups.com
Oki, i have more info about my problem,
The parameter who give me a problem is a mask
My function is : 
err = clGetDeviceIDs(0, 1<<3 , 1, &device_id, &device_num);

it's the bitmask who give me this error with javascript parameter.

I must do something wrong but i don't know what ;)

wolfviking0

unread,
Apr 1, 2013, 6:08:32 AM4/1/13
to emscripte...@googlegroups.com
Hi, i still working on webcl, and i have successfully build and execute my hello_world sample In opencl (i use the sample on the Apple website : http://developer.apple.com/library/mac/samplecode/OpenCL_Hello_World_Example/Introduction/Intro.html )

Anyway, i have some trouble with my result. I have some question ...

1) about my problem with parameter, i know is a problem when one of the parameter is bitmask, i can keep working because i had a parameter to my Javascript function but is a dirty way may be a better solution will be great.

2) one of my function in c++ take a référence of pointer, theorically this parameter it´s a refernce for put the list of devices. I want my Javascript put inside the parameter a list of integer, because i keep the devices In a javascript Array. The list will be the position of Device In my Array. How i can do that ???

I m not sure my problem is just that but before debug i need to have a clean code. My error it´s about the result of my kernel opencl. The kernel compute the square of list of 1024 float number. But the result it´s wrong 😳

Thanks for help me with my problems 😌

Tony

Alon Zakai

unread,
Apr 1, 2013, 6:33:17 PM4/1/13
to emscripte...@googlegroups.com
Is one of the parameters an i64 perhaps? Those turn into i32, i32 in function parameters. So corrupted/wrong parameters might be explained by that.

If that's not it, can you make a testcase for us to reproduce the problem with?

- azakai




--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

wolfviking0

unread,
Apr 3, 2013, 11:58:40 AM4/3/13
to emscripte...@googlegroups.com
Hi Alon,

Yep you have right, the two function who give me a problem take a cl_bitfield
cl_bitfield are cl_ulong,
cl_ulong are typedef unsigned __int64.

When you say convert tha parameter, you talk inside the javascript function  ????
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Alon Zakai

unread,
Apr 3, 2013, 2:34:10 PM4/3/13
to emscripte...@googlegroups.com
Yes. Look at the C code and the generated JS (when it tries to call it). The number of arguments will be different when there is an i64. So you must take that into account when writing the JS side.

- azakai



To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

wolfviking0

unread,
Apr 3, 2013, 2:49:11 PM4/3/13
to emscripte...@googlegroups.com
Ok I do that, i add one parameter more for that work. But in my case the first parameter has the good result, the second still with zero, for my test i use the first because that work. i must be do something with the two parameters i suppose ??

Tony
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Alon Zakai

unread,
Apr 5, 2013, 12:17:48 AM4/5/13
to emscripte...@googlegroups.com
If the high 32 bits are expected to not be used, I guess you can ignore them. In general cases though they need to be used.

- azakai



To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

wolfviking0

unread,
May 3, 2013, 5:53:43 PM5/3/13
to emscripte...@googlegroups.com

oscar barenys

unread,
May 7, 2013, 10:57:47 AM5/7/13
to emscripte...@googlegroups.com
Are you going to post patches to github?

wolfviking0

unread,
May 7, 2013, 2:23:06 PM5/7/13
to emscripte...@googlegroups.com
Hi Oscar,

i hope if everything ok, make a pull request the next week. Still experimental and work just with nokia plugin, i don't try yet the Webkit Samsung version of webcl.

Tony

oscar barenys

unread,
May 12, 2013, 11:03:48 AM5/12/13
to emscripte...@googlegroups.com
Thanks good to know..

wolfviking0

unread,
May 24, 2013, 2:18:28 PM5/24/13
to emscripte...@googlegroups.com
Hi,

I make an patched version of emscripten here(https://github.com/wolfviking0/webcl-emscripten) for build opencl sample to webcl.
With the last firefox build (21) some sample like (QJulia) doesn't work, it's for that i don't make pull request, but you can play with it if you want.

I try to keep the repository updated with the last incoming version of Emscripten.

Tony
Reply all
Reply to author
Forward
0 new messages