Skip to content

Conversation

@danhoeflinger
Copy link
Contributor

@danhoeflinger danhoeflinger commented Nov 5, 2025

Dynamic Selection API: Backend and Policy Customization & Removal of Selection API

This PR refactors the Dynamic Selection API to introduce a flexible backend architecture and simplify the user-facing API by removing the select() function. It provides better tools for customization of backend and policies to allow for easier customization and more flexibility for users.

Implements RFCs #2220.

Key Changes

Backend Architecture

  • Added policy_base.h and default_backend.h to provide common base classes for policies and backends respectively
  • Backends now accept ResourceAdapter function to support different flavors of resource with the same backend (e.g. sycl::queue vs sycl::queue*)

API Simplification

  • Removed select() function - selections are now internal implementation details
  • Addition of try_submit- always returns a std::optional quickly, returns empty if unable to obtain a resource
  • Users now exclusively use try_submit, submit() and submit_and_wait() functions
  • Policies expose try_select_impl() (returns std::optional) instead of public select()

Execution Info & Reporting

  • Backends validate reporting requirements at construction and filter incompatible resources
  • Clear runtime errors when no compatible resources remain after filtering

Summary of changes to look out for from individual components:

  • Documentation:
    • Removal of public select API
  • Examples:
    • Policy template argument adjustment (by resource first rather than backend)
  • Policies:
    • Adjustment to use policy_base, remove repetative code
    • Implement try_select_impl instead of select
    • Implement initialize_impl instead of initialize
  • Sycl Backend:
    • Conversion to partial specialization of default backend, use of backend_base
    • Addition of ResourceAdapter to support different flavors from a single base resource / backend
    • Improve system of reporting requirements for better filtering and error messages
    • Adjust support for profiling to require sycl extension for profiling (only reliable way to time)
      • Filter devices accordingly
  • Tests:
    • Removal of testing of select before submit
    • Addition of default universe initialization testing
    • Addition of testing of use of resource adapter to support sycl::queue* in addition to sycl::queue

egfefey added 30 commits May 20, 2025 22:34
…t after, also removed submit from the sycl_backend. Now uses the base implementation
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger
<dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
and ``submit_and_wait`` functions select a resource and then pass the chosen resource
to a developer-provided function.
Policy objects are used as arguments to the dynamic selection functions. The
``try_submit`` function attempts to select a resource and returns null if none are
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this return a std::optional now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, fixed.

Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Comment on lines +71 to +72
Lazy Reporting
--------------
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should name it "on-demand reporting" or similarly - at least in the documentation (while the API naming can be discussed / addressed later).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vossmjp Do you have an opinion here? This is not something new in the design, but just something we've documented. I have no strong opinions here, but there are a few places we would have to change it if we choose to.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, my comment is primarily about the documentation. And it's also minor and can be postponed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong objection to the change itself, but I'd prefer to defer all but essential changes at this point so we can get things merged.

Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Copy link
Contributor

@akukanov akukanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approval is for the public documentation update in the PR. I have not reviewed anything else.

Copy link
Contributor

@vossmjp vossmjp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@SergeyKopienko SergeyKopienko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@egfefey egfefey merged commit d61d6ae into main Dec 4, 2025
22 of 23 checks passed
@egfefey egfefey deleted the dev/egfefey/custom_backend_tests branch December 4, 2025 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants