src/main.rs

changeset 3
c3a4f4bb87f7
parent 1
a4137aedcb3a
equal deleted inserted replaced
1:a4137aedcb3a 3:c3a4f4bb87f7
1 /*! 1 // The main documentation is in README.md
2 TODO: include README here. 2 #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))]
3 */
4
5 #![feature(maybe_uninit_array_assume_init)] 3 #![feature(maybe_uninit_array_assume_init)]
6 #![feature(iterator_try_collect)] 4 #![feature(iterator_try_collect)]
7 #![feature(once_cell_try)] 5 #![feature(once_cell_try)]
8 // We use unicode. We would like to use much more of it than Rust allows. 6 // We use unicode. We would like to use much more of it than Rust allows.
9 // Live with it. Embrace it. 7 // Live with it. Embrace it.
25 mod python_access; 23 mod python_access;
26 24
27 use experiments::Experiments; 25 use experiments::Experiments;
28 use python_access::pymod_pointsource_pde; 26 use python_access::pymod_pointsource_pde;
29 27
28 /// Helper for construct the list Python modules that we include as strings from `.py` files.
30 macro_rules! pymods { 29 macro_rules! pymods {
31 [$($modname:expr),*] => {&[$( 30 [$($modname:expr),*] => {&[$(
32 (c_str!(concat!("pointsource_pde.", $modname)), 31 (c_str!(concat!("pointsource_pde.", $modname)),
33 c_str!(concat!("src/", $modname, ".py")), 32 c_str!(concat!("src/", $modname, ".py")),
34 c_str!(include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/", $modname, ".py")))), 33 c_str!(include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/", $modname, ".py")))),
35 )*]}; 34 )*]};
36 } 35 }
37 36
37 /// List of Python modules that we include as strings from `.py` files.
38 const PY_MODULES: &[(&CStr, &CStr, &CStr)] = pymods![ 38 const PY_MODULES: &[(&CStr, &CStr, &CStr)] = pymods![
39 "dolfinx_extras", 39 "dolfinx_extras",
40 "compose", 40 "compose",
41 "measure", 41 "measure",
42 "quadratic_dataterm", 42 "quadratic_dataterm",
45 "full_sampling" 45 "full_sampling"
46 ]; 46 ];
47 47
48 /// The entry point for the program. 48 /// The entry point for the program.
49 pub fn main() -> DynResult<()> { 49 pub fn main() -> DynResult<()> {
50 unsafe {
51 // "#(/€"#€/("#€(/ OpenMPI and Fenics junk, don't do your obsolete “single-program multiple-data, with no controller at all” threading.
52 std::env::set_var("OMP_NUM_THREADS", "1");
53 }
54
50 // Initialise logging 55 // Initialise logging
51 colog::init(); 56 colog::init();
52 57
53 debug!("Appending Rust-side Python modules to inittab"); 58 debug!("Appending Rust-side Python modules to inittab");
54 59
72 c_str!( 77 c_str!(
73 r#" 78 r#"
74 import mpi4py 79 import mpi4py
75 80
76 mpi4py.rc.initialize = False # do not initialize MPI automatically 81 mpi4py.rc.initialize = False # do not initialize MPI automatically
77 mpi4py.rc.thread_level = "multiple" 82 mpi4py.rc.thread_level = "serialized"
78 mpi4py.rc.threads = True 83 mpi4py.rc.threads = False
79 84
80 from mpi4py import MPI 85 from mpi4py import MPI
81 86
82 MPI.Init() 87 MPI.Init()
83 size = MPI.COMM_SELF.Get_size() 88 size = MPI.COMM_SELF.Get_size()

mercurial