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

The 'threading' CLI option/build param/target property changed to 'single threaded' #1817

Merged
merged 28 commits into from
Nov 8, 2023

Conversation

patilatharva
Copy link
Collaborator

@patilatharva patilatharva commented Jun 4, 2023

Todo:

  • Change docs accordingly.
  • Rename all occurrences of "unthreaded" to "single threaded".
  • Add validation check to ensure mutual exclusivity between workers and single-threaded
  • Return error upon specifying single-threaded on a federated program.

Also fixes #2080 in the sense that we now adjust paths for any target property that extends FileListProperty.

@cmnrd
Copy link
Collaborator

cmnrd commented Jun 5, 2023

I am not sure if "single threaded" is a good name. I expect that it is difficult for users to see the difference between --single-threaded and --threads=1. Perhaps --unthreaded would be clearer?

@lhstrh
Copy link
Member

lhstrh commented Jun 5, 2023

I am not sure if "single threaded" is a good name. I expect that it is difficult for users to see the difference between --single-threaded and --threads=1. Perhaps --unthreaded would be clearer?

What would actually happen if both --single-threaded and --threads=1 are used?

@cmnrd
Copy link
Collaborator

cmnrd commented Jun 5, 2023

I am not sure if "single threaded" is a good name. I expect that it is difficult for users to see the difference between --single-threaded and --threads=1. Perhaps --unthreaded would be clearer?

What would actually happen if both --single-threaded and --threads=1 are used?

There should be an error message. I am not sure if there is one in place right know, but setting the number of workers in the unthreaded runtime should be an error (or at least a warning). Also using --single-threaded on targets that don't have an unthreaded runtime should be an error.

Copy link
Collaborator

@petervdonovan petervdonovan left a comment

Choose a reason for hiding this comment

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

This looks good to me, as long as other people are happy with the "single-threaded" terminology (there was a discussion on Zulip). Thanks Atharva!

Copy link
Member

@lhstrh lhstrh left a comment

Choose a reason for hiding this comment

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

Looks good!

The absence of changes to the validator suggests that the combination of the single-threaded and threads target property isn't being checked for, which we should do, as @cmnrd suggested. Would you be able to fix this?

@patilatharva
Copy link
Collaborator Author

patilatharva commented Jul 3, 2023

The absence of changes to the validator suggests that the combination of the single-threaded and threads target property isn't being checked for, which we should do, as @cmnrd suggested. Would you be able to fix this?

I just added checks in the validator and CLI to make it illegal to set workers when single-threaded is enabled. To clarify, this makes the CLI combination of --single-threaded and --workers=1 illegal, but in LF syntax single-threaded: false, workers: 2 is still allowed.

@lhstrh lhstrh requested a review from edwardalee July 3, 2023 20:58
Copy link
Collaborator

@edwardalee edwardalee left a comment

Choose a reason for hiding this comment

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

This is nice! However, I'm not sure what workers means. It says it specifies the "default" number of workers, but I would think that the default number of workers would be what you get when you do not specify the workers property. Also, we will now have an inconsistency with the website. I suggest starting a release-4 branch of the lf-website repo and update the documentation in this following locations:

https://www.lf-lang.org/docs/handbook/target-declaration#threading

https://www.lf-lang.org/docs/handbook/target-declaration#workers

https://www.lf-lang.org/docs/handbook/target-declaration#command-line-arguments

https://www.lf-lang.org/docs/handbook/target-language-details?target=c#single-threaded-implementation

https://www.lf-lang.org/docs/handbook/target-language-details?target=c#multithreaded-implementation

cli/lfc/src/main/java/org/lflang/cli/Lfc.java Show resolved Hide resolved
cli/lfc/src/main/java/org/lflang/cli/Lfc.java Outdated Show resolved Hide resolved
test/C/src/arduino/BlinkAttemptThreading.lf Outdated Show resolved Hide resolved
test/C/src/zephyr/threaded/UserThreads.lf Outdated Show resolved Hide resolved
@lhstrh lhstrh requested a review from erlingrj July 5, 2023 23:18
@cmnrd
Copy link
Collaborator

