rzel / aparapi

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

Invoking kernels with single boolean fields in kernel causes NoSuchFieldError in JNI #146

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run TestBoolean class (see attached file TestBoolean.java) on APARAPI (r1674)

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

I expect:

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Instead, I got:

Exception in thread "main" java.lang.NoSuchFieldError: ok
    at com.amd.aparapi.internal.jni.KernelRunnerJNI.runKernelJNI(Native Method)
    at com.amd.aparapi.internal.kernel.KernelRunner.executeOpenCL(KernelRunner.java:870)
    at com.amd.aparapi.internal.kernel.KernelRunner.execute(KernelRunner.java:1165)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1985)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1916)
    at com.amd.aparapi.Kernel.execute(Kernel.java:1901)
    at com.amd.aparapi.TestBoolean.main(TestBoolean.java:18)

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

APARAPI Win64 (Aparapi_2014_04_29_Win64.zip, got from subversion)

Windows 7 Professional

GPU environment is a Nvidia Quadro FX880M with 1 GiB, driver: ForceWare: 327.02 

Please provide any additional information below.

OpenCL code seems OK:

typedef struct This_s{
   char  ok;
   __global int *val$output;
   int passid;
}This;
int get_pass_id(This *this){
   return this->passid;
}
__kernel void run(
   char  ok, 
   __global int *val$output, 
   int passid
){
   This thisStruct;
   This* this=&thisStruct;
   this->ok = ok;
   this->val$output = val$output;
   this->passid = passid;
   {
      if (this->ok!=0){
         this->val$output[get_global_id(0)]  = get_global_id(0);
      } else {
         this->val$output[get_global_id(0)]  = 0;
      }
      return;
   }
}

(given that APARAPI uses "char" to map "boolean")

[My curiosity: why does APARAPI use "char" type here instead of OpenCL's 
"bool"?]

If I try to substituite boolean with an int having hardcoded true/false values 
(as 1/0), like in TestHomeGrownBoolean (see attached file), result is ok ("[0, 
1, 2, 3, 4, 5, 6, 7, 8, 9]")
and generated OpenCL code is somewhat the same as above, except for "ok" var's 
type:

typedef struct This_s{
   int ok;
   __global int *val$output;
   int passid;
}This;
int get_pass_id(This *this){
   return this->passid;
}
__kernel void run(
   int ok, 
   __global int *val$output, 
   int passid
){
   This thisStruct;
   This* this=&thisStruct;
   this->ok = ok;
   this->val$output = val$output;
   this->passid = passid;
   {
      if (this->ok==1){
         this->val$output[get_global_id(0)]  = get_global_id(0);
      } else {
         this->val$output[get_global_id(0)]  = 0;
      }
      return;
   }
}

Original issue reported on code.google.com by lgallucci@gmail.com on 29 May 2014 at 4:30

Attachments: