[all-commits] [llvm/llvm-project] 4a35c4: [Offload] Lazily initialize platforms in the Offlo...

Joseph Huber via All-commits all-commits at lists.llvm.org
Tue Oct 14 07:36:15 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4a35c4d38af4844f26d944047ca1f6aefd6a0eff
      https://github.com/llvm/llvm-project/commit/4a35c4d38af4844f26d944047ca1f6aefd6a0eff
  Author: Joseph Huber <huberjn at outlook.com>
  Date:   2025-10-14 (Tue, 14 Oct 2025)

  Changed paths:
    M offload/liboffload/API/Common.td
    M offload/liboffload/src/OffloadImpl.cpp

  Log Message:
  -----------
  [Offload] Lazily initialize platforms in the Offloading API (#163272)

Summary:
The Offloading library wraps around the underlying plugins. The problem
is that we currently initialize all plugins we find, even if they are
not needed for the program. This is very expensive for trivial uses, as
fully heterogenous usage is quite rare. In practice this means that you
will always pay a 200 ms penalty for having CUDA installed.

This patch changes the behavior to provide accessors into the plugins
and devices that allows them to be initialized lazily. We use a
once_flag, this should properly take a fast-path check while still
blocking on concurrent use.

Making full use of this will require a way to filter platforms more
specifically. I'm thinking of what this would look like as an API.
I'm thinking that we either have an extra iterate function that takes a
callback on the platform, or we just provide a helper to find all the
devices that can run a given image. Maybe both?

Fixes: https://github.com/llvm/llvm-project/issues/159636



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list