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

Adaptive scheduler for C target #1207

Merged
merged 15 commits into from
Jun 22, 2022
Merged

Adaptive scheduler for C target #1207

merged 15 commits into from
Jun 22, 2022

Conversation

petervdonovan
Copy link
Collaborator

@petervdonovan petervdonovan commented May 31, 2022

To clarify -- this is the scheduler that previously had the vague name "heuristic."

This scheduler is written in response to poor scaling behavior wrt number of threads in our Savina benchmarks. It achieves good performance on these benchmarks, but it is uncertain whether this good performance will generalize beyond them.

Some notes:

  • These graphs are not the most up-to-date, but they should be close enough. A-Star has a known bug, so scaling behavior in that benchmark probably can be ignored.
  • Some of the logic implemented here, in the main LF repo, has to do with finding the files related to a particular pluggable scheduler. It may soon be deleted anyway, for we may choose to refactor to use CMake for that sort of thing.
  • Other schedulers which we should implement soon will hopefully replace this scheduler for at least some use cases. Annotations that specify order-of-magnitude estimates of reaction WCETs may in some applications replace the experiments that this scheduler does at runtime. Some of the strategies implemented by this scheduler may also be realizable without sacrificing the worst-case execution time of levels. Furthermore, schedulers ideally should not rely on levels, as this scheduler does. They should have chain ID (or something like it) and LET instead.
    • This is relevant because it means I regard this scheduler as experimental and argue that its general level of quality may not be as critical as in e.g. the GEDF scheduler.

benchmarks-4-3

@petervdonovan petervdonovan force-pushed the c-scaling-wrt-threads branch 2 times, most recently from 11c7278 to 880734f Compare May 31, 2022 18:30
@Soroosh129
Copy link
Contributor

It looks like the Windows tests are failing because of a path-related issue:

A required target resource could not be found: /lib/c/reactor-c/core/threaded\scheduler_NP.c

@petervdonovan petervdonovan force-pushed the c-scaling-wrt-threads branch from 880734f to 8575800 Compare June 1, 2022 00:29
@petervdonovan petervdonovan force-pushed the c-scaling-wrt-threads branch from 61ef088 to 36c2e76 Compare June 7, 2022 05:18
@petervdonovan petervdonovan changed the title C heuristic-based scheduler C adaptive scheduler Jun 9, 2022
@petervdonovan petervdonovan force-pushed the c-scaling-wrt-threads branch from 9d25354 to 9969d5f Compare June 9, 2022 17:35
@petervdonovan petervdonovan marked this pull request as ready for review June 9, 2022 17:36
Copy link
Contributor

@Soroosh129 Soroosh129 left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for cleaning up the logic in the validator.

@@ -112,13 +115,16 @@ private static List<String> getThreadSupportFiles(
SchedulerOption scheduler
) {
return threading ?
List.of(
Stream.concat(
Stream.of(
"threaded/scheduler.h",
"threaded/scheduler_instance.h",
"threaded/scheduler_sync_tag_advance.c",
"threaded/scheduler_" + scheduler + ".c",
Copy link
Contributor

@Soroosh129 Soroosh129 Jun 20, 2022

Choose a reason for hiding this comment

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

This line seems to not be necessary for the adaptive scheduler since scheduler.getRelativePaths() already includes this. Would it make sense to have all these files added in the enum constructor for all schedulers?

Copy link
Collaborator Author

@petervdonovan petervdonovan Jun 20, 2022

Choose a reason for hiding this comment

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

Oh, good catch... I'll fix that. The other three files -- scheduler.h, scheduler_instance.h, and scheduler_sync_tag_advance.c -- are currently used by all schedulers, I think, so to me it seems reasonable to limit redundancy by keeping them here.

(BTW, I have for a while been making noises about factoring this logic out into CMake files, so if others agree with me then this code might not be here for long anyway.)

Edit: The adaptive scheduler doesn't use scheduler_instance.h, actually, but I think it's harmless to copy it into the src-gen directory. I don't think doing so has any effect on the executable produced.

Copy link
Contributor

Choose a reason for hiding this comment

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

Factoring this logic out into CMake files

This sounds like a great idea. Are you imagining each scheduler having a separate CMakeLists.txt or one CMakeLists.txt for all the schedulers?

One thing to keep in mind is that we should still be able to accommodate cmake: false (i.e., building without CMake).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How important is it to accommodate cmake: false? Maybe this isn't the place to have this discussion, but I am not aware of use-cases for cmake: false, and what I was talking about was basically to do away with it. Do we maintain it just for fun?

Copy link
Contributor

Choose a reason for hiding this comment

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

It’s for embedded systems, particularly bare-iron, that don’t necessarily have a supported CMake-based workflow.

@petervdonovan petervdonovan merged commit 9cb9ae7 into master Jun 22, 2022
@petervdonovan petervdonovan deleted the c-scaling-wrt-threads branch June 22, 2022 23:18
@Soroosh129 Soroosh129 added the enhancement Enhancement of existing feature label Jul 1, 2022
@lhstrh lhstrh changed the title C adaptive scheduler Adaptive scheduler for C target Jul 7, 2022
@lhstrh lhstrh added the feature New feature label Jul 7, 2022
@lhstrh lhstrh removed the enhancement Enhancement of existing feature label Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants