Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 907333 - dev-libs/pocl updated ebuild for riscv
Summary: dev-libs/pocl updated ebuild for riscv
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: riscv Linux
: Normal normal (vote)
Assignee: Sam James
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-28 22:19 UTC by Andrew Cameron
Modified: 2024-03-05 16:44 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
updated ebuild (pocl-3.1-r1.ebuild,3.19 KB, text/plain)
2023-05-28 22:19 UTC, Andrew Cameron
Details
Build log (pocl-3.1-r1.ebuild.log,698.39 KB, text/x-log)
2023-05-28 22:20 UTC, Andrew Cameron
Details
add riscv64 support (pocl-riscv.patch,476 bytes, patch)
2023-05-28 23:56 UTC, Yixun Lan
Details | Diff
output of clinfo (clinfo,22.64 KB, text/plain)
2023-05-29 17:41 UTC, Andrew Cameron
Details
Test program I am using to test POCL (test.py,2.89 KB, text/x-python)
2023-05-30 20:11 UTC, Andrew Cameron
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Cameron 2023-05-28 22:19:19 UTC
Created attachment 862766 [details]
updated ebuild

The attached ebuild enables dev-libs/pocl to build successfully on a riscv platform.
Comment 1 Andrew Cameron 2023-05-28 22:20:04 UTC
Created attachment 862767 [details]
Build log
Comment 2 Yixun Lan archtester gentoo-dev 2023-05-28 23:52:30 UTC
I'd suggest providing a patch for the change, also the logical is not correct AFAIC, please don't keyword it before the patch is accepted

As comment in bug #907331, it would great to have a short summary about why request this keywording (reasons behind), and how it works well (have run-time test passed)? I would guess it's used by opencl related apps
Comment 3 Yixun Lan archtester gentoo-dev 2023-05-28 23:56:09 UTC
Created attachment 862772 [details, diff]
add riscv64 support
Comment 4 Andrew Cameron 2023-05-29 17:41:00 UTC
Created attachment 862847 [details]
output of clinfo

I want to enable the CPU component of OpenCL on my RISCV SBC.

I have just started testing and I see the following error when i run clinfo which I am not sure what to do to fix.

Kernel library file /usr/lib64/OpenCL/vendors/pocl/../../../../share/pocl/kernel-riscv64-unknown-linux-gnu-sifive-u74.bc doesn't exist.
Aborted (core dumped)
tarFive ~ # ls /usr/share/pocl/kernel-riscv64-unknown-linux-gnu-generic-rv64.bc 
/usr/share/pocl/kernel-riscv64-unknown-linux-gnu-generic-rv64.bc
StarFive ~ # file /usr/share/pocl/kernel-riscv64-unknown-linux-gnu-generic-rv64.bc 
/usr/share/pocl/kernel-riscv64-unknown-linux-gnu-generic-rv64.bc: LLVM IR bitcode
Comment 5 Andrew Cameron 2023-05-29 22:09:59 UTC
It looks like for riscv you need to figure out the appropriate -mcpu to use
Once I changed it to 
    if use riscv ; then host_cpu_variants="sifive-u74"

then it worked better but there are still one or two issues.
StarFive ~ # poclcc  -l
LIST OF DEVICES:
0:
  Vendor:   Imagination Technologies
    Name:   PowerVR B-Series BXE-4-32
 Version:   OpenCL 3.0 

/hashcat -I
hashcat (v6.2.6-460-gca4dc7acf) starting in backend information mode

* Device #1: This device's local mem size is too small.

OpenCL Info:
============

OpenCL Platform ID #1
  Vendor..: Imagination Technologies
  Name....: PowerVR
  Version.: OpenCL 3.0 

  Backend Device ID #1
    Type...........: GPU
    Vendor.ID......: 2147483648
    Vendor.........: Imagination Technologies
    Name...........: PowerVR B-Series BXE-4-32
    Version........: OpenCL 3.0 
    Processor(s)...: 1
    Clock..........: 594
    Memory.Total...: 7927 MB (limited to 990 MB allocatable in one block)
    Memory.Free....: 1152 MB
    Local.Memory...: 4 KB
    OpenCL.Version.: OpenCL C 1.2 
    Driver.Version.: 1.17@6210866

OpenCL Platform ID #2
  Vendor..: Mesa
  Name....: Clover
  Version.: OpenCL 1.1 Mesa 23.0.0-devel (git-a89acaf05d)

