Skip to content

How to query a backend's native/recommended groupsize? #740

Description

@jonas-schulze

My use cases evolve around sparse linear algebra. As always, there are big differences in performance between CPU and GPU (-like). As a naive solution, I used isgpu(backend) to choose a groupsize. However, isgpu is no longer around, and I have (once) observed the PoCL backend on the CPU to be fastest for a groupsize of 1, whereas the CPU performed better for ~4 and CUDABackend much better for 32 (or 64). I've used smth like this, which I specialized using package extensions:

clamp_groupsize(groupsize::Int, backend)::Int

Technically, one can probably only recommend prod(@groupsize) but not @groupsize directly. It would be nice if KA would provide an abstraction that, in the long term, could make use of CUDA's occupancy API. Therefore, I would recommend smth like

recommended_groupsize(backend, kernel)::Int

where the user then has to recover the actual groupsize for N > 1 dimensional kernels.

  • If CUDA, use the occupancy API
  • If old CPU backend, use number of cores
  • If new PoCL CPU backend, use one (more research needed!)

I'm sometimes confused on whether I should focus on groupsize or the hardware's vector width. Please let me know what you think. 🙂

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions