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

Update Documentation #729

Merged
merged 26 commits into from
Nov 5, 2024
Merged

Update Documentation #729

merged 26 commits into from
Nov 5, 2024

Conversation

yamaguchi1024
Copy link
Member

@yamaguchi1024 yamaguchi1024 commented Oct 21, 2024

Add documentation for design, imports, system overview, externs, inspection, instructions, memories, and object code. Also add the Cursor example in examples/cursors.

Copy link

codecov bot commented Oct 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.00%. Comparing base (cebef49) to head (4c99d64).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #729   +/-   ##
=======================================
  Coverage   88.00%   88.00%           
=======================================
  Files          86       86           
  Lines       20965    20965           
=======================================
  Hits        18450    18450           
  Misses       2515     2515           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yamaguchi1024 yamaguchi1024 force-pushed the docs branch 2 times, most recently from 8fdd8fd to ccbbfdf Compare October 23, 2024 18:56
@yamaguchi1024 yamaguchi1024 marked this pull request as ready for review October 27, 2024 23:34
@yamaguchi1024 yamaguchi1024 changed the title Update docs Update Documentation Oct 27, 2024
docs/README.md Show resolved Hide resolved
docs/Design.md Outdated Show resolved Hide resolved
docs/Design.md Outdated Show resolved Hide resolved
docs/Design.md Outdated Show resolved Hide resolved
docs/System.md Show resolved Hide resolved
docs/externs.md Show resolved Hide resolved
examples/cursors/cursors.py Show resolved Hide resolved
docs/memories.md Show resolved Hide resolved
docs/memories.md Show resolved Hide resolved
docs/instructions.md Show resolved Hide resolved
docs/object_code.md Show resolved Hide resolved
docs/Imports.md Outdated Show resolved Hide resolved
docs/externs.md Outdated Show resolved Hide resolved

- Generates the code that calls the external function, ensuring proper casting to the primitive type.

##### `globl(self, prim_type)`
Copy link
Contributor

Choose a reason for hiding this comment

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

Mention that this globl function is called for each unique prim_type.

By the way, this is better left for a different PR, but this means many externs don't work reliably if we mix precisions due to C name collisions. For example

@proc
def foo_sigmoid(xo : f32, yo : f64, xi : f32, yi : f64):
    xo = sigmoid(xi)
    yo = sigmoid(yi)

generates a C file that starts with

#include <math.h>
double sigmoid(double x) {
    return 1 / (1 + exp(-x));
}


#include <math.h>
float sigmoid(float x) {
    return 1 / (1 + exp(-x));
}

which is invalid (C does not support function overloading).

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! Yeah this is a bug, I filed it here: #737 737

docs/externs.md Outdated

Externs can be used as expressions on the RHS of assignment and reduction statements. This allows you to incorporate external functions seamlessly into your Exo computations.

Note that externs (and Exo procedures) do not allow aliasing in their arguments. This restriction is in place to prevent externs from having side effects on the input arguments.
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this restriction because externs can have side effects on their arguments, and thus we need the aliasing restriction for the same reason extended C++ has restrict?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, Exo procedures can modify their arguments (like put output in the out buffer), but externs should not be able to modify their arguments. Externs return the expression instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, externs actually allow aliasing.

@proc
def foo(xo : f32, yo : f64, xi : f32, yi : f64):
    xo = select(xi, xi, xi, xi) 

gets compiled into

 float _select_float(float x,float v,float y,float z) {
    if (x < v) return y;
    else return z;
}

// foo(
//     xo : f32 @DRAM,
//     yo : f64 @DRAM,
//     xi : f32 @DRAM,
//     yi : f64 @DRAM
// )
void foo( void *ctxt, float* xo, const double* yo, const float* xi, const double* yi ) { 
*xo = _select_float((float)*xi, (float)*xi, (float)*xi, (float)*xi);
}

docs/memories.md Outdated Show resolved Hide resolved
docs/instructions.md Outdated Show resolved Hide resolved
@@ -0,0 +1,50 @@
# External Inspection Functions
Copy link
Contributor

Choose a reason for hiding this comment

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

Good new documentation, thanks.

@yamaguchi1024 yamaguchi1024 enabled auto-merge (squash) November 5, 2024 19:02
@yamaguchi1024 yamaguchi1024 merged commit 5fb813f into main Nov 5, 2024
9 checks passed
@yamaguchi1024 yamaguchi1024 deleted the docs branch November 5, 2024 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants