From 76cf14c520091d00985f845203580e14c611ed14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Thu, 27 Aug 2020 11:21:56 +0000 Subject: Brutally yank out multicore --- macros/src/codegen/post_init.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'macros/src/codegen/post_init.rs') diff --git a/macros/src/codegen/post_init.rs b/macros/src/codegen/post_init.rs index 0c740e8..098d1cc 100644 --- a/macros/src/codegen/post_init.rs +++ b/macros/src/codegen/post_init.rs @@ -2,21 +2,24 @@ use proc_macro2::TokenStream as TokenStream2; use quote::quote; use rtic_syntax::ast::App; -use crate::{analyze::Analysis, check::Extra, codegen::util}; +use crate::analyze::Analysis; /// Generates code that runs after `#[init]` returns pub fn codegen( - core: u8, app: &App, analysis: &Analysis, - extra: &Extra, ) -> (Vec, Vec) { - let mut const_app = vec![]; + //#TODO remove + let const_app = vec![]; let mut stmts = vec![]; // initialize late resources - if let Some(late_resources) = analysis.late_resources.get(&core) { - for name in late_resources { + //if let Some(late_resources) = analysis.late_resources { + //for name in late_resources { + if analysis.late_resources.len() > 0 { + // #TODO, check soundness of this, why the wrapping + // BTreeSet wrapped in a vector + for name in &analysis.late_resources[0] { // if it's live let cfgs = app.late_resources[name].cfgs.clone(); if analysis.locations.get(name).is_some() { @@ -29,7 +32,9 @@ pub fn codegen( } } + /* if analysis.timer_queues.is_empty() { + /* // cross-initialization barriers -- notify *other* cores that their resources have been // initialized for (user, initializers) in &analysis.initialization_barriers { @@ -55,7 +60,9 @@ pub fn codegen( #ib.release(); )); } + */ + /* // then wait until the other cores have initialized *our* resources if analysis.initialization_barriers.contains_key(&core) { let ib = util::init_barrier(core); @@ -75,6 +82,7 @@ pub fn codegen( )); } } + */ } else { // if the `schedule` API is used then we'll synchronize all cores to leave the // `init`-ialization phase at the same time. In this case the rendezvous barrier makes the @@ -154,6 +162,7 @@ pub fn codegen( } } } + */ // enable the interrupts -- this completes the `init`-ialization phase stmts.push(quote!(rtic::export::interrupt::enable();)); -- cgit v1.2.3 From f151d5871c559012173356259030c1dd36a442cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Tue, 1 Sep 2020 14:39:05 +0000 Subject: Cargo fmt --- macros/src/codegen/post_init.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'macros/src/codegen/post_init.rs') diff --git a/macros/src/codegen/post_init.rs b/macros/src/codegen/post_init.rs index 098d1cc..93d5704 100644 --- a/macros/src/codegen/post_init.rs +++ b/macros/src/codegen/post_init.rs @@ -5,17 +5,14 @@ use rtic_syntax::ast::App; use crate::analyze::Analysis; /// Generates code that runs after `#[init]` returns -pub fn codegen( - app: &App, - analysis: &Analysis, -) -> (Vec, Vec) { +pub fn codegen(app: &App, analysis: &Analysis) -> (Vec, Vec) { //#TODO remove let const_app = vec![]; let mut stmts = vec![]; // initialize late resources //if let Some(late_resources) = analysis.late_resources { - //for name in late_resources { + //for name in late_resources { if analysis.late_resources.len() > 0 { // #TODO, check soundness of this, why the wrapping // BTreeSet wrapped in a vector -- cgit v1.2.3 From d06cf91acc1126e66002f8884b1e7b7a65a9b24a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Tue, 1 Sep 2020 17:04:55 +0000 Subject: Remove stale code, fix comment styling --- macros/src/codegen/post_init.rs | 149 ++-------------------------------------- 1 file changed, 6 insertions(+), 143 deletions(-) (limited to 'macros/src/codegen/post_init.rs') diff --git a/macros/src/codegen/post_init.rs b/macros/src/codegen/post_init.rs index 93d5704..c35c697 100644 --- a/macros/src/codegen/post_init.rs +++ b/macros/src/codegen/post_init.rs @@ -5,19 +5,14 @@ use rtic_syntax::ast::App; use crate::analyze::Analysis; /// Generates code that runs after `#[init]` returns -pub fn codegen(app: &App, analysis: &Analysis) -> (Vec, Vec) { - //#TODO remove - let const_app = vec![]; +pub fn codegen(app: &App, analysis: &Analysis) -> Vec { let mut stmts = vec![]; - // initialize late resources - //if let Some(late_resources) = analysis.late_resources { - //for name in late_resources { + // Initialize late resources if analysis.late_resources.len() > 0 { - // #TODO, check soundness of this, why the wrapping // BTreeSet wrapped in a vector - for name in &analysis.late_resources[0] { - // if it's live + for name in analysis.late_resources.first().unwrap() { + // If it's live let cfgs = app.late_resources[name].cfgs.clone(); if analysis.locations.get(name).is_some() { // Need to also include the cfgs @@ -29,140 +24,8 @@ pub fn codegen(app: &App, analysis: &Analysis) -> (Vec, Vec::reset(); - )); - } else { - // in the multi-core case we need a rendezvous (RV) barrier between *all* the cores that - // use the `schedule` API; otherwise one of the cores could observe the before-reset - // value of the monotonic counter - // (this may be easier to implement with `AtomicU8.fetch_sub` but that API is not - // available on ARMv6-M) - - // this core will reset the monotonic counter - const FIRST: u8 = 0; - - if core == FIRST { - for &i in analysis.timer_queues.keys() { - let rv = util::rendezvous_ident(i); - let shared = if cfg!(feature = "heterogeneous") { - Some(quote!( - #[rtic::export::shared] - )) - } else { - None - }; - - const_app.push(quote!( - #shared - static #rv: rtic::export::Barrier = rtic::export::Barrier::new(); - )); - - // wait until all the other cores have reached the RV point - if i != FIRST { - stmts.push(quote!( - #rv.wait(); - )); - } - } - - let rv = util::rendezvous_ident(core); - stmts.push(quote!( - // the compiler fences are used to prevent `reset` from being re-ordering wrt to - // the atomic operations -- we don't know if `reset` contains load or store - // operations - - core::sync::atomic::compiler_fence(core::sync::atomic::Ordering::SeqCst); - - // reset the counter - <#m as rtic::Monotonic>::reset(); - - core::sync::atomic::compiler_fence(core::sync::atomic::Ordering::SeqCst); - - // now unblock all the other cores - #rv.release(); - )); - } else { - let rv = util::rendezvous_ident(core); - - // let the first core know that we have reached the RV point - stmts.push(quote!( - #rv.release(); - )); - - let rv = util::rendezvous_ident(FIRST); - - // wait until the first core has reset the monotonic timer - stmts.push(quote!( - #rv.wait(); - )); - } - } - } - */ - - // enable the interrupts -- this completes the `init`-ialization phase + // Enable the interrupts -- this completes the `init`-ialization phase stmts.push(quote!(rtic::export::interrupt::enable();)); - (const_app, stmts) + stmts } -- cgit v1.2.3