Comments (16)
Interestingly, if you comment out these lines:
if(s_i == t_j) {
cost = 0;
}
else {
cost = 1;
}
...and then just initialise cost to 0 on its declaration, the code will compile
and run (though obviously won't generate the correct result.) It seems to be
the if statement causing the error which seems a bit odd?
Original comment by [email protected]
on 6 Feb 2012 at 8:55
from aparapi.
I found a workaround in that the equivalent ternary statement works fine. That
surprises me - I assumed that they'd compile the same way, is there a subtle
difference?
Original comment by [email protected]
on 6 Feb 2012 at 9:10
from aparapi.
Sorry, forgot to include the equivalent ternary statement above:
cost = s_i == t_j ? 0 : 1;
Original comment by [email protected]
on 6 Feb 2012 at 9:10
from aparapi.
Actually, I get the following error:
clBuildProgram failed
************************************************
<program source>:45:70: error: use of undeclared identifier 'cost'
int c = this->val$d[((firstSize * (i - 1)) + (j - 1))] + cost;
^
************************************************
Feb 6, 2012 12:49:52 PM com.amd.aparapi.KernelRunner warnFallBackAndExecute
WARNING: Reverting to Java Thread Pool (JTP) for class gov.pnnl.ia.gpu.test$1:
OpenCL compile failed
Original comment by [email protected]
on 6 Feb 2012 at 9:32
from aparapi.
Which makes sense since you cannot declare variables without initializing them
first...we've run into this same limitation with our kernels as well.
FYI, if you use the Trunk code char support has been added :)
Original comment by [email protected]
on 6 Feb 2012 at 9:33
from aparapi.
Ah I see! That does make a lot of sense. And thanks for the tip about the char
support - don't suppose 2D arrays is in there as well?
Oh and how do you get the specific OpenCL error displayed? Is it an option I
need to add? I'm just getting the "reverting to JTP" warning.
Original comment by [email protected]
on 6 Feb 2012 at 9:38
from aparapi.
Thanks for reporting this.
So for me when I initialize cost to 0 (line 25) I don't have to comment out the
two lines or switch to the ternary form.
So on line 25 (of your code) I just swapped 'int cost=0;' for 'int cost;'
Can you try this and just confirm.
If you still see a compile error try setting
-Dcom.amd.aparapi.enableShowGeneratedOpenCL=true this should dump the generated
opencl and might help us diagnose.
Are you using eclipse's java compiler or Oracles?
There is a subtle difference parsing the ternary form of "a = b?c:d;" instead
of "if (b)c;else d; but I too would expect to have the same issue parsing the
bytecodes.
Essentially the stack is offset (by both conditional paths) after executing
"b?c:d" wheres a normal if()..else.. we don't expect the stack to be effected
by following either path.
The problem stems from not being able to determine the scope of the 'cost'
variable unless we initialize it.
Gary
Original comment by [email protected]
on 6 Feb 2012 at 9:39
from aparapi.
Thanks for the quick feedback guys.
Gary, yup I can confirm that works if I change it as you describe (Oracle
JDK7.) It does seem to be a scoping problem - I'm not a compiler guy at all,
but seem to remember hearing a talk somewhere that explained determining the
scope in the Java compiler for these sorts of cases was a decidedly complex
problem!
Original comment by [email protected]
on 6 Feb 2012 at 9:50
from aparapi.
On a related point, in the attached code I've tried to take the working example
and apply it to work with a number of strings (so it has a practical use.)
However, I end up with a generic NullPointerException rather than a specific
OpenCL compile error:
Exception in thread "main" java.lang.NullPointerException
at com.amd.aparapi.KernelWriter.convertType(KernelWriter.java:111)
at com.amd.aparapi.KernelWriter.write(KernelWriter.java:260)
at com.amd.aparapi.KernelRunner.execute(KernelRunner.java:1197)
at com.amd.aparapi.Kernel.execute(Kernel.java:1523)
at com.amd.aparapi.Kernel.execute(Kernel.java:1469)
at com.amd.aparapi.Kernel.execute(Kernel.java:1454)
at org.quelea.utils.opencl.LevenshteinDistance.compare(LevenshteinDistance.java:104)
at org.quelea.utils.opencl.LevenshteinDistance.main(LevenshteinDistance.java:32)
Java Result: 1
I suspect this may be because there's 2D arrays involved, in the following line:
result[getGlobalId()] = ld(s1Arr[getGlobalId()], s2Arr[getGlobalId()],
s1Length, s2Length);
...s1Arr and s2Arr are 2D arrays of integers. I "hoped" it'd just count as a 1D
array since all I'm doing is retrieving the 1D array from the 2D array based on
the global ID and using that, but is this not allowed either and hence is
what's causing the issue?
Original comment by [email protected]
on 6 Feb 2012 at 9:56
Attachments:
from aparapi.
Two dimensional arrays (well, arrays of arrays) will throw a NPE in the Aparapi
code.
See http://code.google.com/p/aparapi/issues/detail?id=10
Original comment by [email protected]
on 6 Feb 2012 at 10:05
from aparapi.
Sadly no we just can't access 2D arrays.
The NPE is actually bad coding on my behalf, this code is only expecting so
see primitives or single dimension arrays of primitives and should be more
defensive. I think it has been fixed in the main branch (it is time for me to
create a new set of binary builds isn't it!) or at least it will generated an
Aparapi exception complaining that we can't access 2D arrays.
As Ryan indicated (he is clearly faster than me at typing ;)) I think you are
hitting issue #10. http://code.google.com/p/aparapi/issues/detail?id=10
Moving 2D arrays to the GPU would be expensive due to the layout of Java arrays.
Although I think I know *how* to do it if someone wanted to try to implement
it....
Gary
Original comment by [email protected]
on 6 Feb 2012 at 10:15
from aparapi.
Just an FYI, when I receive the error above (uninitialized method local
variables) and OpenCL dies, Aparapi never returns or fails over to JTP mode.
Should I file a new bug on that condition and use the attachment on this ticket
as the test case?
Original comment by [email protected]
on 8 Feb 2012 at 7:47
from aparapi.
I also get that behaviour - it just seems to hang rather than falling over to a
thread pool.
Original comment by [email protected]
on 8 Feb 2012 at 9:40
from aparapi.
Original comment by [email protected]
on 14 Feb 2012 at 5:29
- Changed state: Accepted
from aparapi.
I just got around to trying to fix this. I thought I had wrapped all tests in
ClassParseExceptions, but this is not detected until OpenCL write time which is
a shock. I think this should be detected earlier.
Worse case I will defend the KernelRunner from any exception and fall back. I
will also see if this particular error can't be detected earlier. I need to
create a junit case for this.
Thanks 'berry120'
Original comment by [email protected]
on 20 Feb 2012 at 9:29
from aparapi.
I made the changes suggested above. Now any exception encountered at codegen
time is converted to CodeGenException so should revert to JTP. Fix is in SVN
R#287
Original comment by [email protected]
on 20 Feb 2012 at 9:41
- Changed state: Fixed
from aparapi.
Related Issues (20)
- Problem when running with NVIDIA GPUs HOT 8
- Generating OpenCL
- Patch for /trunk/samples/add/src/com/amd/aparapi/sample/add/Main.java
- fatal error when disposing a 2D float execution kernel HOT 2
- Failed to load aparapi native library
- 2D arrays management HOT 2
- FFT Extension example fails to run HOT 1
- Add support for Intel Xeon Phi
- Trouble running samples in lambda branch on Kaveri HOT 6
- Release in the downloads section is old and no guide on how to compile on Mac HOT 1
- High total processing/running time on GPU mode w/Aparapi HOT 2
- Aparapi can't find OpenCL HOT 21
- Mandel Works Fine With The GPU But, When I Run My Code From BlueJ It Doesn't Work HOT 1
- Can i Run Aparapi on "Nvidia Gpu" or "Intel Gpu"? HOT 4
- Missing Sync or Volatile with Aparapi HOT 2
- Dump modified Java bytecode HOT 4
- Please update the tutorial about HSA settings
- Adding Vector data type at Aparapi HOT 1
- OpenCL compile fails... sometimes? (w/ Processing)
- How Learn Aparapi and use it!Any pdf , tutorial and ... HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aparapi.