rzel / aparapi

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

Multiple kernel invokes on the same kernel class with different arguments #127

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi there,

I found another issue, especially in my implementation, but I am pretty sure 
that this issue can also be reproduced in the default Aparapi version.

What is it about?
Having a kernel that is invoked multiple times with different arguments 
produces wrong results. Array references are updated as intended. Primitive 
arguments remain the same, resulting in partially silly execution times.

For my fluid solver application case an execution with 400 cells took 4000ms, 
with 320000 4100ms. I found out that the reason for this is the kernelObject 
attribute within the JNIContext alias KernelContext class. This one has to be 
updated if the kernel reference changes. Otherwise, values for primitive 
arguments are taken from the old references, resulting in those stupid results.

For my implementation you can find a bugfix here:
https://github.com/klassm/aparapi-clone/commit/ca3ce84a075ab305b7cfb9c92ba3e488b
ccb5690

In effect, I introduced another JNI method being called if the kernel reference 
changes. Within the JNI method, the kernelObject is replaced. That's it, the 
execution time jumps up to 32000ms - that's realistic.

Matthias

Original issue reported on code.google.com by matthias.klass@gmail.com on 7 Aug 2013 at 7:55

GoogleCodeExporter commented 8 years ago
Thanks Matthias. 

Let me take a look at your fix and see if I can work out a) what was going on 
and b) how to patch to trunk.  

Gary

Original comment by frost.g...@gmail.com on 7 Aug 2013 at 1:54

GoogleCodeExporter commented 8 years ago

Original comment by frost.g...@gmail.com on 7 Aug 2013 at 1:54

GoogleCodeExporter commented 8 years ago

Original comment by frost.g...@gmail.com on 7 Aug 2013 at 1:55

GoogleCodeExporter commented 8 years ago
Hi,

jip sure. Let me point out that I am still not sure whether this really also 
occurs on trunk. I can only imagine that it _should_ happen on trunk. If you 
have any questions (before spending too much time understanding the issue) just 
ask.

Matthias

Original comment by matthias.klass@gmail.com on 7 Aug 2013 at 1:56