OpenCL Platform ID #3
  Vendor..: The pocl project
  Name....: Portable Computing Language
  Version.: OpenCL 3.0 PoCL 3.1  Linux, RelWithDebInfo+Asserts, RELOC, SPIR, SPIR-V, LLVM 15.0.7, SLEEF

  Backend Device ID #2
    Type...........: CPU
    Vendor.ID......: 2147483648
    Vendor.........: Unknown x86
    Name...........: pthread
    Version........: OpenCL 3.0 PoCL HSTR: pthread-riscv64-unknown-linux-gnu-sifive-u74
    Processor(s)...: 4
    Clock..........: 1500
    Memory.Total...: 5879 MB (limited to 1024 MB allocatable in one block)
    Memory.Free....: 2907 MB
    Local.Memory...: 512 KB
    OpenCL.Version.: OpenCL C 1.2 PoCL
    Driver.Version.: 3.1

-- FAILED TEST ---
StarFive ~ # python3 test.py 
Execution time of test without OpenCL:  30.688774824142456 s
===============================================================
Platform name: PowerVR
Platform profile: EMBEDDED_PROFILE
Platform vendor: Imagination Technologies
Platform version: OpenCL 3.0 
---------------------------------------------------------------
Device name: PowerVR B-Series BXE-4-32
Device type: ALL | GPU
Device memory:  7927 MB
Device max clock speed: 594 MHz
Device compute units: 1
Execution time of test: 0.014451 s
Results OK
===============================================================
Platform name: Portable Computing Language
Platform profile: FULL_PROFILE
Platform vendor: The pocl project
Platform version: OpenCL 3.0 PoCL 3.1  Linux, RelWithDebInfo+Asserts, RELOC, SPIR, SPIR-V, LLVM 15.0.7, SLEEF
---------------------------------------------------------------
Device name: pthread
Device type: ALL | CPU
Device memory:  5879 MB
Device max clock speed: 1500 MHz
Device compute units: 4
Segmentation fault (core dumped)
Comment 6 jinqiang zhang 2023-05-30 03:06:20 UTC
(In reply to Andrew Cameron from comment #4)
> Created attachment 862847 [details]
> output of clinfo
> 
> I want to enable the CPU component of OpenCL on my RISCV SBC.
> 
> I have just started testing and I see the following error when i run clinfo
> which I am not sure what to do to fix.
> 
> Kernel library file
> /usr/lib64/OpenCL/vendors/pocl/../../../../share/pocl/kernel-riscv64-unknown-
> linux-gnu-sifive-u74.bc doesn't exist.
> Aborted (core dumped)
I reproduced this coredump with host_cpu_variants="generic"

(In reply to Andrew Cameron from comment #5)
> It looks like for riscv you need to figure out the appropriate -mcpu to use
> Once I changed it to 
>     if use riscv ; then host_cpu_variants="sifive-u74"
> 
I'm not quite sure what guidelines to use to add host_cpu_variants, I tried changing to host_cpu_variants="generic-rv64;rocket-rv64;sifive-s21;sifive-s51;sifive-s54;sifive-s76;sifive-u54;sifive-u74;sifive-x280" (Source: https://github.com/llvm/llvm-project/blob/071e9d7bac7a5c879b1c67e1c4e847814f6d8254/clang/test/Misc/target-invalid-cpu-note.c#L88) and it compile fails on sifive-u74 (hifive unmatched board), obviously we should pick some more generic variants.

For now, I think host_cpu_variants="generic-rv64;sifive-u74" is ok on my unmatched board.

(In reply to Andrew Cameron from comment #5)
> pthread-riscv64-unknown-linux-gnu-sifive-u74
>     Processor(s)...: 4
>     Clock..........: 1500
>     Memory.Total...: 5879 MB (limited to 1024 MB allocatable in one block)
>     Memory.Free....: 2907 MB
>     Local.Memory...: 512 KB
>     OpenCL.Version.: OpenCL C 1.2 PoCL
>     Driver.Version.: 3.1
> 
> -- FAILED TEST ---
> StarFive ~ # python3 test.py 
> Execution time of test without OpenCL:  30.688774824142456 s
> ===============================================================
> Platform name: PowerVR
> Platform profile: EMBEDDED_PROFILE
> Platform vendor: Imagination Technologies
> Platform version: OpenCL 3.0 
> ---------------------------------------------------------------
> Device name: pthread
> Device type: ALL | CPU
> Device memory:  5879 MB
> Device max clock speed: 1500 MHz
> Device compute units: 4
> Segmentation fault (core dumped)
How to reproduce this error?
Comment 7 Andrew Cameron 2023-05-30 20:10:47 UTC
I can confirm that host_cpu_variants="generic-rv64;sifive-u74" also seems to work on my device.

To test and see if you can reproduce the error I got you need to emerge pyopencl and all its dependencies.
Then you can execute my test program that I will add as an attachment.
python test.py

Please post the output you get so we can compare results.
Comment 8 Andrew Cameron 2023-05-30 20:11:29 UTC
Created attachment 862915 [details]
Test program I am using to test POCL
Comment 9 Andrew Cameron 2024-03-05 16:44:20 UTC
Any Updates on this?