Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Hercules-Torch
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
prathi3
Hercules-Torch
Commits
4feea45d
Commit
4feea45d
authored
1 year ago
by
Aaron Councilman
Browse files
Options
Downloads
Patches
Plain Diff
New scheduler syntax
parent
1c8a4869
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
juno_scheduler/src/lang.l
+8
-2
8 additions, 2 deletions
juno_scheduler/src/lang.l
juno_scheduler/src/lang.y
+72
-31
72 additions, 31 deletions
juno_scheduler/src/lang.y
with
80 additions
and
33 deletions
juno_scheduler/src/lang.l
+
8
−
2
View file @
4feea45d
...
@@ -42,8 +42,11 @@ false "false"
...
@@ -42,8 +42,11 @@ false "false"
/ "/"
/ "/"
% "%"
% "%"
\|\| "||"
&& "&&"
\| "|"
:: "::"
:: "::"
\. "."
, ","
, ","
_ "_"
_ "_"
...
@@ -51,7 +54,10 @@ _ "_"
...
@@ -51,7 +54,10 @@ _ "_"
\) ")"
\) ")"
\{ "{"
\{ "{"
\} "}"
\} "}"
\| "|"
if "if"
on "on"
partition "partition"
[a-zA-Z][a-zA-Z0-9_]* "ID"
[a-zA-Z][a-zA-Z0-9_]* "ID"
[0-9]+ "INT"
[0-9]+ "INT"
...
...
This diff is collapsed.
Click to expand it.
juno_scheduler/src/lang.y
+
72
−
31
View file @
4feea45d
...
@@ -3,57 +3,84 @@
...
@@ -3,57 +3,84 @@
%avoid_insert "ID" "INT" "HEX_INT" "BIN_INT" "OCT_INT" "LABEL"
%avoid_insert "ID" "INT" "HEX_INT" "BIN_INT" "OCT_INT" "LABEL"
%expect-unused Unmatched 'UNMATCHED'
%expect-unused Unmatched 'UNMATCHED'
%left '||'
%left '&&'
%nonassoc '==' '!=' '<' '<=' '>' '>='
%nonassoc '==' '!=' '<' '<=' '>' '>='
%left '+' '-'
%left '+' '-'
%left '*' '/' '%'
%left '*' '/' '%'
%%
%%
Schedule -> Vec<
Inst> : Inst
List {
rev(
$1
)
};
Schedule -> Vec<
Partition> : Partition
List { $1 };
Inst
List -> Vec<
Inst
>
Partition
List -> Vec<
Partition
>
: { vec![] }
: { vec![] }
|
Instruction Schedule { cons
($1, $2) }
|
PartitionList Partition { snoc
($1, $2) }
;
;
Instruction -> Inst : Base '.' Commands { Inst { span : $span, base : $1, commands : $3 }};
Partition -> Partition
: 'partition' Func '{' Labels '}' Directives
{ Partition { span : $span, func : $2, labels : $4, directs : $6 } };
Commands -> Vec<Command>
Func -> Func
:
Command { vec![$1]
}
:
'ID' { Func { span : $span, name : $span, args : None }
}
| '
{' CommandList
'
}
' {
rev
($
2
) }
| '
ID' '::' '<' TypeExprs
'
>
' {
Func { span : $span, name : span_of_tok($1), args : Some
($
4
) }
}
;
;
CommandList -> Vec<Command>
Labels -> Vec<Span> : LabelsRev { rev($1) };
LabelsRev -> Vec<Span>
: { vec![] }
: { vec![] }
|
Command
{ vec![$1] }
|
'LABEL'
{ vec![
span_of_tok(
$1
)
] }
|
Command ',' CommandList { cons
($1, $3) }
|
'LABEL' ',' LabelsRev { cons(span_of_tok
($1
)
, $3) }
;
;
Command -> Command
Directives -> Vec<Directive>
:
'ID' { Command { span : $span, name : $span, args :
vec![] }
}
:
{
vec![] }
|
'ID' '(' Values ')' { Command { span : $span, nam
e
:
s
pan_of_tok
($1
)
,
args : rev($3
) }
}
|
Directives Directiv
e
{
s
noc
($1,
$2
) }
;
;
Base -> Base
Directive -> Directive
: Func { Base::Function { span : $span, func : $1 }}
: 'on' Device '{' Directives '}'
| Func 'LABEL' { Base::Label { span : $span, func : $1, label : span_of_tok($2) }}
{ Directive::OnDevice { span : $span, device : $2, directs : $4 } }
| 'if' Expr '{' Directives '}'
{ Directive::IfExpr { span : $span, cond : $2, directs : $4 } }
| 'LABEL' '{' Commands '}'
{ Directive::Command { span : $span, label : span_of_tok($1), commands : $3 } }
;
;
Func -> Func
Device -> Device
: 'ID' { Func { span : $span, name : $span, args : None }}
: 'ID'
| 'ID' '::' '<' TypeVals '>' { Func { span : $span, name : span_of_tok($1), args : Some(rev($4)) }}
{ Device { span : $span, name : span_of_tok($1), args : vec![] } }
| 'ID' '(' Exprs ')'
{ Device { span : $span, name : span_of_tok($1), args : $3 } }
;
;
Values -> Vec<Expr>
Commands -> Vec<Command> : CommandsRev { rev($1) };
CommandsRev -> Vec<Command>
: { vec![] }
| Command { vec![$1] }
| Command ',' CommandsRev { cons($1, $3) }
;
Command -> Command
: 'ID'
{ Command { span : $span, name : span_of_tok($1), args : vec![] } }
| 'ID' '(' Exprs ')'
{ Command { span : $span, name : span_of_tok($1), args : $3 } }
;
Exprs -> Vec<Expr> : ExprsRev { rev($1) };
ExprsRev -> Vec<Expr>
: { vec![] }
: { vec![] }
| Expr { vec![$1] }
| Expr { vec![$1] }
| Expr ','
Values
{ cons($1, $3) }
| Expr ','
ExprsRev
{ cons($1, $3) }
;
;
TypeVals -> Vec<TypExp>
TypeExprs -> Vec<TypExp> : TypeExprsRev { rev($1) };
TypeExprsRev -> Vec<TypExp>
: { vec![] }
: { vec![] }
| TypeExp { vec![$1] }
| TypeExp { vec![$1] }
| TypeExp ',' Type
Vals
{ cons($1, $3) }
| TypeExp ',' Type
ExprsRev
{ cons($1, $3) }
;
;
Expr -> Expr
Expr -> Expr
...
@@ -75,6 +102,8 @@ Expr -> Expr
...
@@ -75,6 +102,8 @@ Expr -> Expr
| Expr '<=' Expr { Expr::BinOp { span : $span, lhs : Box::new($1), op : BinOp::Le, rhs : Box::new($3) }}
| Expr '<=' Expr { Expr::BinOp { span : $span, lhs : Box::new($1), op : BinOp::Le, rhs : Box::new($3) }}
| Expr '>' Expr { Expr::BinOp { span : $span, lhs : Box::new($1), op : BinOp::Gt, rhs : Box::new($3) }}
| Expr '>' Expr { Expr::BinOp { span : $span, lhs : Box::new($1), op : BinOp::Gt, rhs : Box::new($3) }}
| Expr '>=' Expr { Expr::BinOp { span : $span, lhs : Box::new($1), op : BinOp::Ge, rhs : Box::new($3) }}
| Expr '>=' Expr { Expr::BinOp { span : $span, lhs : Box::new($1), op : BinOp::Ge, rhs : Box::new($3) }}
| Expr '&&' Expr { Expr::BinOp { span : $span, lhs : Box::new($1), op : BinOp::And, rhs : Box::new($3) }}
| Expr '||' Expr { Expr::BinOp { span : $span, lhs : Box::new($1), op : BinOp::Or, rhs : Box::new($3) }}
;
;
TypeExp -> TypExp
TypeExp -> TypExp
...
@@ -93,7 +122,7 @@ TypeExp -> TypExp
...
@@ -93,7 +122,7 @@ TypeExp -> TypExp
| 'f32' { TypExp::Primitive { span : $span, typ : Primitive::F32 }}
| 'f32' { TypExp::Primitive { span : $span, typ : Primitive::F32 }}
| 'f64' { TypExp::Primitive { span : $span, typ : Primitive::F64 }}
| 'f64' { TypExp::Primitive { span : $span, typ : Primitive::F64 }}
| 'void' { TypExp::Primitive { span : $span, typ : Primitive::Void }}
| 'void' { TypExp::Primitive { span : $span, typ : Primitive::Void }}
| '(' Type
Val
s ')'
{ TypExp::Tuple { span : $span, elems :
rev(
$2
)
}}
| '(' Type
Expr
s ')' { TypExp::Tuple { span : $span, elems : $2 }}
| '{' 'ID' '|' Expr '}' { TypExp::Set { span : $span, nm : span_of_tok($2), cond : $4 }}
| '{' 'ID' '|' Expr '}' { TypExp::Set { span : $span, nm : span_of_tok($2), cond : $4 }}
;
;
...
@@ -113,19 +142,26 @@ fn cons<A>(hd : A, mut tl : Vec<A>) -> Vec<A> {
...
@@ -113,19 +142,26 @@ fn cons<A>(hd : A, mut tl : Vec<A>) -> Vec<A> {
tl
tl
}
}
fn snoc<A>(mut hd : Vec<A>, tl : A) -> Vec<A> {
hd.push(tl);
hd
}
fn rev<A>(mut lst : Vec<A>) -> Vec<A> {
fn rev<A>(mut lst : Vec<A>) -> Vec<A> {
lst.reverse();
lst.reverse();
lst
lst
}
}
pub struct Inst { pub span : Span, pub base : Base, pub commands : Vec<Command>, }
pub struct Partition {
pub struct Command { pub span : Span, pub name : Span, pub args : Vec<Expr>, }
pub span : Span,
pub func : Func,
pub labels : Vec<Span>,
pub directs : Vec<Directive>,
}
pub struct Func { pub span : Span, pub name : Span, pub args : Option<Vec<TypExp>>, }
pub struct Func { pub span : Span, pub name : Span, pub args : Option<Vec<TypExp>>, }
pub struct Device { pub span : Span, pub name : Span, pub args : Vec<Expr>, }
pub struct Command { pub span : Span, pub name : Span, pub args : Vec<Expr>, }
pub enum Base {
Function { span : Span, func : Func },
Label { span : Span, func : Func, label : Span },
}
pub enum Expr {
pub enum Expr {
Id { span : Span },
Id { span : Span },
Int { span : Span, base : IntBase },
Int { span : Span, base : IntBase },
...
@@ -139,7 +175,12 @@ pub enum TypExp {
...
@@ -139,7 +175,12 @@ pub enum TypExp {
Tuple { span : Span, elems : Vec<TypExp> },
Tuple { span : Span, elems : Vec<TypExp> },
Set { span : Span, nm : Span, cond : Expr },
Set { span : Span, nm : Span, cond : Expr },
}
}
pub enum Directive {
OnDevice { span : Span, device : Device, directs : Vec<Directive> },
IfExpr { span : Span, cond : Expr, directs : Vec<Directive> },
Command { span : Span, label : Span, commands : Vec<Command> },
}
pub enum IntBase { Bin, Oct, Dec, Hex }
pub enum IntBase { Bin, Oct, Dec, Hex }
pub enum BinOp { Add, Sub, Mul, Div, Mod, Eq, Ne, Lt, Le, Gt, Ge }
pub enum BinOp { Add, Sub, Mul, Div, Mod, Eq, Ne, Lt, Le, Gt, Ge
, And, Or
}
pub enum Primitive { Bool, I8, I16, I32, I64, U8, U16, U32, U64, USize, F32, F64, Void }
pub enum Primitive { Bool, I8, I16, I32, I64, U8, U16, U32, U64, USize, F32, F64, Void }
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment