Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • mesa mesa
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 2,699
    • Issues 2,699
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 908
    • Merge requests 908
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Mesa
  • mesamesa
  • Merge requests
  • !15439

Adding rusticl

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Karol Herbst requested to merge karolherbst/mesa:rusticl/wip into main Mar 17, 2022
  • Overview 196
  • Commits 139
  • Pipelines 98
  • Changes 128

Goal

I wanted to learn Rust and I was thinking, why not implement OpenCL in it inside mesa and see how nice it would be to use Rust inside mesa.

Design

I wish I had something to point to, but there is no documentation (I know, I am a terrible person) and no design document I've should have written or anything. Roughly I put most of the API validation inside api/ and most of the real implementation inside core/. Shared code, especially wrappers around mesa code live inside util/ and mesa/. I wish I could even show some nice graphs about internal dependencies or anything. Nope, doesn't exist.

It uses clc for compiling source code to SPIR-V and it relies on drivers supporting nir.

Dependencies

Rusticl doesn't really add anything new except rustc and bindgen as dependencies. clc needs the SPIRV-LLVM-Translator and libclc, so that needs to be installed as well.

Compiling

Enable -Dgallium-rusticl=true -Dopencl-spirv=true -Dshader-cache=true -Dllvm=true -Drust_std=2021 and.. that should just be it.

There is a workaround as the meson bindgen module can't deal with include paths for generated headers, so one needs to adjust a relative path pointing to the build dir.

Running

Just use OCL_ICD_VENDORS and point it towards the rusticl.icd file. To run it on top of llvmpipe also set LP_CL=1

Status

It passes like most of the OpenCL 1.0 related CTS tests and a bunch of other ones. The CTS isn't really good at running against a specific version below 1.2. As Rusticl also reports CL 3.0 as the platform version some of the newer APIs are implemented as well. Older APIs might not be on the other hand.

Todos:

  • support explicit local groups bigger than 1 (works with 0 already, just not when the application specifies the size)
  • Review the Rust code
  • image support
  • printf support
  • passing the 3.0 CTS
  • convert to Rust 2018
  • A better origin story as mine is boring.
  • SPIRV-link bug: https://github.com/KhronosGroup/SPIRV-Tools/pull/4784
  • LLVM OpenCL headers expose CL extensions we don't support as they are always support for spirv targets, we need to make that optional
  • fix vload/vstore half function when using opencl-c-base.h: https://github.com/llvm/llvm-project/issues/55275

Nice to Haves:

  • support for 32 bit devices
  • fp16 support
  • SPIR-V support
  • compile to hw when a cl_kernel object is created and fetch work group info from the driver
  • support for function calling: this needs work in the backends. Inlining everything works for quite a bit of stuff (e.g. luxmark v3.1 LuxBall), but bigger kernels we might not be able to run.
  • Figure out why Geekbench 5 crashes
  • cl_khr_gl_sharing (used by multiple apps)
  • cl_khr_image2d_from_buffer (required by davinci resolve)
  • make it work with radeonsi
  • make it work with r600
Edited Jun 21, 2022 by Alyssa Rosenzweig
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: rusticl/wip