gcn_agg/
lib.rs

1//! the crate gcn_agg is a graph convolutional neural network accelerator simulator.
2//! there are 4 parts in the crate:
3//!
4//! - accelerator: the accelerator is a graph convolutional neural network accelerator.
5//! - graph: the data structure to represent the graph.
6//! - node_features: the data structure to represent the node features.
7//! - statics: the result statics to record the result.
8//! # Examples
9//! ```
10//!     use chrono::Local;
11//!     use gcn_agg::{
12//!     accelerator::System, gcn_result::GcnAggResult, graph::Graph, node_features::NodeFeatures,
13//!     settings::Settings,
14//!     };
15//!     use itertools::Itertools;
16//!
17//!     fn test_system() -> Result<(), Box<dyn std::error::Error>> {
18//!         std::fs::create_dir_all("output")?;
19//!
20//!         simple_logger::init_with_level(log::Level::Info).unwrap_or(());
21//!         let current_time: String = Local::now().format("%Y-%m-%d-%H-%M-%S%.6f").to_string();
22//!
23//!         let start_time = std::time::Instant::now();
24//!         let mut results = GcnAggResult::default();
25//!
26//!         let settings = Settings::new(vec!["configs/default.toml".into()]).unwrap();
27//!         results.settings = Some(settings.clone());
28//!         // create the folder for output
29//!         std::fs::create_dir_all("output")?;
30//!
31//!         let graph_name = &settings.graph_path;
32//!         let features_name = &settings.features_paths;
33//!
34//!         let graph = Graph::new(graph_name.as_str())?;
35//!
36//!         let node_features: Vec<_> = features_name
37//!             .iter()
38//!             .map(|x| NodeFeatures::new(x.as_str()))
39//!             .try_collect()?;
40//!
41//!         let mem_stat_path = format!("output/{}_mem_stat.txt", current_time);
42//!         let mut system = System::new(
43//!             &graph,
44//!             &node_features,
45//!             settings.accelerator_settings,
46//!             &mem_stat_path,
47//!         );
48//!
49//!         // run the system
50//!         let mut stat = system.run()?;
51//!
52//!         // record the simulation time
53//!         let simulation_time = start_time.elapsed().as_secs();
54//!         // record the result
55//!         let seconds = simulation_time % 60;
56//!         let minutes = (simulation_time / 60) % 60;
57//!         let hours = (simulation_time / 60) / 60;
58//!         let time_str = format!("{}:{}:{}", hours, minutes, seconds);
59//!         stat.simulation_time = time_str;
60//!
61//!         results.stats = Some(stat);
62//!         let output_path = format!("output/{}.json", current_time);
63//!
64//!         println!("{}", serde_json::to_string_pretty(&results)?);
65//!         // write json of results to output_path
66//!         std::fs::write(output_path, serde_json::to_string_pretty(&results)?)?;
67//!         Ok(())
68//!     }
69//!     match test_system() {
70//!         Ok(_) => println!("test_system success"),
71//!         Err(e) => println!("test_system failed: {}", e),
72//!    }
73//!```  
74//!
75
76pub mod accelerator;
77pub mod cmd_args;
78pub mod gcn_result;
79pub mod graph;
80pub mod node_features;
81pub mod settings;
82// default re-export
83pub use accelerator::System;
84pub use gcn_result::{GcnAggResult, GcnStatistics};
85pub use graph::Graph;
86pub use node_features::NodeFeatures;
87pub use settings::Settings;