vortexgpgpu / pocl

a clone of POCL that includes RISC-V newlib devices support and Vortex
MIT License
36 stars 14 forks source link

can't link double-float modules with soft-float modules #1

Open alexfanqi opened 2 years ago

alexfanqi commented 2 years ago

Hello,

First off, Merry Christmas and big thanks for bringing out this great project to enhance OpenCL support in riscv.

I was trying to compile natively on a Hifive Unmatched board with a few patches from main pocl/pocl repo to allow compilation on llvm 11+. I defined -DLLC_HOST_CPU=sifive-u74. But when I run poclcc -o kernel.pocl kernel.cl to compile the kernel, I got linker errors can't link double-float modules with soft-float modules. readelf reports the generated tempfile-xx-xx.so.o in kcache is indeed soft float. My whole machine is running on -march=rv64gc -mabi=lp64d.

I have tried specifying CFLAGS="-mabi=lp64d" -DEXTRA_HOST_LLC_FLAGS="-target-abi lp64d -mattr=+d" and add ss << "-target-abi lp64d -target-feature +d -mattr=+d"; to lib/CL/pocl_llvm_build.cc, but the error is still there.

Do you have any idea how I can get around this issue?

RuHungLee commented 2 years ago

Hello @alexfanqi, I have the same issue. Have you solved it?

alexfanqi commented 2 years ago

Yes, I haven't test out this with pocl yet, but this is a general issue I have worked out. Some configs need to be passed into llvm mc backend, ie. Cpu name, Target feature and targetabi.

Try use lastest llvm main branch. LLVM <=14 detects cpu name as generic, but riscv backend only recognises generic-rv64/32. Target feature detection is not complete yet, so better to pass it in manually. Targetabi needs to be passed in mcoption. Passing by metadata in ir should work as well, but there was a bug before that should be fixed by latest llvm.

See my port of julia for example https://github.com/alexfanqi/julia/commit/073d7f69140e637f3c2b3bb872f078fe96cb343