Saalma / aparapi

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

Null Pointer Exception when forEach() IntConsumer contains another lambda on HSA device #139

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago

What steps will reproduce the problem?
1.Add a lambda inside you forEach() body, e.g. 

        Aparapi.range(SOME_RANGE).parallel().forEach(i -> {
            Runnable aparapiDoesNotLikeMe = () -> {  };
        });

What is the expected output? What do you see instead?
I would expect this code to execute without error, but get a Null Pointer 
Exception.

I get the following stack trace:
 Exception in thread "main" java.lang.NullPointerException
    at com.amd.aparapi.InstructionSet$I_INVOKEDYNAMIC.getStackConsumeCount(InstructionSet.java:3026)
    at com.amd.aparapi.ClassModel$ClassModelMethod.getInstructionMap(ClassModel.java:2505)
    at com.amd.aparapi.ClassModel$ClassModelMethod.getInstructions(ClassModel.java:2671)
    at com.amd.aparapi.HSAILMethod.<init>(HSAILMethod.java:276)
    at com.amd.aparapi.HSAILMethod.getHSAILMethod(HSAILMethod.java:261)
    at com.amd.aparapi.HSADevice.forEach(HSADevice.java:145)
    at com.amd.aparapi.Aparapi$ParallelIntRange.forEach(Aparapi.java:56)
    at com.test.AparapiTest.test(AparapiTest.java:12)

What version of the product are you using? On what operating system?
Aparapi-lambda revision 1608 on Ubuntu 13.10

Please provide any additional information below.
AMD A10-7850K APU, GIGABYTE|GA-F2A88X-UP4 ( F4 BIOS, IOMMU enabled )

Original issue reported on code.google.com by adri...@caloiaro.com on 22 Mar 2014 at 7:42

GoogleCodeExporter commented 8 years ago
The lambda must be an IntConsumer you seem to be 'nesting' two lambdas.  We 
don't support that :)

Your IntConsumer is trying to create a new Runnable.  We can't allocate on the 
gpu. 

You just want a single IntConsumer. 

int buf[SOME_RANGE];
Aparapi.range(SOME_RANGE).parallel().forEach(i -> {
           // Runnable aparapiDoesNotLikeMe = () -> {  };
           buf[i] = i;
        });

Original comment by frost.g...@gmail.com on 22 Mar 2014 at 7:55

GoogleCodeExporter commented 8 years ago
Thanks for the quick response, Gary. I'll make sure not to allocate any new 
objects on the GPU. I ran across this calling a method on an object that called 
IntStream.range(), so sometimes it's not immediately clear that new Objects are 
being allocated. 

Original comment by adri...@caloiaro.com on 22 Mar 2014 at 8:10

GoogleCodeExporter commented 8 years ago
Indeed one of the issues with lambdas is that it hides such allocations. 

So are you up and running on HSA device?

Did the hsailmandel demo run for you?

Gary

Original comment by frost.g...@gmail.com on 22 Mar 2014 at 8:36

GoogleCodeExporter commented 8 years ago
Yes sir. I'm in the process of refactoring algorithms to run on the HSA device. 
Now that I know not to allocate Objects, I am moving along much more quickly.

Original comment by adri...@caloiaro.com on 23 Mar 2014 at 2:57

GoogleCodeExporter commented 8 years ago

Original comment by frost.g...@gmail.com on 26 Mar 2014 at 7:48