-
Notifications
You must be signed in to change notification settings - Fork 63
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
Update Python target APIs to match the C target updates #1116
Conversation
f0339dc
to
b8fb84c
Compare
Looks great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
How do I use lf.time.physical_elapse() now? When I try to schedule an action based on the physical elapsed time, I get the following error.
I generated the python code using lfc (release 0.2.0) command line. Thereafter, I Am I missing something? Furthermore, the generated python code worked with the previous release of lfc. |
Shouldn't it be |
Oops, my bad. Thanks for pointing out the typo. Unfortunately, my code still does not work with latest release. The code fragment gets blocked at
|
Would you mind elaborating on what you mean by "the code fragment gets blocked"? Does the line |
I agree with @housengw that we need a bit more information about your specific situation to be able to comment definitively. Your program’s output would be really helpful. A fully executable minimal LF program that exhibits this behavior would be even better. Based on the information that we have, is disparityMap a port? In that case, you would want to check and use |
I used the exact code you provided but was unable to reproduce the halting behavior. Are you using the latest version of Below is the output of my program:
|
Right I was able to getting it working on a x86-64 Linux. However the problem seems to occur only on ARMv7 Linux (Raspberry Pi4). Furthermore, I noticed that the following lines of output in your run (also reproduced on x86-64 Linux)
Notice the
Could be that the timer is not properly initialized in ARM platforms? |
An implementation of the timing routines is chosen based on the platform on which the program is compiled. Could it be that the wrong implementation is being used? See: https://github.com/lf-lang/reactor-c/blob/2ceec60bc3d9b3420553f66813c40790d1e28c85/core/platform.h#L45 |
Very interesting. Is it possible that the Raspberry Pi has been running for 7 hours? In that case, it's clock is not synchronized to UTC. I have no idea, however, why this would cause schedule or time.physical_elapsed to not return... We should drill into this. I suspect the ARMv7 is a 32 bit processor and maybe needs a different implementation of the time functions. I don't think we've done any testing on 32 bit processors running Linux (though we have done some testing on bare iron 32 bit processors). |
Would you please enable logging and post the output here?
|
@lhstrh should I rebuild LFC for Raspberry-Pi4 from the source? I am using the release version (), which I suspect has been compiled for x86-64 Linux systems only. @edwardalee here's the complete log from Raspberry-Pi's run
I actually kept the program running for around 24 hours on Raspberry Pi. And unbeknownst to me, it did execute some of the reactions, albeit with unreasonably long (and unpredictable) delays. |
@edwardalee and @Soroosh129. I do not have access to the board as of now. I would update the detailed spec and the new run result with debugging enabled soon. |
@Arka2009, there is no need to rebuild
Thanks! |
The DEBUG log is quite big (>300MB) for only seconds of program run. I am sharing it as a Dropbox Link (https://www.dropbox.com/s/mvjewtt79vdu1lb/SimplifiedPhysicalActionsDebugOut.txt?dl=0). Let me know if you can access it. Besides the system information is below.
|
The long delays suggest that the time reported by Linux is not nanoseconds but is being interpreted as nanoseconds. In the trace you provided, it covered about 2 seconds of logical time in about 24 hours, which suggests that each bit of its time represents about 50 microseconds rather than one nanosecond. This would explain the difference in starting dates reported on the two platforms. Using this website: https://www.unixtimestamp.com, the two dates have a ration roughly on the order of 50,000. What time zone are you in? Knowing that, we could calculate the ratio exactly. The following website suggests a C program you could compile and run to determine whether the clock resolution is 1 ns: https://raspberrypi.stackexchange.com/questions/36674/raspberry-pi-raspbian-tick-rate-in-hz As a wild guess, you could try this in the LF program: target C { |
We do ask CMake to require C11 but this is not the case for the Python target (which doesn’t use CMake). If the C standard is the problem, I can find a way to enforce C11 or C99 in the Python target as well. One way to find that out is to create an equivalent (or a simpler test) program in the C target on the Raspberry Pi and see how it behaves. |
@edwardalee, my time zone is UTC+8:00 (Singapore Time). @Soroosh129 based on your suggestion, I am trying to create an equivalent LF-C program as below
Here the Once this code is ready, I can test it on Raspberry-Pi and amd64 desktop and study the behaviour with different compile options. |
Thank you for taking the time to convert your code to C. To answer your question, yes, you can pass the action as a |
Notice that you should use I suspect the problem with the implementation on the Raspberry Pi is more fundamental and would show up with a much simpler example. I suspect that the OS time functions we are relying on may not actually be POSIX compliant. Can you try running some of the tests? E.g., this one: ActionDelay. It should print:
|
Thanks for referring the Lingua-Franca handbook. @edwardalee I was able to reproduce the anomalous behaviour with the test case. I had to run the generated binary with Raspberry-Pi4 (Raspbian OS, Bulls eye)
x86-64 Linux
FYI I ran the binary many more times on Raspberry Pi. There were quite often a perceptible delay (> 1.5s), which should ideally take around 0.1ms (as it does in x86-64/Linux platform). The binary runtime also varied a lot. |
Just out of curiosity, how does the Python version of ActionDelay perform on the Pi? |
I don't see the display log, so I'm not sure what you mean by being able to reproduce the anomalous behavior. What exactly was the anomalous behavior? |
I mean the program output, including the output of |
I was expecting the compiled binary to run in little more than 0.1s (say 0.11-0.15s). Please correct if I am wrong. I use the In x86-64/Linux platforms I observe this expected behaviour, not in Raspberry Pi. |
Ok, I see it now... |
I think I still don’t see the anomalous behavior that was causing 2 seconds in logical time to take a day. What I see from running ActionDelay is that the Raspberry Pi is slow, as expected: amaity@pios3:~/Desktop/WasteBoard_EdgePipeline $ time /home/amaity/Desktop/WasteBoard_EdgePipeline/OUT/bin/SimplifiedC_2
---- Start execution at time Thu Jan 1 07:30:00 1970
---- plus 0 nanoseconds.
---- Using 4 workers.
Logical, physical, and elapsed logical: 100000000 100003696 100000000.
SUCCESS. Elapsed logical time is 100 msec.
---- Elapsed logical time (in nsec): 100,000,000
real 0m0.395s
user 0m0.133s
sys 0m0.234s Here, user time is shown as 133 msecs for 100 msec in logical time. Even if we take the highest number in the range, which would be 600 msecs, that can’t be due to time being reported as microseconds, I think, since 100 million microseconds is 1 minute 40 seconds. |
@Soroosh129 , there is also a case, where the user time is 559ms.
|
@Arka2009 Would you please create an issue so that we don’t lose track of this? |
This PR updates the API of the python target according to the API change in the C target merged in #1097.
All of the old names are marked as deprecated.
Format:
old name -> new name
means that the API is renamed fromold name
tonew name
.old name
is still available in the current release, but will be removed in a future release.old name
(deprecated) means that theold name
has not been renamed, and will be removed in a future release.new name
(new) means that the API is introduced in the linked PR.Python target:
-
get_current_tag
->lf.tag()
-
compare_tags
->lf.tag_compare()
-
get_microstep
(deprecated)-
get_elapsed_logical_time
->lf.time.logical_elapsed()
-
get_logical_time
->lf.time.logical()
-
get_physical_time
->lf.time.physical()
-
get_elapsed_physical_time
->lf.time.physical_elapsed()
-
get_start_time
->lf.time.start()