-
Notifications
You must be signed in to change notification settings - Fork 231
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
Assorted interpreter fixes #3430
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
66e2f93
renamed actors6.dd -> chrono.dd for time, etc.
mahrud fc0b8b8
removed unused binopExpr
mahrud 0d9fac9
removed obsolete newLocalFrameCode
mahrud 73d2d8f
removed ambiguous interpreter typedef 'fun'
mahrud c91ce3b
removed ambiguous 'class', 'new' in c/d sources
mahrud b7c5605
removed double semicolon from interpreter exports
mahrud 5f7a387
fixed typo in parse.d
mahrud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
-- TODO: get core time: number of cpu clock ticks spent in the core/libraries | ||
-- TODO: define time and elapsedTime in the top level instead, and print in the AfterPrint | ||
-- TODO: auto-calibrate spin based on the wall time | ||
|
||
use arithmetic; -- for types | ||
use binding; -- for symbols | ||
use evaluate; -- for eval | ||
use expr; -- for timeClass | ||
use struct; -- for Sequence | ||
use system; -- for cpuTime | ||
use stdio; -- for tostringRR | ||
use actors5; -- for gcTime | ||
|
||
declarations "#include <chrono>"; | ||
|
||
-- The typedef from this type declaration is put into the include file chrono-exports.h, | ||
-- so that means we can write "use chrono;" only in a *.dd file, not in a *.d file. | ||
-- That's why we are renaming interp.d to interp.dd. Eventually all *.d files should | ||
-- be renamed. | ||
Chrono := Type "std::chrono::steady_clock::time_point" ; | ||
|
||
----------------------------------------------------------------------------- | ||
-- Top level timing functions | ||
----------------------------------------------------------------------------- | ||
|
||
cpuTime(e:Expr):Expr := ( | ||
when e is s:Sequence do | ||
if length(s) == 0 then toExpr(cpuTime()) | ||
else WrongNumArgs(0) | ||
else WrongNumArgs(0)); | ||
setupfun("cpuTime", cpuTime); | ||
|
||
cpuTimer(c:Code):Sequence := ( | ||
T0 := cpuTime(); | ||
ret := eval(c); | ||
T1 := cpuTime(); | ||
Sequence(toExpr(T1 - T0), ret)); | ||
|
||
wallTimer(c:Code):Sequence := ( | ||
T0 := Ccode(Chrono, "std::chrono::steady_clock::now()"); | ||
ret := eval(c); | ||
T1 := Ccode(Chrono, "std::chrono::steady_clock::now()"); | ||
dT := double(Ccode(uint64_t, "(", T1, " - ", T0, ").count()")); | ||
dT = dT/1000000000.; | ||
Sequence(toExpr(dT), ret)); | ||
|
||
showtimefun(a:Code):Expr := ( | ||
cpuStart := cpuTime(); | ||
threadStart := threadTime(); | ||
gcStart := gcTime(); | ||
ret := eval(a); | ||
cpuEnd := cpuTime(); | ||
threadEnd := threadTime(); | ||
gcEnd := gcTime(); | ||
stdError << " -- used " | ||
<< cpuEnd - cpuStart << "s (cpu); " | ||
<< threadEnd - threadStart << "s (thread); " | ||
<< gcEnd - gcStart << "s (gc)" << endl; | ||
ret); | ||
setupop(timeS,showtimefun); | ||
|
||
-- TODO: should "timing" return thread and gc times like "time"? | ||
timingfun(c:Code):Expr := ( | ||
s := cpuTimer(c); | ||
when s.1 is Error do s.1 else list(timeClass, s)); | ||
setupop(timingS, timingfun); | ||
|
||
elapsedTimefun(c:Code):Expr := ( | ||
s := wallTimer(c); | ||
when s.0 is dT:RRcell do ( | ||
stdError << " -- " << tostringRR(dT.v) << "s elapsed" << endl;) | ||
else nothing; s.1); | ||
setupop(elapsedTimeS,elapsedTimefun); | ||
|
||
elapsedTimingfun(c:Code):Expr := ( | ||
s := wallTimer(c); | ||
when s.1 is Error do s.1 else list(timeClass, s)); | ||
setupop(elapsedTimingS,elapsedTimingfun); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Oh, I should say that I wrote this commit a long time ago. I don't really agree with the second item anymore.