pocl icon indicating copy to clipboard operation
pocl copied to clipboard

poclcc failed cross compilation for ARM platform

Open crocodiletongue opened this issue 4 years ago • 2 comments

I tried to compile opencl kernel code to generate the kernel binary object(kernel.cl.pocl) for Arm platform but it failed.

poclcc runtime environment is:

HostPC : Ubuntu 16.04.LTS on virtualbox
Processer : Intel Core i7-9700 3GHz
gcc version 6.3.1
GNU ld (GNU Binutils) 2.29.1.20170915

The procedure I tried is:

1. download llvm9, make and install to Ubuntu
 $cmake -G "Unix Makefiles" ../llvm-9.0.0.src -DCMAKE_INSTALL_PREFIX=/home/llvm -DCMAKE_BUILD_TYPE=Release
 $make -j12
 $sudo make install

2. download pocl1.4, make and install to Ubuntu
 $cmake  -DLLC_TRIPLE=aarch64-linux-gnu -DLLC_HOST_CPU=cortex-a53 -DWITH_LLVM_CONFIG=/home/llvm_ubuntu/bin/llvm-config ..
 $make
 $sudo make install

The above succeeded but $poclcc kernel.cl failed with the following error message.

/usr/bin/ld: unrecognised emulation mode: aarch64linux
Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386linux elf_l1om elf_k1om i386pep i386pe
error: linker command failed with exit code 1 (use -v to see invocation)

poclcc seems to use GNU Linker on Ubuntu during its compilation. I think it is wrong but have no idea what is wrong in my procedure.

crocodiletongue avatar Apr 01 '20 04:04 crocodiletongue

What's wrong is that you have compiled both the "platform" of pocl and the "opencl CPU device" code for ARM. Your kernel is telling you that it cannot launch ARM executables on your intel CPU.

What you are looking for is "platform" code compiled for x86-64 with "opencl CPU device" compiled for ARM. Such config is not supported; Pocl has always supported only the same architecture for CPU OpenCL device as the platform code. May i ask what are you trying to do ? In general it's not impossible to add such support, but it's quite pointless effort, since you can compile Pocl for ARM natively, even on weak machines like raspberry pi with 1GB ram.

franz avatar Apr 01 '20 08:04 franz

May i ask what are you trying to do?

I want to execute the pocl and an OpenCL CPU device code (kernel.cl) on ARM CPU board.

So I want do the following on Ubuntu x64 PC.

  • compile the pocl1.4 and generate ARM executable files of it with ARM cross-compiler that operates on Ubuntu x64 PC
  • offline-compile a kernel.cl and generate ARM executable files of it with the poclcc that operates on Ubuntu x64 PC

But I got unwanted result that the poclcc outputs x86 kernel.cl object. I suspect there may be something wrong in my setting of LLVM.

I want to know correct installation and setup procedure.

May I let me confirm my understanding of the pocl spec is correct? It's my understanding that the pocl does not support online compilation if the pocl is cross-compiled. So I'm trying to have the poclcc cross-compiles kernel.cl with offline compile(Cross-compile pocl LLVM-less build). I believe poclcc operates as a cross-compiler and outputs executable files for ARM.

Could you tell me if there is some wrong in my understanding and procedure?

crocodiletongue avatar Apr 02 '20 05:04 crocodiletongue