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
OpenCL backend produces Syntax Error #247
Comments
Hi @fkellner. Thank you for the report. This is a bug in TornadoVM. It generates an OpenCL kernel with an extra "}" bracket. It will help if you can send us a test case (minimal code) that breaks. This error should not happen if you use the PTX or SPIR-V backend. The PTX backend is supported on Windows via MSys2. The SPIR-V backend is only supported on Linux. One thing, you can use |
Thanks for the quick reply and the tip! I cannot test with PTX or SPIR-V, because I have no access to a device which supports them. However, I tried to create a minimal example. When trying to reproduce the error, I received a different error, which I also received when executing the code that previously generated this error (even though I changed nothing) (see below, or check the The minimal example is available here: https://github.com/fkellner/tornadovm-debug
|
Thank you. We will take a look internally and let you know. |
I took a look at this. The issue is related to the basic block traversal and the generation of OpenCL C code from the unstructured Control Flow Graph in the JIT compiler. This is not a problem when for the PTX and SPIR-V backends because we can jump to the same basic block from different ones in the generated assembly code. However, we can't do this for OpenCL. From my view, the TornadoVM JIT compiler should add a new compiler phase for block-reordering and cloning conditional expressions. I will discuss this internally and provide a fix. In the meantime, this works: public static void calcLowpassAtRB(float[] samples, float[] lowPassAtRB, int width, int height, int green1Idx, int green2Idx) {
for (@Parallel int x = 0; x < width; x++) {
for (@Parallel int y = 0; y < height; y++) {
int patternIdx = (x % 2) + 2 * (y % 2);
boolean a = patternIdx == green1Idx;
boolean b = patternIdx == green2Idx;
// each condition in a separated branch.
if (a) {
lowPassAtRB[x + y * width] = 0.0f;
} else if (b) {
lowPassAtRB[x + y * width] = 0.0f;
} else {
// 3x3 low-pass filter
float middle = samples[x + y * width];
float top = samples[x + TornadoMath.max(0, y - 1) * width];
float bottom = samples[x + TornadoMath.min(height - 1, y + 1) * width];
float left = samples[TornadoMath.max(0, x - 1) + y * width];
float right = samples[TornadoMath.min(width - 1, x + 1) + y * width];
float topLeft = samples[TornadoMath.max(0, x - 1) + TornadoMath.max(0, y - 1) * width];
float topRight = samples[TornadoMath.min(width - 1, x + 1) + TornadoMath.max(0, y - 1) * width];
float bottomLeft = samples[TornadoMath.max(0, x - 1) + TornadoMath.min(height - 1, y + 1) * width];
float bottomRight = samples[TornadoMath.min(width - 1, x + 1) + TornadoMath.min(height - 1, y + 1) * width];
lowPassAtRB[x + y * width] = 0.25f * middle + //
0.125f * (top + bottom + left + right) + //
0.0625f * (topLeft + topRight + bottomLeft + bottomRight);
}
}
}
} |
Can confirm that it works, thank you very much for looking into it! |
Describe the bug
Running a task with
@Parallel
-annotated for-loops calculating a simple low-pass filter produces an OpenCL syntax error when run on Apple M1 or Windows.The offending method reads as follows:
Running it as a task graph on an Apple Mac Mini (only available device is M1 chip) with
--fullDebug
and--printKernel
results in the following error:Running the same on a Windows 10 machine with OpenCL Backends also results in the error
[TornadoVM-OCL-JNI] ERROR : clBuildProgram -> Returned: -11
, however without giving any details like above.How To Reproduce
We are currently still working out how to open source the surrounding program. If it helps, I can privately send you a copy of the code with instructions. But maybe I just overlooked the use of some not-yet-implemented method, or something like that.
Expected behavior
The task to compile and run.
Computing system setup (please complete the following information):
tornado --devices
:Additional context
Same errorcode -11 on Windows 10, but without line number and additional information.
The text was updated successfully, but these errors were encountered: