jordan30001 / aparapi

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

Suggestion to support structs (classes) #29

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I noticed a comment in the Wiki describing the lack of struct support due to a 
mismatch in the C and Java memory models.

On a different Java/JNI open-source project I am working with structs are 
supported using custom annotations.

Here is a link to the documentation: 
https://www.alljoyn.org/sites/default/files/alljoyn-development-guide-java-sdk.p
df

5.4.2 Complex data types using the @Position annotation

Here is some example code from the documentation:

public class ImageInfo{
    @Position(0)
    public String fileName;
    @Position(1)
    public int isoValue;
    @Position(2)
    public int dateTaken;
}

Is this something we would like to consider for Aparapi and OpenCL structs?

Original issue reported on code.google.com by ryan.lam...@gmail.com on 29 Dec 2011 at 4:21

GoogleCodeExporter commented 9 years ago
The code (added by Eric Caspole) supporting arrays of objects actually solves 
some of this (albeit with specific constraints).  We can access arrays of 
objects from Aparapi and the OpenCL code generated actually creates a 
contiguous block of memory (essentially a contiguous array of structs) which is 
accessed from OpenCL code. 

The issue is that an Array or collection of ImageInfo instances will not be 
placed in contiguous memory (same argument I have against 2d arrays :( ).  The 
code that Eric put together is forced to scan an incoming array of Java objects 
and copy the accessed fields into a single memory sequence. This is expensive 
as it happens each time we call Kernel.execute().

So I am not sure we need this as an enhancement, I think that the current array 
of objects feature will probably work for the application you have in mind. 

Regarding the @Position annotation.  We can determine the position of fields 
using the unsafe wrapper class. So thankfully we don't have to force the use of 
Annotations here. 

So Ryan can you take a look at the array of objects support and see if it works 
for you here?

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

GoogleCodeExporter commented 9 years ago

Original comment by frost.g...@gmail.com on 23 Feb 2012 at 8:13

GoogleCodeExporter commented 9 years ago
Gary,

Based on the new functionality in the Trunk for multi-dimensional arrays and 
the new AparapiBuffer class, is there any new features we can envision 
supporting additional 'struct' or 'arrays of objects' support?

Original comment by ryan.lam...@gmail.com on 22 Apr 2013 at 5:14