From eb20fd06108ce8b9819293bdfae923183a4a3401 Mon Sep 17 00:00:00 2001 From: Ryan Ziegler <rzig408@gmail.com> Date: Wed, 30 Apr 2025 12:51:25 -0400 Subject: [PATCH] num_cpus in more places --- Cargo.lock | 3 --- juno_samples/matmul/src/matmul.sch | 2 +- juno_scheduler/src/lang.l | 2 ++ juno_scheduler/src/lang.y | 4 ++++ juno_scheduler/src/lib.rs | 3 +++ juno_scheduler/src/pm.rs | 9 +++++++++ 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2469033d..5cdc2848 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1378,11 +1378,8 @@ name = "juno_matmul" version = "0.1.0" dependencies = [ "async-std", - "dlopen", - "dlopen_derive", "hercules_rt", "juno_build", - "juno_scheduler", "rand 0.9.0", "with_builtin_macros", ] diff --git a/juno_samples/matmul/src/matmul.sch b/juno_samples/matmul/src/matmul.sch index e6fe7bc8..5c6ec43e 100644 --- a/juno_samples/matmul/src/matmul.sch +++ b/juno_samples/matmul/src/matmul.sch @@ -70,7 +70,7 @@ if feature("cuda") { // Parallelize by computing output array as 16 chunks let par = matmul@outer \ matmul@inner; - fork-chunk; + fork-chunk; let (outer, inner, _) = fork-reshape[[0, 2], [1], [3]](par); parallelize!(outer \ inner); diff --git a/juno_scheduler/src/lang.l b/juno_scheduler/src/lang.l index 726264a3..ddaaee4e 100644 --- a/juno_scheduler/src/lang.l +++ b/juno_scheduler/src/lang.l @@ -50,6 +50,8 @@ false "false" \|\| "||" && "&&" +/ "/" + panic[\t \n\r]+after "panic_after" print[\t \n\r]+iter "print_iter" stop[\t \n\r]+after "stop_after" diff --git a/juno_scheduler/src/lang.y b/juno_scheduler/src/lang.y index 4500f42f..c9426acb 100644 --- a/juno_scheduler/src/lang.y +++ b/juno_scheduler/src/lang.y @@ -10,6 +10,7 @@ %left '&&' %right '!' %left '.' '@' +%left '/' %% @@ -98,6 +99,8 @@ Expr -> Expr { Expr::BinaryOp { span: $span, op: BinaryOp::Or, lhs: Box::new($1), rhs: Box::new($3) } } | Expr '&&' Expr { Expr::BinaryOp { span: $span, op: BinaryOp::And, lhs: Box::new($1), rhs: Box::new($3) } } + | Expr '/' Expr + { Expr::BinaryOp { span: $span, op: BinaryOp::Div, lhs: Box::new($1), rhs: Box::new($3) } } ; Args -> Vec<Expr> @@ -208,6 +211,7 @@ pub enum BinaryOp { Intersection, Or, And, + Div, } pub enum Expr { diff --git a/juno_scheduler/src/lib.rs b/juno_scheduler/src/lib.rs index 2a634664..7dbe2ca4 100644 --- a/juno_scheduler/src/lib.rs +++ b/juno_scheduler/src/lib.rs @@ -107,6 +107,9 @@ pub fn schedule_juno( let func_name = strings.lookup_string(func_name); env.insert(func_name, Value::JunoFunction { func: func_id }); } + let num_cpus_id = strings.lookup_string("num_cpus".to_owned()); + // Hardcoding hack + env.insert(num_cpus_id, Value::Integer { val: 16 }); let mut s = InterpretState { stringtab: strings, env, diff --git a/juno_scheduler/src/pm.rs b/juno_scheduler/src/pm.rs index 867a387c..15d5948c 100644 --- a/juno_scheduler/src/pm.rs +++ b/juno_scheduler/src/pm.rs @@ -1639,6 +1639,15 @@ fn interp_expr( lhs_mod || rhs_mod, )) } + parser::BinaryOp::Div => { + let (Value::Integer { val: lhs_i }, Value::Integer { val: rhs_i }) = (lhs, rhs) + else { + return Err(SchedulerError::SemanticError( + "Cannot divide nonintegers".to_owned(), + )); + }; + Ok((Value::Integer { val: lhs_i / rhs_i }, lhs_mod || rhs_mod)) + } } } ScheduleExp::Field { collect, field } => { -- GitLab