rzel / aparapi

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

Bug when converting certain Java constructs to OpenCL #99

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compile and run attached samples
2. Observe exceptions thrown

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

Throws exception while attempting to convert run method.

There are 2 different exceptions thrown for the 2 different samples, though I 
expect the underlying bug is the same.

Here is the output from Child_List_Bug:

Scope block from 17 to  21
com.amd.aparapi.internal.exception.ClassParseException: 
java.lang.IllegalStateException: child list broken 
    at com.amd.aparapi.internal.instruction.ExpressionList.foldComposite(ExpressionList.java:822)
    at com.amd.aparapi.internal.model.MethodModel.foldExpressions(MethodModel.java:586)
    at com.amd.aparapi.internal.model.MethodModel.init(MethodModel.java:1676)
    at com.amd.aparapi.internal.model.MethodModel.<init>(MethodModel.java:1472)
    at com.amd.aparapi.internal.model.ClassModel.getMethodModel(ClassModel.java:2589)
    at com.amd.aparapi.internal.model.ClassModel.getEntrypoint(ClassModel.java:2622)
    at com.amd.aparapi.internal.model.ClassModel.getEntrypoint(ClassModel.java:2631)
    at com.amd.aparapi.internal.kernel.KernelRunner.execute(KernelRunner.java:935)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1909)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1840)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1825)
    at test.Child_List_Bug.main(Child_List_Bug.java:9)
    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: java.lang.IllegalStateException: child list broken 
    at com.amd.aparapi.internal.instruction.Instruction.setChildren(Instruction.java:104)
    at com.amd.aparapi.internal.instruction.InstructionSet$CompositeInstruction.<init>(InstructionSet.java:801)
    at com.amd.aparapi.internal.instruction.InstructionSet$CompositeIfElseInstruction.<init>(InstructionSet.java:862)
    at com.amd.aparapi.internal.instruction.InstructionSet$CompositeInstruction.create(InstructionSet.java:824)
    at com.amd.aparapi.internal.instruction.ExpressionList.addAsComposites(ExpressionList.java:831)
Scope block from 17 to  20
    at com.amd.aparapi.internal.instruction.ExpressionList.foldComposite(ExpressionList.java:695)
    ... 16 more
Mar 17, 2013 4:12:37 PM com.amd.aparapi.internal.kernel.KernelRunner 
warnFallBackAndExecute
WARNING: Reverting to Java Thread Pool (JTP) for class test.Child_List_Bug: 
java.lang.IllegalStateException: child list broken 
com.amd.aparapi.internal.exception.ClassParseException: 
java.lang.IllegalStateException: child list broken 
    at com.amd.aparapi.internal.instruction.ExpressionList.foldComposite(ExpressionList.java:822)
    at com.amd.aparapi.internal.model.MethodModel.foldExpressions(MethodModel.java:586)
    at com.amd.aparapi.internal.model.MethodModel.init(MethodModel.java:1676)
    at com.amd.aparapi.internal.model.MethodModel.<init>(MethodModel.java:1472)
    at com.amd.aparapi.internal.model.ClassModel.getMethodModel(ClassModel.java:2589)
    at com.amd.aparapi.internal.model.ClassModel.getEntrypoint(ClassModel.java:2622)
    at com.amd.aparapi.internal.model.ClassModel.getEntrypoint(ClassModel.java:2631)
    at com.amd.aparapi.internal.kernel.KernelRunner.execute(KernelRunner.java:935)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1909)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1840)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1825)
    at test.Child_List_Bug.main(Child_List_Bug.java:9)
    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: java.lang.IllegalStateException: child list broken 
    at com.amd.aparapi.internal.instruction.Instruction.setChildren(Instruction.java:104)
    at com.amd.aparapi.internal.instruction.InstructionSet$CompositeInstruction.<init>(InstructionSet.java:801)
    at com.amd.aparapi.internal.instruction.InstructionSet$CompositeIfElseInstruction.<init>(InstructionSet.java:862)
    at com.amd.aparapi.internal.instruction.InstructionSet$CompositeInstruction.create(InstructionSet.java:824)
    at com.amd.aparapi.internal.instruction.ExpressionList.addAsComposites(ExpressionList.java:831)
    at com.amd.aparapi.internal.instruction.ExpressionList.foldComposite(ExpressionList.java:695)
    ... 16 more

Here is the output from Fold_Composite_Bug:

