Skip to content
Snippets Groups Projects
Commit f0b4d682 authored by Russel Arbore's avatar Russel Arbore
Browse files

Generate rust structs for transitive closure of visible types

parent 3dcb381d
No related branches found
No related tags found
1 merge request!49Juno build system, labels, and skeleton scheduler
This commit is part of merge request !49. Comments created here will be created in the context of that merge request.
......@@ -2,6 +2,7 @@ extern crate serde;
extern crate hercules_ir;
use std::collections::BTreeSet;
use std::iter::once;
use self::serde::Deserialize;
......@@ -113,6 +114,24 @@ impl Manifest {
SType::Product(partition.returns.iter().map(|(ty, _)| ty.clone()).collect())
}))
}
pub fn transitive_closure_type_set(type_set: BTreeSet<SType>) -> BTreeSet<SType> {
let mut closure = BTreeSet::new();
let mut workset: BTreeSet<&SType> = type_set.iter().collect();
while let Some(ty) = workset.pop_last() {
match ty {
SType::Product(fields) => workset.extend(fields),
SType::ArrayRef(elem) => {
workset.insert(elem);
}
_ => {}
}
closure.insert(ty.clone());
}
closure
}
}
impl PartitionManifest {
......
......@@ -175,7 +175,7 @@ pub fn sched_make_schedule(schedule: &Schedule) -> SSchedule {
* value product types, since the layout of these types may be platform
* dependent.
*/
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SType {
Boolean,
Integer8,
......
......@@ -7,7 +7,7 @@ extern crate hercules_opt;
extern crate postcard;
extern crate proc_macro;
use std::collections::{HashMap, HashSet};
use std::collections::{BTreeSet, HashMap};
use std::ffi::OsStr;
use std::fmt::Write;
use std::fs::File;
......@@ -136,11 +136,12 @@ fn codegen(
// Emit the product types used in this module. We can't just emit product
// types, since we need #[repr(C)] to interact with LLVM.
let all_stypes = manifests
let visible_stypes = manifests
.into_iter()
.map(|(_, manifest)| manifest.all_visible_types())
.flatten()
.collect::<HashSet<SType>>();
.collect::<BTreeSet<SType>>();
let all_stypes = Manifest::transitive_closure_type_set(visible_stypes);
for stype in all_stypes.iter() {
if let Some(fields) = stype.try_product() {
write!(
......@@ -230,8 +231,8 @@ fn codegen(
// are declared as MaybeUninit, since they get assigned after running a
// partition. MaybeUninits should always be defined before assume_init()
// is called on them, assuming a valid partitioning.
let mut data_inputs = HashSet::new();
let mut data_outputs = HashSet::new();
let mut data_inputs = BTreeSet::new();
let mut data_outputs = BTreeSet::new();
for partition in manifest.partitions.iter() {
data_inputs.extend(partition.data_inputs());
data_outputs.extend(partition.data_outputs());
......
......@@ -4,9 +4,6 @@ extern crate async_std;
extern crate juno_build;
extern crate hercules_rt;
#[derive(Clone, Copy, Debug)]
struct __Prod_();
juno_build::juno!("simple3");
fn main() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment