Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add experimental task hints API, support for 2D splits #227

Merged
merged 2 commits into from
Dec 5, 2023
Merged

Conversation

psalz
Copy link
Member

@psalz psalz commented Nov 16, 2023

This adds a new experimental::hint API that can be used to provide the runtime with additional information on how to process a task. The first two hints we have are experimental::hints::split_1d and experimental::hints::split_2d. As a 1D split is currently the default, the former is a no-op. For the latter this introduces a new split_2d function that attempts to produce a number of evenly sized chunks while satisfying the provided granularity constraints.

The algorithm works by trying to find two factors for num_chunks, the number of requested chunks, that are as close to sqrt(num_chunks) as possible while also producing the requested number of chunks, degrading to a 1D split in the worst case. Due to granularity constraints it is not always possible to produce the requested number of chunks however, in that case the algorithm will attempt to get as close as possible. Finding the factors requires at most O(sqrt(num_chunks)) time.

Given the two factors, the algorithm uses two heuristics to decide to which side of the domain they should be assigned:

  • If the domain is square-ish, the algorithm prefers to have more splits along the slower dimension.
  • If the domain is non-square, the algorithm prefers the split that produces overall shorder edges (smaller sum of circumferences).

Here's a visual representation of some of the 2D splits from the unit tests. Each split is labelled in the form <size0>x<size1> ~ <granularity0>x<granularity1> | <num chunks>. Red lines represent split constraints (i.e., individual red boxes can not be split further):

image

@psalz psalz requested review from PeterTh, fknorr and GagaLP November 16, 2023 16:18
Copy link

Check-perf-impact results: (3b34e58e3c100f4c3541a1ed59580f72)

❓ No new benchmark data submitted. ❓
Please re-run the microbenchmarks and include the results if your commit could potentially affect performance.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

src/split.cc Show resolved Hide resolved
src/split.cc Show resolved Hide resolved
src/split.cc Show resolved Hide resolved
src/split.cc Show resolved Hide resolved
src/split.cc Show resolved Hide resolved
src/split.cc Show resolved Hide resolved
src/split.cc Show resolved Hide resolved
Copy link
Contributor

@PeterTh PeterTh left a comment

Choose a reason for hiding this comment

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

Great work! I have a few comments/questions.

include/handler.h Outdated Show resolved Hide resolved
include/hint.h Show resolved Hide resolved
include/hint.h Show resolved Hide resolved
src/split.cc Show resolved Hide resolved
src/split.cc Outdated Show resolved Hide resolved
test/split_tests.cc Outdated Show resolved Hide resolved
Copy link
Contributor

@fknorr fknorr left a comment

Choose a reason for hiding this comment

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

Nice! That is an impressive amount of testing. Some code, especially split_2d internals, is rather hard to understand though.

include/handler.h Outdated Show resolved Hide resolved
include/hint.h Show resolved Hide resolved
src/split.cc Outdated Show resolved Hide resolved
src/split.cc Outdated Show resolved Hide resolved
src/split.cc Outdated Show resolved Hide resolved
src/split.cc Outdated Show resolved Hide resolved
fknorr pushed a commit to fknorr/celerity-runtime that referenced this pull request Nov 18, 2023
Task hints are a means of providing the runtime with additional
information on how to process a task, allowing users to incorporate
their domain knowledge. Crucially, hints are non-binding, i.e., the
runtime might decide to not honor a hint (e.g. if a heuristic indicates
a better way).
@fknorr
Copy link
Contributor

fknorr commented Nov 28, 2023

I noticed that task_manager::submit_command_group has a hints parameter, I guess that's obsolete now.

Copy link
Contributor

@fknorr fknorr left a comment

Choose a reason for hiding this comment

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

Looks great!

src/split.cc Show resolved Hide resolved
include/handler.h Outdated Show resolved Hide resolved
fknorr pushed a commit to fknorr/celerity-runtime that referenced this pull request Dec 5, 2023
@psalz psalz added this to the 0.5.0 milestone Dec 5, 2023
psalz added 2 commits December 5, 2023 12:31
Task hints are a means of providing the runtime with additional
information on how to process a task, allowing users to incorporate
their domain knowledge. Crucially, hints are non-binding, i.e., the
runtime might decide to not honor a hint (e.g. if a heuristic indicates
a better way).
This adds two new task hints, `split_1d` and `split_2d`, which influence
the way tasks are split into chunks. The latter uses a new splitting
function of the same name; all splitting related functionality is moved
into a separate file and tests for both 1D and 2D splitting are
included.
Copy link

github-actions bot commented Dec 5, 2023

Check-perf-impact results: (4c65f1399a47e0eb1340f63004745b17)

❓ No new benchmark data submitted. ❓
Please re-run the microbenchmarks and include the results if your commit could potentially affect performance.

@psalz psalz merged commit 404e325 into master Dec 5, 2023
28 checks passed
@psalz psalz deleted the task-hints branch December 5, 2023 12:42
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.

3 participants