Syncleus / aparapi

The New Official Aparapi: a framework for executing native Java and Scala code on the GPU.
http://aparapi.com
Apache License 2.0
466 stars 60 forks source link

[BOUNTY $25] Can not directly return an instantiated array. #66

Open freemo opened 6 years ago

freemo commented 6 years ago

Generating the code for the following will return an exception:

 public class ReturnDoubleArrayNew extends Kernel {

    double[] returnDoubleArrayNew() {
        return new double[1024];
    }

    public void run() {
        returnDoubleArrayNew();
    }
}

However the following work around will compile just fine:

public class ReturnDoubleArrayVar extends Kernel {

    double[] returnDoubleArrayVar() {
        double[] doubles = new double[1024];
        return doubles;
    }

    public void run() {

        returnDoubleArrayVar();
    }
}
freemo commented 6 years ago

I wrote a unit test which demonstrates this bug here:

https://github.com/Syncleus/aparapi/blob/master/src/test/java/com/aparapi/runtime/ReturnInstantiatedArrayDirectlyTest.java