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

Comments: Fix add1Tree cursorize example #252

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions gibbon-compiler/src/Gibbon/Passes/Cursorize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,30 @@ packed context, we return dilated values.

E.g.

add1 :: Tree -> Tree
add1 tr =
add1Tree :: Tree -> Tree
add1Tree tr =
case tr of
Leaf n -> Leaf (n + 1)
Node l r -> Node (add1 l) (add1 r)
Node l r -> Node (add1Tree l) (add1Tree r)

becomes

-- char*
type Cursor = Ptr Char

add1 :: Cursor -> Cursor -> (Cursor, (Cursor, Cursor))
add1 lout lin =
let tag = readTag lin
in case tag of
Leaf -> let n = readInt tag
add1Tree :: Cursor -> Cursor -> Cursor -> Cursor -> (Cursor,Cursor,Cursor,(Cursor,Cursor))
add1Tree end_rin end_rout lout lin =
in case lin of
Leaf -> let n = readScalar "Int" (lin + 1)
wt = writeTag lout Leaf
wi = writeInt wt (n+1)
in (lin + 8, (lout, wi))
wi = writeInt wt (n+1)
in (end_rin, end_rout, lin + 9, (lout, wi))
Node -> ...

Every packed input becomes a read cursor. And it takes additional output cursors
for every packed type in the return value. Every packed return value becomes a
(Cursor,Cursor) i.e (start,end). And it returns additional end_of_read cursors
if the functions "traverses" it's input (more details in the paer).
if the functions "traverses" it's input (more details in the paper).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if the functions "traverses" it's input (more details in the paper).
if the functions "traverses" its input (more details in the paper).


-}

Expand Down
Loading