I want to make a generic program to transform an OpenCL project into SPIRV format with the files as optimized as I can for making them faster at execution time. I am following these steps in my pipeline:
First, after finding an OpenCL project, I execute
clang for convert the OpenCL files into bytecode format (.cl into .bc), using the following command:
clang -cc1 -triple spir64 -emit-llvm-bc -finclude-default-header -cl-single-precision-constant EXAMPLE.cl -o EXAMPLE.bc
After that, I execute the command
llvm-spirv (from SPIRV-LLVM) to convert the mentioned bytecode into SPIRV format (.bc into .spv), executing the following command:
llvm-spirv EXAMPLE.bc -o EXAMPLE.spv
After that, I finally execute the
spirv-opt (from SPIRV-Tools Project) for finding how different optimizations affect to different projects, using the command like:
spirv-opt EXAMPLE.spv -o EXAMPLE_0.spv
I am having an error in some projects when running this pipeline. When I get the code from a project and it runs the optimizator, it gives me an error. For example, when I applied all of the project called backprop from Rodinia benchmark, I got the following error:
error line 313: Block 26[%if_then65] appears in the binary before its dominator 35[%if_end55_4]
%if_end55_4 = OpLabel
After a little research, I have found the problem comes from one of the first to commands,
llvm-spirv. I have tried several things but I do not found exactly where and why the problem is generated. Any suggestions? I would like to continue this project for finishing my final degree project and if it works, give to the community an automatic OpenCL optimizer.
I could not put the links to the projects and benchmark, if you need them or you can help me with this problem, please email me: email@example.com, I would appreciate it.
Thanks in advance!