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

USER_THREADS specifiable in platform options #1721

Merged
merged 37 commits into from
May 30, 2023

Conversation

siljesu
Copy link
Contributor

@siljesu siljesu commented Apr 28, 2023

In reference to this PR: lf-lang/reactor-c#194

USER_THREADS can now be specified under platform options in target properties:

platform: {
name: Zephyr,
user_threads: 3
}

@erlingrj
Copy link
Collaborator

I think this looks okay. For now it is only Zephyr which needs this so its okay to only expose it (i.e. add the NUM_USER_THREADS compile def) when Zephyr is the target platform.

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.

Thanks, @siljesu! This looks like a good start. I've requested some changes that are mostly to enforce conventions. Two things that I think we should add:

  • a test
  • a validator check to point out that this property is ignored if the platform is not Zephyr

org.lflang/src/org/lflang/TargetProperty.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/TargetProperty.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/TargetProperty.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/generator/c/CGenerator.java Outdated Show resolved Hide resolved
@erlingrj
Copy link
Collaborator

Did you get a chance to look at Martens suggestion, @siljesu ?

@siljesu
Copy link
Contributor Author

siljesu commented May 12, 2023

Yes, take a look at the newest commits.

test/C/src/zephyr/UserThreads.lf Outdated Show resolved Hide resolved
test/C/src/zephyr/UserThreads.lf Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/generator/c/CGenerator.java Outdated Show resolved Hide resolved
@erlingrj
Copy link
Collaborator

Try running bin/lff test/C from the root of the project to run the Lingua Franca Formatter on all the tests. This will format your newly added tests

@siljesu siljesu requested a review from lhstrh May 18, 2023 08:00
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.

LGTM!

@erlingrj
Copy link
Collaborator

The remaining problem is that, in the test system, I explicitly set the threading=false on all tests executed by Zephyr.

In the file Configurators.java you can look at makeZephyrCompatible, This is used in CZephyrTests.java. I propose to make two separate. One:
makeZephyrCompatibleUnthreaded and makeZephyrCompatible. Use the former for runGenericTests and use the altter for runZephyrTests. This way your test will run, but runGenericTests will still be with unthreaded.

@siljesu
Copy link
Contributor Author

siljesu commented May 19, 2023

OK, take a look at the newest commit.

In addition, threaded Zephyr will generate an error "Threaded support on Zephyr is not supported" as of now (from lf_zephyr_support.c). This should probably be removed soon, or else threaded Zephyr tests will always fail regardless. I propose replacing it with a warning "Threaded support on Zephyr is still experimental". If you agree, I can make that change in lf-lang/reactor-c#194.

@erlingrj
Copy link
Collaborator

Yes, change it into a warning about it being experimental. These two PRs should be merged together. I will then get the threaded tests running on Zephyr, at which point we can remove that warning

@erlingrj
Copy link
Collaborator

OK. I have merged the changes into reactor-c. Now you only have to update your reactor-c pointer to the most recent commit on main and we can actually run the test in CI

@erlingrj
Copy link
Collaborator

Silje, there is something not working with the the joining of zephyr threads. The UserThreads program does not exit as expected, rather the main thread is stuct at lf_thread_join even after the worker has completed. I wonder if this could be a QEMU problem. Could you test the UserThreads.lf program on your NXP and verify that it indeed terminates. It should print exit at the end of the execution

@siljesu
Copy link
Contributor Author

siljesu commented May 25, 2023

Yes, the program exits as expected when running on an NXP.

@lhstrh lhstrh force-pushed the zephyr-target-prop branch from 8b01b71 to aad2ef3 Compare May 26, 2023 05:10
@erlingrj
Copy link
Collaborator

@lhstrh Lets merge this, finally...

@lhstrh
Copy link
Member

lhstrh commented May 30, 2023

Thanks you for your persistence, @erlingrj and @siljesu, and getting this to pass all the checks.

@lhstrh lhstrh requested review from erlingrj and removed request for erlingrj May 30, 2023 18:50
@lhstrh lhstrh merged commit 1f0bc0c into lf-lang:master May 30, 2023
@cmnrd
Copy link
Collaborator

cmnrd commented May 31, 2023

I noticed that this PR checked in the binary file test/C/lib/libapp.a but it does not seem to be referenced anywhere. Was this on purpose? If so, why is it needed? I think we should avoid checking in binary files.

@erlingrj
Copy link
Collaborator

Ops. That is a mistake!

@erlingrj
Copy link
Collaborator

I removed it again in #1803

@lhstrh lhstrh changed the title Make USER_THREADS possible to specify in platform options USER_THREADS specifiable in platform options Aug 28, 2023
@lhstrh lhstrh added the feature New feature label Aug 28, 2023
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.

4 participants