PiRSquared17 / aparapi

Automatically exported from code.google.com/p/aparapi
Other
0 stars 0 forks source link

kernel.execute and getGlobalId should accept an array of ints #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I believe that according to 
http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/get_global_id.html 
the method getGlobalId() and correspondingly kernel.execute() should support an 
array of ints. This would allow us to navigate a table structure using 
different index values from the same global id.

The current work-around for this is to encode the table values in the single 
global id similar to:

final int i = this.getGlobalId() / some_variable;
final int j = this.getGlobalId() % some_variable;

Ideally we could do something similar to:

final int i = this.getGlobalId()[0]
final int j = this.getGlobalId()[1]

Original issue reported on code.google.com by ryan.lam...@gmail.com on 8 Nov 2011 at 5:15

GoogleCodeExporter commented 9 years ago
This is a follow-on request for the work that was completed in 
http://code.google.com/p/aparapi/issues/detail?id=10

Original comment by ryan.lam...@gmail.com on 10 Nov 2011 at 7:04

GoogleCodeExporter commented 9 years ago
Ryan, sorry  for the delay here. I am still thinking about this one. I think 
OpenCL's get_global_id(int dim) is not doing what you think here, however I am 
having a lack of confidence moment here ;) maybe it does and I don't actually 
understand it.  So I am reading the specs.  

Standby... ;) 

Original comment by frost.g...@gmail.com on 10 Nov 2011 at 7:33

GoogleCodeExporter commented 9 years ago
Alright I experimented with this yesterday.  You are correct I should have 
exposed the dimension access to allow width and height (and depth possibly) to 
kernel.execute() as well as provide mappings from getGlobalId(0..2) and 
getGlobalSize(0..2). 

This probably is not hard, and can be worked around so I am not sure it will be 
a high priority enhancement request.  Although probably a great project for 
someone to try to do.  ;) 

My suggestion is that we keep all the current API's but provide 
getGlobalId(int dim) mappings to opencl's get_global_id(int dim). We can keep 
the no-arg version as a helper for getGlobalId(0).  So getGlobalId() equiv of 
getGlobalId(0).

Same for getGlobalSize().

For Kernel.execute(range, itercount) I recommend adding 
Kernel.executeXY(xrange, yrange, itercount) and Kernel.executeXYZ(xrange, 
yrange, zrange, itercount) or possibly Kernel.execute1D, Kernel.execute2D or 
Kernel.execute3D if people find those names preferable.  

Most of this is name mapping in KernelWriter and of course some JNI to access 
the ranges. 

What do you think?  

Original comment by frost.g...@gmail.com on 17 Nov 2011 at 4:06

GoogleCodeExporter commented 9 years ago
You are correct, by encoding the values in the globalId we can work-around this 
issue for now.

I think it would be alright to simply overload the same method as long as the 
parameter names make sense and are documented appropriately.

For example:

Kernel.execute(xRange, iterCount);
Kernel.execute(xRange, yRange, iterCount);
Kernel.execute(xRange, yRange, zRange, iterCount);

Original comment by ryan.lam...@gmail.com on 17 Nov 2011 at 8:18

GoogleCodeExporter commented 9 years ago
Also, based some code we're investigating, we would also like to request 
getLocalId() accept a range of ints as well.

Please see:
http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/get_local_id.html

Original comment by ryan.lam...@gmail.com on 17 Nov 2011 at 10:32

GoogleCodeExporter commented 9 years ago
After further review of some algorithms we're exploring, it appears we need the 
all of the following methods to support 'uint dimindx':

http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/get_global_id.html
http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/get_global_size.html
http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/get_local_id.html
http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/get_local_size.html

Original comment by ryan.lam...@gmail.com on 25 Nov 2011 at 6:11

GoogleCodeExporter commented 9 years ago
I propose that this is fixed as part of the LocalMemory and MultiDim branch 
merge (r#258)

Ryan can you validate. 

Original comment by frost.g...@gmail.com on 14 Feb 2012 at 5:41

GoogleCodeExporter commented 9 years ago

Original comment by frost.g...@gmail.com on 14 Feb 2012 at 5:46

GoogleCodeExporter commented 9 years ago
Thanks Gary!

Original comment by ryan.lam...@gmail.com on 14 Feb 2012 at 9:49