From: Michal B. (TAU) <mic...@tu...> - 2019-10-31 11:32:21
|
Hello, It seems to me that there is no tool for (cross) compiling the kernel (cl file to binary). There is no tool, because every OpenCL implementation (pocl, AMD SDK etc) uses its own binary format. There is no single format which every implementation accepts. Pocl has a tool for compiling an OpenCL source to a binary, poclcc, which simply calls clCreateProgram/clBuildProgram/clGetProgramInfo(...CL_PROGRAM_BINARIES...) and stores the result in a file. That file is only loadable by pocl. clang should be able to compile kernels, however, in praxis it doesn't Clang can compile OpenCL to LLVM bitcode. However it cannot output binaries which OpenCL implementations can load, because (again) every implementation uses its own binary format. That's why you must always compile through implementation, not through Clang. There is one somewhat common binary format, SPIR-V, but it currently works with only a few OpenCL implementations. And it probably won't help you, because a SPIR-V binary needs to be compiled for the target device by the implementation, so the target OpenCL implementation will need a compiler anyway. I compiled pocl with the host_cpu='riscv64' (this flag apparently specifies the target CPU) Sounds like you tried to compile some version of pocl with autotools, which is ancient and we don't provide any support for it anymore. The following post seems to be outdated It is outdated, and wrong. RISC-V is supported by upstream LLVM (from my quick googling), and pocl haven't used autotools for a few years now. So to clear up the confusion around cross-compiling here: 1) cross compiling the implementation (pocl) itself for another device - this may or may not work with pocl, i haven't tried. The reason is that pocl can now be compiled natively on devices as weak as a Raspberry Pi with 1GB ram. If you have a RISC-V device with at least 1GB ram, you can probably compile pocl with LLVM and the CPU driver natively on it. 2) "cross compiling the OpenCL sources" - this doesn't exist. There is something similar: offline compilation, which is compiling OpenCL sources for a device which is not present in the system. However this has to be supported by the implementation. Pocl doesn't support this ATM. What you can do with pocl is: 1) on a sufficiently powerful RISC-V machine, compile a native build with LLVM and use it to compile sources to pocl-binaries; and 2) on weaker RISC-V machines (<1G ram), you can compile a compiler-less version of pocl that only supports loading from binaries, and you can use binaries from 1) here. Regards, -- mb ________________________________ From: Raad Bahmani via pocl-devel <poc...@li...> Sent: Thursday, October 31, 2019 11:36 AM To: poc...@li... <poc...@li...> Cc: Raad Bahmani <r.b...@ya...> Subject: [pocl-devel] Cross-compiling for RISC-V Dear all, I’m trying to cross-compile OpenCL (on X86 for RISC-V). Thereby, the kernel (cl file) should be loaded from binary and this is the problem. It seems to me that there is no tool for (cross) compiling the kernel (cl file to binary). I compiled pocl with the host_cpu='riscv64' (this flag apparently specifies the target CPU) but the generated binary can not be loaded on RISC-V. According to its documentation ( https://clang.llvm.org/docs/UsersManual.html#opencl-features) clang should be able to compile kernels, however, in praxis it doesn't. The following post seems to be outdated (and it has also not been accepted as an answer). https://stackoverflow.com/questions/41204224/configuring-pocl-for-riscv/42800248#42800248 It would be a great help if you could give some information (best case would be a simple working example:) ) about how binaries of OpenCL-Kernels can be generated for RISC-V. Best, Raad |