-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Double addition of inputs in PrintfNode prevents inlining and as result debuggin #506
Comments
Thanks @andrii0lomakin for the report. We do not use this function and it is only partially supported for OpenCL. Improvemnts on this matter are very welcome. |
@jjfumero, what do you mean by partially supported? How do you debug kernels in such cases? Could you provide more information? |
It works for simple test cases (Java primitive types) This was part of the original designed more than 10 years ago and we haven't evolved it. In general, we do not use prints inside GPU kernels. Debugging kernels is a bit tricky and what we do is to use the TornadoVM prebuilt API with the changes we want to include in our compiler optimizations, including extensions for We also use external C/C++ tools to check and debug kernels (in the case of SPIR-V, we pass LLVM SPIR-V Khronos validator) for example. In some occasions we have also used Intel VTune for OpenCL: |
During the addition of PrintfNode, all its input usages are also registered in the constructor because of the calling of
NodeList#set
method.After that, it obviously added to the graph of operations by calling
b.add(b.append(print mode));.
That causes a second attempt to add printf inputs to the graph. This causes side effect - argument is used as a parameter of printf registers printf extra usage twice, so as a result during inlining, inputs of two printf nodes, instead of one, will be tried to be replaced by the new inlined node that causes an exception during compilation and as result inability to use printf for debugging.
Let us consider the example:
In the graph printf argument will be


FloatArray#get
method, which will be extracted in the plugin and then:During construction, FloatArray#get will be added as input and then PrintfNode will be added as extra usage of FloatArray#get
But then after the call of
b.add(b.append(print mode));.
, one more extra usage ofFloatArray#get
is addedThat causes an exception during
FloatArray#get
inlining because second attempt to replace the input ofsecond
printf node fails (because those nodes are the same instances):So the fix should be simple in a nutshell:
append
andadd
methods inb.add(b.append(print mode));.
The call to the add method is a no-op in this case because the node is already in the graph.If I get everything right, I will provide the PR soon.
The text was updated successfully, but these errors were encountered: