aparapi icon indicating copy to clipboard operation
aparapi copied to clipboard

[Bounty $30] Private superclass fields missing from struct This_s

Open freemo opened this issue 8 years ago • 1 comments

From @Pr0methean on July 6, 2016 2:19

When I create the following classes:

abstract class OperatorKernel extends Kernel {
  private float[] output;
  public void init(int pixels) {
    if (output == null) {
      output = new float[pixels];
    }
  }
}

class ProductKernel extends OperatorKernel {/*...*/}

and then call init() on a ProductKernel, I get this error:

Jul 05, 2016 7:11:43 PM com.amd.aparapi.internal.kernel.KernelRunner warnFallBackAndExecute
WARNING: Reverting to Java Thread Pool (JTP) for class com.google.users.polymorpheus.experimental.arttree.operators.X$XK
ernel: OpenCL compile failed
clBuildProgram failed
************************************************
<kernel>:36:13: error: no member named 'output' in 'struct This_s'
      this->output[pixelId]  = com_google_users_polymorpheus_experimental_arttree_operators_UnaryOperatorKernel__calcula
tePixelById(this, pixelId) * (float)this->signum;
      ~~~~  ^
<kernel>:36:163: error: no member named 'signum' in 'struct This_s'
      this->output[pixelId]  = com_google_users_polymorpheus_experimental_arttree_operators_UnaryOperatorKernel__calcula
tePixelById(this, pixelId) * (float)this->signum;

                                    ~~~~  ^

************************************************

Changing the visibility of the inherited fields to protected seems to fix this. I suspect the problem is that the bytecode-to-OpenCL compiler isn't looking at the superclass bytecode, even when the superclass isn't immediately Kernel.

Copied from original issue: aparapi/aparapi#31

freemo avatar Dec 02 '16 23:12 freemo

From @grfrost on July 6, 2016 21:14

Great catch. I suspect you are right. Sadly I don't recall a great deal of testing using class hierarchies. Actually I am surprised (but glad you have a workaround), it works if output is protected or public.

I will take a quick look and see if I spot anything obvious.

Gary

On Tue, Jul 5, 2016 at 7:19 PM, Pr0methean [email protected] wrote:

When I create the following classes:

abstract class OperatorKernel extends Kernel { private float[] output; public void init(int pixels) { if (output == null) { output = new float[pixels]; } } }

class ProductKernel extends OperatorKernel {/.../}

and then call init() on a ProductKernel, I get this error:

Jul 05, 2016 7:11:43 PM com.amd.aparapi.internal.kernel.KernelRunner warnFallBackAndExecute WARNING: Reverting to Java Thread Pool (JTP) for class com.google.users.polymorpheus.experimental.arttree.operators.X$XK ernel: OpenCL compile failed clBuildProgram failed


:36:13: error: no member named 'output' in 'struct This_s' this->output[pixelId] = com_google_users_polymorpheus_experimental_arttree_operators_UnaryOperatorKernel__calcula tePixelById(this, pixelId) * (float)this->signum; ~~~~ ^ :36:163: error: no member named 'signum' in 'struct This_s' this->output[pixelId] = com_google_users_polymorpheus_experimental_arttree_operators_UnaryOperatorKernel__calcula tePixelById(this, pixelId) * (float)this->signum;

                                ~~~~  ^

Changing the visibility of the inherited fields to protected seems to fix this. I suspect the problem is that the bytecode-to-OpenCL compiler isn't looking at the superclass bytecode, even when the superclass isn't immediately Kernel.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/aparapi/aparapi/issues/31, or mute the thread https://github.com/notifications/unsubscribe/AEKiN-szJEIw_m4YV9_96FBkN3Rw7Xctks5qSxCpgaJpZM4JFsm2 .

freemo avatar Dec 02 '16 23:12 freemo