mtchamengo / aparapi

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

Simple object data access via getters and setters appears not to be working #102

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compile and run attached classes
2. Observe assertion error and exception thrown.
3.

What is the expected output? What do you see instead?

Program should run as is without error.

Instead there is an assertion error in the process of generating OpenCL C code 
at runtime.

What version of the product are you using? On what operating system?

Current trunk (r1116), on Mac OS X 10.8.3.

Please provide any additional information below.

Here is error output:

java.lang.AssertionError
    at com.amd.aparapi.internal.kernel.KernelRunner.execute(KernelRunner.java:1286)
    at com.amd.aparapi.Kernel.execute(Kernel.java:2410)
    at com.amd.aparapi.Kernel.execute(Kernel.java:2326)
    at com.amd.aparapi.Kernel.execute(Kernel.java:2308)
    at bug.BugBadObjectAccess.main(BugBadObjectAccess.java:16)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: com.amd.aparapi.internal.exception.CodeGenException: 
java.lang.AssertionError
    at com.amd.aparapi.internal.writer.KernelWriter.writeToString(KernelWriter.java:812)
    at com.amd.aparapi.internal.kernel.KernelRunner.execute(KernelRunner.java:1282)
    ... 9 more
Caused by: java.lang.AssertionError
    at com.amd.aparapi.internal.model.Entrypoint.getCallTarget(Entrypoint.java:1172)
    at com.amd.aparapi.internal.writer.KernelWriter.writeMethod(KernelWriter.java:272)
    at com.amd.aparapi.internal.writer.BlockWriter.writeInstruction(BlockWriter.java:758)
    at com.amd.aparapi.internal.writer.KernelWriter.writeInstruction(KernelWriter.java:787)
    at com.amd.aparapi.internal.writer.BlockWriter.writeInstruction(BlockWriter.java:509)
    at com.amd.aparapi.internal.writer.KernelWriter.writeInstruction(KernelWriter.java:787)
    at com.amd.aparapi.internal.writer.BlockWriter.writeSequence(BlockWriter.java:381)
    at com.amd.aparapi.internal.writer.BlockWriter.writeBlock(BlockWriter.java:393)
    at com.amd.aparapi.internal.writer.BlockWriter.writeMethodBody(BlockWriter.java:960)
    at com.amd.aparapi.internal.writer.KernelWriter.write(KernelWriter.java:728)
    at com.amd.aparapi.internal.writer.KernelWriter.writeToString(KernelWriter.java:804)
    ... 10 more

Original issue reported on code.google.com by n...@u1.com on 24 Mar 2013 at 12:29

Attachments:

GoogleCodeExporter commented 9 years ago
Yes I just recreated.  This is a big regression. Thanks for reporting.

It is also broken in the 'trunk-20130305' snapshot taken prior to the recent 
JNI refactoring. 

I need to back-track to see where this regression came from.

I will try to track this down today/tonight.

Apologies for this. 

Gary

Original comment by frost.g...@gmail.com on 24 Mar 2013 at 5:05

GoogleCodeExporter commented 9 years ago
There is a subtle gotcha with your app that might not be documented or maybe 
not tested correctly.
The problem is that "objects" is static. It ends up that the BugDataObject 
class is not processed correctly for oop conversion because it is a static 
field. Early versions of Aparapi had almost no support for static fields and 
this might be a lingerer from that.

I slightly modified the example as shown below and it works OK.

I have not looked at trunk in a while but we will see about fixing this so the 
example will work as is originally written.

==========

package bug;

import com.amd.aparapi.*;

public class BugBadObjectAccess extends Kernel
{
    BugDataObject [] objects = new BugDataObject[1024];

    public static void main(String[] args)
    {
        BugBadObjectAccess b = new BugBadObjectAccess();

//      for(int i = 0; i < objects.length; ++i)
//          objects[i] = new BugDataObject();

        b.execute(1024);
    }

    public BugBadObjectAccess() {
         for(int i = 0; i < objects.length; ++i)
             objects[i] = new BugDataObject();

    }

    @Override
    public void run()
    {
        int id = getGlobalId();

        int value = objects[id].getValue();
    }
}

Original comment by ecasp...@gmail.com on 25 Mar 2013 at 4:52

GoogleCodeExporter commented 9 years ago
Fixed in revision 1117, but there are still some issues with use of static 
fields. I modified the submitted example app into a test case. Thanks for that.

Original comment by ecasp...@gmail.com on 26 Mar 2013 at 3:37