cmnrd commented Jul 6, 2023

I just added checks in the validator and CLI to make it illegal to set workers when single-threaded is enabled. To clarify, this makes the CLI combination of --single-threaded and --workers=1 illegal, but in LF syntax single-threaded: false, workers: 2 is still allowed.

What is the reason for allowing single-threaded: false, workers: 2 in the target properties? Shouldn't this be illegal too?

Copy link
Collaborator

@erlingrj erlingrj left a comment

Choose a reason for hiding this comment

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

Looks good, couple of comments. We should do some renaming in reactor-c also since "unthreaded" is used quite alot

test/C/src/arduino/BlinkAttemptThreading.lf Outdated Show resolved Hide resolved
test/C/src/zephyr/threaded/UserThreads.lf Outdated Show resolved Hide resolved
@patilatharva
Copy link
Collaborator Author

What is the reason for allowing single-threaded: false, workers: 2 in the target properties? Shouldn't this be illegal too?

@cmnrd I was thinking it's technically correct to explicitly disable the single-threaded property when multiple workers are specified (even if the single-threaded: false is redundant), but do you think it's better design to just make the two properties mutually exclusive?

Copy link
Collaborator

@edwardalee edwardalee left a comment

Choose a reason for hiding this comment

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

This looks good to me. I have made some updates in the release-5 branch of the lf-lang website and requested your review to make sure I got it right. Thanks!

@lhstrh
Copy link
Member

lhstrh commented Nov 3, 2023

@patilatharva, I did not yet merge this PR due to bigger changes that were happening in #2008. I will fix this PR after #2008 has been merged. (Expect force pushes on single-threaded.)

@lhstrh lhstrh added this to the 0.6.0 milestone Nov 3, 2023
@lhstrh lhstrh enabled auto-merge November 6, 2023 08:20
Copy link
Collaborator

@erlingrj erlingrj left a comment

Choose a reason for hiding this comment

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

It seems many of these changes here are not related to moving from threading to single-threaded. They seem to part of the general target-property updates? I did not look closely on them because I think I am lacking that context. Otherwise looks good. But we are still code-generating LF_THREADED and LF_UNTHREADED so I guess we should move to LF_SINGLE_THREADED to be compatible with the reactor-c PR?

@lhstrh
Copy link
Member

lhstrh commented Nov 6, 2023

It seems many of these changes here are not related to moving from threading to single-threaded. They seem to part of the general target-property updates? I did not look closely on them because I think I am lacking that context. Otherwise looks good. But we are still code-generating LF_THREADED and LF_UNTHREADED so I guess we should move to LF_SINGLE_THREADED to be compatible with the reactor-c PR?

Right, there is some overflow from #2008 that crept into this PR, but that's OK; they are closely related and I had to quite drastically alter the code in this PR to accommodate the changes in #2008.

@erlingrj
Copy link
Collaborator

erlingrj commented Nov 7, 2023

@lhstrh, there is a segfault in one of the federated Python programs, not reproducible on my end. Also very hard to see how the seg-fault in Python is due to doing this renaming

@lhstrh
Copy link
Member

lhstrh commented Nov 7, 2023

@lhstrh, there is a segfault in one of the federated Python programs, not reproducible on my end. Also very hard to see how the seg-fault in Python is due to doing this renaming

I also think it's unlikely that this is due to these changes in this PR. Maybe it's related to lf-lang/reactor-c#293.

@lhstrh
Copy link
Member

lhstrh commented Nov 7, 2023

The problem is that our reactor-c CI doesn't run the Python tests...so we don't find out that something is broken until we update the reactor-c submodule pointer in lingua-franca...

@lhstrh lhstrh added this pull request to the merge queue Nov 8, 2023
Merged via the queue into master with commit 1a96598 Nov 8, 2023
41 checks passed
@lhstrh lhstrh deleted the single-threaded branch November 8, 2023 06:51
@lhstrh lhstrh added the refactoring Code quality enhancement label Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Code quality enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Merging of target properties in federations is brittle and incomplete
6 participants