Scope block from 25 to  25
com.amd.aparapi.internal.exception.ClassParseException: 
java.lang.NullPointerException
    at com.amd.aparapi.internal.instruction.ExpressionList.foldComposite(ExpressionList.java:822)
    at com.amd.aparapi.internal.model.MethodModel.foldExpressions(MethodModel.java:586)
    at com.amd.aparapi.internal.model.MethodModel.init(MethodModel.java:1676)
    at com.amd.aparapi.internal.model.MethodModel.<init>(MethodModel.java:1472)
    at com.amd.aparapi.internal.model.ClassModel.getMethodModel(ClassModel.java:2589)
    at com.amd.aparapi.internal.model.ClassModel.getEntrypoint(ClassModel.java:2622)
    at com.amd.aparapi.internal.model.ClassModel.getEntrypoint(ClassModel.java:2631)
    at com.amd.aparapi.internal.kernel.KernelRunner.execute(KernelRunner.java:935)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1909)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1840)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1825)
    at test.Fold_Composite_Bug.main(Fold_Composite_Bug.java:9)
    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: java.lang.NullPointerException
    at com.amd.aparapi.internal.instruction.ExpressionList.foldComposite(ExpressionList.java:805)
    ... 16 more
Mar 17, 2013 4:14:04 PM com.amd.aparapi.internal.kernel.KernelRunner 
warnFallBackAndExecute
WARNING: Reverting to Java Thread Pool (JTP) for class test.Fold_Composite_Bug: 
java.lang.NullPointerException
com.amd.aparapi.internal.exception.ClassParseException: 
java.lang.NullPointerException
    at com.amd.aparapi.internal.instruction.ExpressionList.foldComposite(ExpressionList.java:822)
    at com.amd.aparapi.internal.model.MethodModel.foldExpressions(MethodModel.java:586)
    at com.amd.aparapi.internal.model.MethodModel.init(MethodModel.java:1676)
    at com.amd.aparapi.internal.model.MethodModel.<init>(MethodModel.java:1472)
    at com.amd.aparapi.internal.model.ClassModel.getMethodModel(ClassModel.java:2589)
    at com.amd.aparapi.internal.model.ClassModel.getEntrypoint(ClassModel.java:2622)
    at com.amd.aparapi.internal.model.ClassModel.getEntrypoint(ClassModel.java:2631)
    at com.amd.aparapi.internal.kernel.KernelRunner.execute(KernelRunner.java:935)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1909)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1840)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1825)
    at test.Fold_Composite_Bug.main(Fold_Composite_Bug.java:9)
    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: java.lang.NullPointerException
    at com.amd.aparapi.internal.instruction.ExpressionList.foldComposite(ExpressionList.java:805)
    ... 16 more

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

Latest trunk build as of 3/16/2013.  Mac OS X 10.8.3

Please provide any additional information below.

This bug came to light when I was working with a fairly large piece of code.  I 
have boiled it down to the bare minimum needed to reproduce the problem.

This occurs on the current trunk build under OS X.  Let me know if additional 
info is needed.

Original issue reported on code.google.com by lats...@gmail.com on 17 Mar 2013 at 11:17

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for reporting and for including simple test cases. 

Let me take a look.  

Original comment by frost.g...@gmail.com on 17 Mar 2013 at 11:47

GoogleCodeExporter commented 9 years ago
I was able to recreate.  Just about to get on a plane.  This will give me 
something to keep me occupied ;)

Original comment by frost.g...@gmail.com on 17 Mar 2013 at 11:58

GoogleCodeExporter commented 9 years ago
Have a nice flight :)

Original comment by lats...@gmail.com on 18 Mar 2013 at 1:40

GoogleCodeExporter commented 9 years ago
So I have a workaround (which you may have found already), and also what looks 
like a fix.  It looks like when their is a declaration in the 'then' block. We 
are not pinning the 'else' to the outer if. 

The workaround is to create an else for your inner if's, just place some 
'throwaway code' in the else.  

So 

if (red){
    if (green){
         your code;
    } else{
       red = red;
    }
}else{
   your code
}

I have a fix that seems to work.  Can I send you a new aparapi.jar to test this 
with your app?

Gary

Original comment by frost.g...@gmail.com on 18 Mar 2013 at 5:51

GoogleCodeExporter commented 9 years ago
Try the attached Aparapi.jar and Mac OSX dylib

Original comment by frost.g...@gmail.com on 18 Mar 2013 at 6:18

Attachments:

GoogleCodeExporter commented 9 years ago
Fix has been tested and appears to work.

Thanks for quick turnaround :)

Can you post the patch and/or let me know a branch I can build from that will 
include the fix?  (no rush on this)

Original comment by lats...@gmail.com on 18 Mar 2013 at 6:48

GoogleCodeExporter commented 9 years ago
Here  (attached) is the patch I applied to the trunk-20130305 trunk copy. 

Basically we remove the search for 'arbitrary scope' which seems to be broken. 

Original comment by frost.g...@gmail.com on 18 Mar 2013 at 5:50

Attachments: