Parabuilder

Struct Parabuilder 

Source
pub struct Parabuilder { /* private fields */ }
Expand description

The main body of building system

Implementations§

Source§

impl Parabuilder

Source

pub const TEMP_TARGET_PATH_DIR: &'static str = "targets"

Source

pub fn new<P, Q, R, S>( project_path: P, workspaces_path: Q, template_file: R, target_files: &[S], ) -> Self
where P: AsRef<Path>, Q: AsRef<Path>, R: AsRef<Path>, S: AsRef<Path>,

Examples found in repository?
examples/cuda_quick_start.rs (lines 13-18)
4fn main() {
5    let project_path = "tests/example_cuda_project"; // your project path
6    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
7    let template_path = "src/main.cu"; // template file in the project
8    let target_executable_file = "build/main"; // target executable file
9    let datas = (0..20)
10        .into_iter()
11        .map(|_| JsonValue::Null)
12        .collect::<Vec<JsonValue>>();
13    let mut parabuilder = Parabuilder::new(
14        project_path,
15        workspaces_path,
16        template_path,
17        &[target_executable_file],
18    )
19    .in_place_template(true)
20    .build_workers(2)
21    .run_method(RunMethod::OutOfPlace(2));
22    parabuilder.set_datas(datas).unwrap();
23    parabuilder.init_workspace().unwrap();
24    parabuilder.run().unwrap();
25}
More examples
Hide additional examples
examples/quick_start.rs (lines 10-15)
4fn main() {
5    let project_path = "tests/example_cmake_project"; // your project path
6    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
7    let template_path = "src/main.cpp.template"; // template file in the project
8    let target_executable_file = "build/main"; // target executable file
9    let datas = vec![json!({"N": "10"}), json!({"N": "20"})];
10    let mut parabuilder = Parabuilder::new(
11        project_path,
12        workspaces_path,
13        template_path,
14        &[target_executable_file],
15    );
16    parabuilder.set_datas(datas).unwrap();
17    parabuilder.init_workspace().unwrap();
18    let (run_data, _compile_error_datas, _processed_data_ids): (
19        JsonValue,
20        Vec<JsonValue>,
21        Vec<usize>,
22    ) = parabuilder.run().unwrap();
23    println!("{}", to_string_pretty(&run_data).unwrap());
24    /*
25    [
26        {
27            "data": {
28                "N": "10"
29            },
30            "status": 0,
31            "stderr": "",
32            "stdout": "10\n"
33        },
34        {
35            "data": {
36                "N": "20"
37            },
38            "status": 0,
39            "stderr": "",
40            "stdout": "20\n"
41        }
42    ]
43     */
44}
examples/complete_usage.rs (lines 18-23)
6fn main() {
7    let project_path = "tests/example_run_time_consuming_project"; // your project path
8    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
9    let template_path = "src/main.cpp.template"; // template file in the project
10    let target_executable_file = "build/main"; // target executable file
11    let mut datas = (1..=100)
12        .map(|i| json!({"N": i}))
13        .collect::<Vec<JsonValue>>();
14    let error_data = json!({"N": "a"});
15    datas.push(error_data.clone());
16    let init_bash_script = r#"cmake -B build -S . -DPARABUILD=ON"#;
17    let compile_bash_script = r#"cmake --build build --target all -- -B"#;
18    let mut parabuilder = Parabuilder::new(
19        project_path,
20        workspaces_path,
21        template_path,
22        &[target_executable_file],
23    )
24    .init_bash_script(init_bash_script)
25    .compile_bash_script(compile_bash_script)
26    // .run_bash_script(format!(r#"./{}"#, target_executable_file).as_str())
27    .build_workers(4)
28    .run_method(RunMethod::OutOfPlace(2)) // 4 threads compile, 1 thread run
29    // .run_method(RunMethod::Exclusive) // 4 threads compile, 1 thread run
30    .compilation_error_handling_method(CompliationErrorHandlingMethod::Collect) // collect data that has compilation error
31    .auto_gather_array_data(true) // when each run thread finishes, gather the data into one array when every thread returns an array
32    .run_func(IGNORE_ON_ERROR_DEFAULT_RUN_FUNC)
33    .in_place_template(false)
34    .disable_progress_bar(false);
35    // let sender = parabuilder.get_data_queue_sender().unwrap();
36    parabuilder.set_datas(datas).unwrap();
37    parabuilder.init_workspace().unwrap();
38    let (run_data, compile_error_datas, _processed_data_ids): (
39        JsonValue,
40        Vec<JsonValue>,
41        Vec<usize>,
42    ) = parabuilder.run().unwrap();
43    println!(
44        "run_data: {}",
45        serde_json::to_string_pretty(&run_data).unwrap()
46    );
47    println!("compile_error_datas: {:?}", compile_error_datas);
48}
Source

pub fn init_bash_script(self, init_bash_script: &str) -> Self

Examples found in repository?
examples/complete_usage.rs (line 24)
6fn main() {
7    let project_path = "tests/example_run_time_consuming_project"; // your project path
8    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
9    let template_path = "src/main.cpp.template"; // template file in the project
10    let target_executable_file = "build/main"; // target executable file
11    let mut datas = (1..=100)
12        .map(|i| json!({"N": i}))
13        .collect::<Vec<JsonValue>>();
14    let error_data = json!({"N": "a"});
15    datas.push(error_data.clone());
16    let init_bash_script = r#"cmake -B build -S . -DPARABUILD=ON"#;
17    let compile_bash_script = r#"cmake --build build --target all -- -B"#;
18    let mut parabuilder = Parabuilder::new(
19        project_path,
20        workspaces_path,
21        template_path,
22        &[target_executable_file],
23    )
24    .init_bash_script(init_bash_script)
25    .compile_bash_script(compile_bash_script)
26    // .run_bash_script(format!(r#"./{}"#, target_executable_file).as_str())
27    .build_workers(4)
28    .run_method(RunMethod::OutOfPlace(2)) // 4 threads compile, 1 thread run
29    // .run_method(RunMethod::Exclusive) // 4 threads compile, 1 thread run
30    .compilation_error_handling_method(CompliationErrorHandlingMethod::Collect) // collect data that has compilation error
31    .auto_gather_array_data(true) // when each run thread finishes, gather the data into one array when every thread returns an array
32    .run_func(IGNORE_ON_ERROR_DEFAULT_RUN_FUNC)
33    .in_place_template(false)
34    .disable_progress_bar(false);
35    // let sender = parabuilder.get_data_queue_sender().unwrap();
36    parabuilder.set_datas(datas).unwrap();
37    parabuilder.init_workspace().unwrap();
38    let (run_data, compile_error_datas, _processed_data_ids): (
39        JsonValue,
40        Vec<JsonValue>,
41        Vec<usize>,
42    ) = parabuilder.run().unwrap();
43    println!(
44        "run_data: {}",
45        serde_json::to_string_pretty(&run_data).unwrap()
46    );
47    println!("compile_error_datas: {:?}", compile_error_datas);
48}
Source

pub fn compile_bash_script(self, compile_bash_script: &str) -> Self

Examples found in repository?
examples/complete_usage.rs (line 25)
6fn main() {
7    let project_path = "tests/example_run_time_consuming_project"; // your project path
8    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
9    let template_path = "src/main.cpp.template"; // template file in the project
10    let target_executable_file = "build/main"; // target executable file
11    let mut datas = (1..=100)
12        .map(|i| json!({"N": i}))
13        .collect::<Vec<JsonValue>>();
14    let error_data = json!({"N": "a"});
15    datas.push(error_data.clone());
16    let init_bash_script = r#"cmake -B build -S . -DPARABUILD=ON"#;
17    let compile_bash_script = r#"cmake --build build --target all -- -B"#;
18    let mut parabuilder = Parabuilder::new(
19        project_path,
20        workspaces_path,
21        template_path,
22        &[target_executable_file],
23    )
24    .init_bash_script(init_bash_script)
25    .compile_bash_script(compile_bash_script)
26    // .run_bash_script(format!(r#"./{}"#, target_executable_file).as_str())
27    .build_workers(4)
28    .run_method(RunMethod::OutOfPlace(2)) // 4 threads compile, 1 thread run
29    // .run_method(RunMethod::Exclusive) // 4 threads compile, 1 thread run
30    .compilation_error_handling_method(CompliationErrorHandlingMethod::Collect) // collect data that has compilation error
31    .auto_gather_array_data(true) // when each run thread finishes, gather the data into one array when every thread returns an array
32    .run_func(IGNORE_ON_ERROR_DEFAULT_RUN_FUNC)
33    .in_place_template(false)
34    .disable_progress_bar(false);
35    // let sender = parabuilder.get_data_queue_sender().unwrap();
36    parabuilder.set_datas(datas).unwrap();
37    parabuilder.init_workspace().unwrap();
38    let (run_data, compile_error_datas, _processed_data_ids): (
39        JsonValue,
40        Vec<JsonValue>,
41        Vec<usize>,
42    ) = parabuilder.run().unwrap();
43    println!(
44        "run_data: {}",
45        serde_json::to_string_pretty(&run_data).unwrap()
46    );
47    println!("compile_error_datas: {:?}", compile_error_datas);
48}
Source

pub fn run_bash_script(self, run_bash_script: &str) -> Self

Source

pub fn build_workers(self, build_workers: usize) -> Self

Examples found in repository?
examples/cuda_quick_start.rs (line 20)
4fn main() {
5    let project_path = "tests/example_cuda_project"; // your project path
6    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
7    let template_path = "src/main.cu"; // template file in the project
8    let target_executable_file = "build/main"; // target executable file
9    let datas = (0..20)
10        .into_iter()
11        .map(|_| JsonValue::Null)
12        .collect::<Vec<JsonValue>>();
13    let mut parabuilder = Parabuilder::new(
14        project_path,
15        workspaces_path,
16        template_path,
17        &[target_executable_file],
18    )
19    .in_place_template(true)
20    .build_workers(2)
21    .run_method(RunMethod::OutOfPlace(2));
22    parabuilder.set_datas(datas).unwrap();
23    parabuilder.init_workspace().unwrap();
24    parabuilder.run().unwrap();
25}
More examples
Hide additional examples
examples/complete_usage.rs (line 27)
6fn main() {
7    let project_path = "tests/example_run_time_consuming_project"; // your project path
8    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
9    let template_path = "src/main.cpp.template"; // template file in the project
10    let target_executable_file = "build/main"; // target executable file
11    let mut datas = (1..=100)
12        .map(|i| json!({"N": i}))
13        .collect::<Vec<JsonValue>>();
14    let error_data = json!({"N": "a"});
15    datas.push(error_data.clone());
16    let init_bash_script = r#"cmake -B build -S . -DPARABUILD=ON"#;
17    let compile_bash_script = r#"cmake --build build --target all -- -B"#;
18    let mut parabuilder = Parabuilder::new(
19        project_path,
20        workspaces_path,
21        template_path,
22        &[target_executable_file],
23    )
24    .init_bash_script(init_bash_script)
25    .compile_bash_script(compile_bash_script)
26    // .run_bash_script(format!(r#"./{}"#, target_executable_file).as_str())
27    .build_workers(4)
28    .run_method(RunMethod::OutOfPlace(2)) // 4 threads compile, 1 thread run
29    // .run_method(RunMethod::Exclusive) // 4 threads compile, 1 thread run
30    .compilation_error_handling_method(CompliationErrorHandlingMethod::Collect) // collect data that has compilation error
31    .auto_gather_array_data(true) // when each run thread finishes, gather the data into one array when every thread returns an array
32    .run_func(IGNORE_ON_ERROR_DEFAULT_RUN_FUNC)
33    .in_place_template(false)
34    .disable_progress_bar(false);
35    // let sender = parabuilder.get_data_queue_sender().unwrap();
36    parabuilder.set_datas(datas).unwrap();
37    parabuilder.init_workspace().unwrap();
38    let (run_data, compile_error_datas, _processed_data_ids): (
39        JsonValue,
40        Vec<JsonValue>,
41        Vec<usize>,
42    ) = parabuilder.run().unwrap();
43    println!(
44        "run_data: {}",
45        serde_json::to_string_pretty(&run_data).unwrap()
46    );
47    println!("compile_error_datas: {:?}", compile_error_datas);
48}
Source

pub fn run_workers(self, run_workers: isize) -> Self

Source

pub fn run_workers_exclusive(self, run_workers: isize) -> Self

Source

pub fn run_method(self, run_method: RunMethod) -> Self

Examples found in repository?
examples/cuda_quick_start.rs (line 21)
4fn main() {
5    let project_path = "tests/example_cuda_project"; // your project path
6    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
7    let template_path = "src/main.cu"; // template file in the project
8    let target_executable_file = "build/main"; // target executable file
9    let datas = (0..20)
10        .into_iter()
11        .map(|_| JsonValue::Null)
12        .collect::<Vec<JsonValue>>();
13    let mut parabuilder = Parabuilder::new(
14        project_path,
15        workspaces_path,
16        template_path,
17        &[target_executable_file],
18    )
19    .in_place_template(true)
20    .build_workers(2)
21    .run_method(RunMethod::OutOfPlace(2));
22    parabuilder.set_datas(datas).unwrap();
23    parabuilder.init_workspace().unwrap();
24    parabuilder.run().unwrap();
25}
More examples
Hide additional examples
examples/complete_usage.rs (line 28)
6fn main() {
7    let project_path = "tests/example_run_time_consuming_project"; // your project path
8    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
9    let template_path = "src/main.cpp.template"; // template file in the project
10    let target_executable_file = "build/main"; // target executable file
11    let mut datas = (1..=100)
12        .map(|i| json!({"N": i}))
13        .collect::<Vec<JsonValue>>();
14    let error_data = json!({"N": "a"});
15    datas.push(error_data.clone());
16    let init_bash_script = r#"cmake -B build -S . -DPARABUILD=ON"#;
17    let compile_bash_script = r#"cmake --build build --target all -- -B"#;
18    let mut parabuilder = Parabuilder::new(
19        project_path,
20        workspaces_path,
21        template_path,
22        &[target_executable_file],
23    )
24    .init_bash_script(init_bash_script)
25    .compile_bash_script(compile_bash_script)
26    // .run_bash_script(format!(r#"./{}"#, target_executable_file).as_str())
27    .build_workers(4)
28    .run_method(RunMethod::OutOfPlace(2)) // 4 threads compile, 1 thread run
29    // .run_method(RunMethod::Exclusive) // 4 threads compile, 1 thread run
30    .compilation_error_handling_method(CompliationErrorHandlingMethod::Collect) // collect data that has compilation error
31    .auto_gather_array_data(true) // when each run thread finishes, gather the data into one array when every thread returns an array
32    .run_func(IGNORE_ON_ERROR_DEFAULT_RUN_FUNC)
33    .in_place_template(false)
34    .disable_progress_bar(false);
35    // let sender = parabuilder.get_data_queue_sender().unwrap();
36    parabuilder.set_datas(datas).unwrap();
37    parabuilder.init_workspace().unwrap();
38    let (run_data, compile_error_datas, _processed_data_ids): (
39        JsonValue,
40        Vec<JsonValue>,
41        Vec<usize>,
42    ) = parabuilder.run().unwrap();
43    println!(
44        "run_data: {}",
45        serde_json::to_string_pretty(&run_data).unwrap()
46    );
47    println!("compile_error_datas: {:?}", compile_error_datas);
48}
Source

pub fn run_func( self, run_func: fn(&PathBuf, &str, &Value, &mut Value, &Arc<AtomicBool>) -> Result<Value, Box<dyn Error>>, ) -> Self

Examples found in repository?
examples/complete_usage.rs (line 32)
6fn main() {
7    let project_path = "tests/example_run_time_consuming_project"; // your project path
8    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
9    let template_path = "src/main.cpp.template"; // template file in the project
10    let target_executable_file = "build/main"; // target executable file
11    let mut datas = (1..=100)
12        .map(|i| json!({"N": i}))
13        .collect::<Vec<JsonValue>>();
14    let error_data = json!({"N": "a"});
15    datas.push(error_data.clone());
16    let init_bash_script = r#"cmake -B build -S . -DPARABUILD=ON"#;
17    let compile_bash_script = r#"cmake --build build --target all -- -B"#;
18    let mut parabuilder = Parabuilder::new(
19        project_path,
20        workspaces_path,
21        template_path,
22        &[target_executable_file],
23    )
24    .init_bash_script(init_bash_script)
25    .compile_bash_script(compile_bash_script)
26    // .run_bash_script(format!(r#"./{}"#, target_executable_file).as_str())
27    .build_workers(4)
28    .run_method(RunMethod::OutOfPlace(2)) // 4 threads compile, 1 thread run
29    // .run_method(RunMethod::Exclusive) // 4 threads compile, 1 thread run
30    .compilation_error_handling_method(CompliationErrorHandlingMethod::Collect) // collect data that has compilation error
31    .auto_gather_array_data(true) // when each run thread finishes, gather the data into one array when every thread returns an array
32    .run_func(IGNORE_ON_ERROR_DEFAULT_RUN_FUNC)
33    .in_place_template(false)
34    .disable_progress_bar(false);
35    // let sender = parabuilder.get_data_queue_sender().unwrap();
36    parabuilder.set_datas(datas).unwrap();
37    parabuilder.init_workspace().unwrap();
38    let (run_data, compile_error_datas, _processed_data_ids): (
39        JsonValue,
40        Vec<JsonValue>,
41        Vec<usize>,
42    ) = parabuilder.run().unwrap();
43    println!(
44        "run_data: {}",
45        serde_json::to_string_pretty(&run_data).unwrap()
46    );
47    println!("compile_error_datas: {:?}", compile_error_datas);
48}
Source

pub fn compilation_error_handling_method( self, compilation_error_handling_method: CompliationErrorHandlingMethod, ) -> Self

Examples found in repository?
examples/complete_usage.rs (line 30)
6fn main() {
7    let project_path = "tests/example_run_time_consuming_project"; // your project path
8    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
9    let template_path = "src/main.cpp.template"; // template file in the project
10    let target_executable_file = "build/main"; // target executable file
11    let mut datas = (1..=100)
12        .map(|i| json!({"N": i}))
13        .collect::<Vec<JsonValue>>();
14    let error_data = json!({"N": "a"});
15    datas.push(error_data.clone());
16    let init_bash_script = r#"cmake -B build -S . -DPARABUILD=ON"#;
17    let compile_bash_script = r#"cmake --build build --target all -- -B"#;
18    let mut parabuilder = Parabuilder::new(
19        project_path,
20        workspaces_path,
21        template_path,
22        &[target_executable_file],
23    )
24    .init_bash_script(init_bash_script)
25    .compile_bash_script(compile_bash_script)
26    // .run_bash_script(format!(r#"./{}"#, target_executable_file).as_str())
27    .build_workers(4)
28    .run_method(RunMethod::OutOfPlace(2)) // 4 threads compile, 1 thread run
29    // .run_method(RunMethod::Exclusive) // 4 threads compile, 1 thread run
30    .compilation_error_handling_method(CompliationErrorHandlingMethod::Collect) // collect data that has compilation error
31    .auto_gather_array_data(true) // when each run thread finishes, gather the data into one array when every thread returns an array
32    .run_func(IGNORE_ON_ERROR_DEFAULT_RUN_FUNC)
33    .in_place_template(false)
34    .disable_progress_bar(false);
35    // let sender = parabuilder.get_data_queue_sender().unwrap();
36    parabuilder.set_datas(datas).unwrap();
37    parabuilder.init_workspace().unwrap();
38    let (run_data, compile_error_datas, _processed_data_ids): (
39        JsonValue,
40        Vec<JsonValue>,
41        Vec<usize>,
42    ) = parabuilder.run().unwrap();
43    println!(
44        "run_data: {}",
45        serde_json::to_string_pretty(&run_data).unwrap()
46    );
47    println!("compile_error_datas: {:?}", compile_error_datas);
48}
Source

pub fn auto_gather_array_data(self, auto_gather_array_data: bool) -> Self

Examples found in repository?
examples/complete_usage.rs (line 31)
6fn main() {
7    let project_path = "tests/example_run_time_consuming_project"; // your project path
8    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
9    let template_path = "src/main.cpp.template"; // template file in the project
10    let target_executable_file = "build/main"; // target executable file
11    let mut datas = (1..=100)
12        .map(|i| json!({"N": i}))
13        .collect::<Vec<JsonValue>>();
14    let error_data = json!({"N": "a"});
15    datas.push(error_data.clone());
16    let init_bash_script = r#"cmake -B build -S . -DPARABUILD=ON"#;
17    let compile_bash_script = r#"cmake --build build --target all -- -B"#;
18    let mut parabuilder = Parabuilder::new(
19        project_path,
20        workspaces_path,
21        template_path,
22        &[target_executable_file],
23    )
24    .init_bash_script(init_bash_script)
25    .compile_bash_script(compile_bash_script)
26    // .run_bash_script(format!(r#"./{}"#, target_executable_file).as_str())
27    .build_workers(4)
28    .run_method(RunMethod::OutOfPlace(2)) // 4 threads compile, 1 thread run
29    // .run_method(RunMethod::Exclusive) // 4 threads compile, 1 thread run
30    .compilation_error_handling_method(CompliationErrorHandlingMethod::Collect) // collect data that has compilation error
31    .auto_gather_array_data(true) // when each run thread finishes, gather the data into one array when every thread returns an array
32    .run_func(IGNORE_ON_ERROR_DEFAULT_RUN_FUNC)
33    .in_place_template(false)
34    .disable_progress_bar(false);
35    // let sender = parabuilder.get_data_queue_sender().unwrap();
36    parabuilder.set_datas(datas).unwrap();
37    parabuilder.init_workspace().unwrap();
38    let (run_data, compile_error_datas, _processed_data_ids): (
39        JsonValue,
40        Vec<JsonValue>,
41        Vec<usize>,
42    ) = parabuilder.run().unwrap();
43    println!(
44        "run_data: {}",
45        serde_json::to_string_pretty(&run_data).unwrap()
46    );
47    println!("compile_error_datas: {:?}", compile_error_datas);
48}
Source

pub fn in_place_template(self, in_place_template: bool) -> Self

Examples found in repository?
examples/cuda_quick_start.rs (line 19)
4fn main() {
5    let project_path = "tests/example_cuda_project"; // your project path
6    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
7    let template_path = "src/main.cu"; // template file in the project
8    let target_executable_file = "build/main"; // target executable file
9    let datas = (0..20)
10        .into_iter()
11        .map(|_| JsonValue::Null)
12        .collect::<Vec<JsonValue>>();
13    let mut parabuilder = Parabuilder::new(
14        project_path,
15        workspaces_path,
16        template_path,
17        &[target_executable_file],
18    )
19    .in_place_template(true)
20    .build_workers(2)
21    .run_method(RunMethod::OutOfPlace(2));
22    parabuilder.set_datas(datas).unwrap();
23    parabuilder.init_workspace().unwrap();
24    parabuilder.run().unwrap();
25}
More examples
Hide additional examples
examples/complete_usage.rs (line 33)
6fn main() {
7    let project_path = "tests/example_run_time_consuming_project"; // your project path
8    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
9    let template_path = "src/main.cpp.template"; // template file in the project
10    let target_executable_file = "build/main"; // target executable file
11    let mut datas = (1..=100)
12        .map(|i| json!({"N": i}))
13        .collect::<Vec<JsonValue>>();
14    let error_data = json!({"N": "a"});
15    datas.push(error_data.clone());
16    let init_bash_script = r#"cmake -B build -S . -DPARABUILD=ON"#;
17    let compile_bash_script = r#"cmake --build build --target all -- -B"#;
18    let mut parabuilder = Parabuilder::new(
19        project_path,
20        workspaces_path,
21        template_path,
22        &[target_executable_file],
23    )
24    .init_bash_script(init_bash_script)
25    .compile_bash_script(compile_bash_script)
26    // .run_bash_script(format!(r#"./{}"#, target_executable_file).as_str())
27    .build_workers(4)
28    .run_method(RunMethod::OutOfPlace(2)) // 4 threads compile, 1 thread run
29    // .run_method(RunMethod::Exclusive) // 4 threads compile, 1 thread run
30    .compilation_error_handling_method(CompliationErrorHandlingMethod::Collect) // collect data that has compilation error
31    .auto_gather_array_data(true) // when each run thread finishes, gather the data into one array when every thread returns an array
32    .run_func(IGNORE_ON_ERROR_DEFAULT_RUN_FUNC)
33    .in_place_template(false)
34    .disable_progress_bar(false);
35    // let sender = parabuilder.get_data_queue_sender().unwrap();
36    parabuilder.set_datas(datas).unwrap();
37    parabuilder.init_workspace().unwrap();
38    let (run_data, compile_error_datas, _processed_data_ids): (
39        JsonValue,
40        Vec<JsonValue>,
41        Vec<usize>,
42    ) = parabuilder.run().unwrap();
43    println!(
44        "run_data: {}",
45        serde_json::to_string_pretty(&run_data).unwrap()
46    );
47    println!("compile_error_datas: {:?}", compile_error_datas);
48}
Source

pub fn disable_progress_bar(self, disable_progress_bar: bool) -> Self

Examples found in repository?
examples/complete_usage.rs (line 34)
6fn main() {
7    let project_path = "tests/example_run_time_consuming_project"; // your project path
8    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
9    let template_path = "src/main.cpp.template"; // template file in the project
10    let target_executable_file = "build/main"; // target executable file
11    let mut datas = (1..=100)
12        .map(|i| json!({"N": i}))
13        .collect::<Vec<JsonValue>>();
14    let error_data = json!({"N": "a"});
15    datas.push(error_data.clone());
16    let init_bash_script = r#"cmake -B build -S . -DPARABUILD=ON"#;
17    let compile_bash_script = r#"cmake --build build --target all -- -B"#;
18    let mut parabuilder = Parabuilder::new(
19        project_path,
20        workspaces_path,
21        template_path,
22        &[target_executable_file],
23    )
24    .init_bash_script(init_bash_script)
25    .compile_bash_script(compile_bash_script)
26    // .run_bash_script(format!(r#"./{}"#, target_executable_file).as_str())
27    .build_workers(4)
28    .run_method(RunMethod::OutOfPlace(2)) // 4 threads compile, 1 thread run
29    // .run_method(RunMethod::Exclusive) // 4 threads compile, 1 thread run
30    .compilation_error_handling_method(CompliationErrorHandlingMethod::Collect) // collect data that has compilation error
31    .auto_gather_array_data(true) // when each run thread finishes, gather the data into one array when every thread returns an array
32    .run_func(IGNORE_ON_ERROR_DEFAULT_RUN_FUNC)
33    .in_place_template(false)
34    .disable_progress_bar(false);
35    // let sender = parabuilder.get_data_queue_sender().unwrap();
36    parabuilder.set_datas(datas).unwrap();
37    parabuilder.init_workspace().unwrap();
38    let (run_data, compile_error_datas, _processed_data_ids): (
39        JsonValue,
40        Vec<JsonValue>,
41        Vec<usize>,
42    ) = parabuilder.run().unwrap();
43    println!(
44        "run_data: {}",
45        serde_json::to_string_pretty(&run_data).unwrap()
46    );
47    println!("compile_error_datas: {:?}", compile_error_datas);
48}
Source

pub fn no_cache(self, no_cache: bool) -> Self

Source

pub fn without_rsync(self, without_rsync: bool) -> Self

Source

pub fn enable_cppflags(self, enable_cppflags: bool) -> Self

Source

pub fn autosave_interval(self, autosave_interval: u64) -> Self

Source

pub fn autosave_dir<S: AsRef<Path>>(self, autosave_dir: S) -> Self

Source

pub fn set_datas(&mut self, datas: Vec<JsonValue>) -> Result<(), Box<dyn Error>>

Set datas to be rendered into the template

Examples found in repository?
examples/cuda_quick_start.rs (line 22)
4fn main() {
5    let project_path = "tests/example_cuda_project"; // your project path
6    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
7    let template_path = "src/main.cu"; // template file in the project
8    let target_executable_file = "build/main"; // target executable file
9    let datas = (0..20)
10        .into_iter()
11        .map(|_| JsonValue::Null)
12        .collect::<Vec<JsonValue>>();
13    let mut parabuilder = Parabuilder::new(
14        project_path,
15        workspaces_path,
16        template_path,
17        &[target_executable_file],
18    )
19    .in_place_template(true)
20    .build_workers(2)
21    .run_method(RunMethod::OutOfPlace(2));
22    parabuilder.set_datas(datas).unwrap();
23    parabuilder.init_workspace().unwrap();
24    parabuilder.run().unwrap();
25}
More examples
Hide additional examples
examples/quick_start.rs (line 16)
4fn main() {
5    let project_path = "tests/example_cmake_project"; // your project path
6    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
7    let template_path = "src/main.cpp.template"; // template file in the project
8    let target_executable_file = "build/main"; // target executable file
9    let datas = vec![json!({"N": "10"}), json!({"N": "20"})];
10    let mut parabuilder = Parabuilder::new(
11        project_path,
12        workspaces_path,
13        template_path,
14        &[target_executable_file],
15    );
16    parabuilder.set_datas(datas).unwrap();
17    parabuilder.init_workspace().unwrap();
18    let (run_data, _compile_error_datas, _processed_data_ids): (
19        JsonValue,
20        Vec<JsonValue>,
21        Vec<usize>,
22    ) = parabuilder.run().unwrap();
23    println!("{}", to_string_pretty(&run_data).unwrap());
24    /*
25    [
26        {
27            "data": {
28                "N": "10"
29            },
30            "status": 0,
31            "stderr": "",
32            "stdout": "10\n"
33        },
34        {
35            "data": {
36                "N": "20"
37            },
38            "status": 0,
39            "stderr": "",
40            "stdout": "20\n"
41        }
42    ]
43     */
44}
examples/complete_usage.rs (line 36)
6fn main() {
7    let project_path = "tests/example_run_time_consuming_project"; // your project path
8    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
9    let template_path = "src/main.cpp.template"; // template file in the project
10    let target_executable_file = "build/main"; // target executable file
11    let mut datas = (1..=100)
12        .map(|i| json!({"N": i}))
13        .collect::<Vec<JsonValue>>();
14    let error_data = json!({"N": "a"});
15    datas.push(error_data.clone());
16    let init_bash_script = r#"cmake -B build -S . -DPARABUILD=ON"#;
17    let compile_bash_script = r#"cmake --build build --target all -- -B"#;
18    let mut parabuilder = Parabuilder::new(
19        project_path,
20        workspaces_path,
21        template_path,
22        &[target_executable_file],
23    )
24    .init_bash_script(init_bash_script)
25    .compile_bash_script(compile_bash_script)
26    // .run_bash_script(format!(r#"./{}"#, target_executable_file).as_str())
27    .build_workers(4)
28    .run_method(RunMethod::OutOfPlace(2)) // 4 threads compile, 1 thread run
29    // .run_method(RunMethod::Exclusive) // 4 threads compile, 1 thread run
30    .compilation_error_handling_method(CompliationErrorHandlingMethod::Collect) // collect data that has compilation error
31    .auto_gather_array_data(true) // when each run thread finishes, gather the data into one array when every thread returns an array
32    .run_func(IGNORE_ON_ERROR_DEFAULT_RUN_FUNC)
33    .in_place_template(false)
34    .disable_progress_bar(false);
35    // let sender = parabuilder.get_data_queue_sender().unwrap();
36    parabuilder.set_datas(datas).unwrap();
37    parabuilder.init_workspace().unwrap();
38    let (run_data, compile_error_datas, _processed_data_ids): (
39        JsonValue,
40        Vec<JsonValue>,
41        Vec<usize>,
42    ) = parabuilder.run().unwrap();
43    println!(
44        "run_data: {}",
45        serde_json::to_string_pretty(&run_data).unwrap()
46    );
47    println!("compile_error_datas: {:?}", compile_error_datas);
48}
Source

pub fn set_datas_with_processed_data_ids_set( &mut self, datas: Vec<JsonValue>, processed_data_ids_set: HashSet<usize>, ) -> Result<(), Box<dyn Error>>

Set datas to be rendered into the template

Source

pub fn get_data_queue_sender( &mut self, ) -> Result<Sender<(usize, JsonValue)>, Box<dyn Error>>

Source

pub fn init_workspace(&self) -> Result<(), Box<dyn Error>>

Initialize workspaces

Examples found in repository?
examples/cuda_quick_start.rs (line 23)
4fn main() {
5    let project_path = "tests/example_cuda_project"; // your project path
6    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
7    let template_path = "src/main.cu"; // template file in the project
8    let target_executable_file = "build/main"; // target executable file
9    let datas = (0..20)
10        .into_iter()
11        .map(|_| JsonValue::Null)
12        .collect::<Vec<JsonValue>>();
13    let mut parabuilder = Parabuilder::new(
14        project_path,
15        workspaces_path,
16        template_path,
17        &[target_executable_file],
18    )
19    .in_place_template(true)
20    .build_workers(2)
21    .run_method(RunMethod::OutOfPlace(2));
22    parabuilder.set_datas(datas).unwrap();
23    parabuilder.init_workspace().unwrap();
24    parabuilder.run().unwrap();
25}
More examples
Hide additional examples
examples/quick_start.rs (line 17)
4fn main() {
5    let project_path = "tests/example_cmake_project"; // your project path
6    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
7    let template_path = "src/main.cpp.template"; // template file in the project
8    let target_executable_file = "build/main"; // target executable file
9    let datas = vec![json!({"N": "10"}), json!({"N": "20"})];
10    let mut parabuilder = Parabuilder::new(
11        project_path,
12        workspaces_path,
13        template_path,
14        &[target_executable_file],
15    );
16    parabuilder.set_datas(datas).unwrap();
17    parabuilder.init_workspace().unwrap();
18    let (run_data, _compile_error_datas, _processed_data_ids): (
19        JsonValue,
20        Vec<JsonValue>,
21        Vec<usize>,
22    ) = parabuilder.run().unwrap();
23    println!("{}", to_string_pretty(&run_data).unwrap());
24    /*
25    [
26        {
27            "data": {
28                "N": "10"
29            },
30            "status": 0,
31            "stderr": "",
32            "stdout": "10\n"
33        },
34        {
35            "data": {
36                "N": "20"
37            },
38            "status": 0,
39            "stderr": "",
40            "stdout": "20\n"
41        }
42    ]
43     */
44}
examples/complete_usage.rs (line 37)
6fn main() {
7    let project_path = "tests/example_run_time_consuming_project"; // your project path
8    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
9    let template_path = "src/main.cpp.template"; // template file in the project
10    let target_executable_file = "build/main"; // target executable file
11    let mut datas = (1..=100)
12        .map(|i| json!({"N": i}))
13        .collect::<Vec<JsonValue>>();
14    let error_data = json!({"N": "a"});
15    datas.push(error_data.clone());
16    let init_bash_script = r#"cmake -B build -S . -DPARABUILD=ON"#;
17    let compile_bash_script = r#"cmake --build build --target all -- -B"#;
18    let mut parabuilder = Parabuilder::new(
19        project_path,
20        workspaces_path,
21        template_path,
22        &[target_executable_file],
23    )
24    .init_bash_script(init_bash_script)
25    .compile_bash_script(compile_bash_script)
26    // .run_bash_script(format!(r#"./{}"#, target_executable_file).as_str())
27    .build_workers(4)
28    .run_method(RunMethod::OutOfPlace(2)) // 4 threads compile, 1 thread run
29    // .run_method(RunMethod::Exclusive) // 4 threads compile, 1 thread run
30    .compilation_error_handling_method(CompliationErrorHandlingMethod::Collect) // collect data that has compilation error
31    .auto_gather_array_data(true) // when each run thread finishes, gather the data into one array when every thread returns an array
32    .run_func(IGNORE_ON_ERROR_DEFAULT_RUN_FUNC)
33    .in_place_template(false)
34    .disable_progress_bar(false);
35    // let sender = parabuilder.get_data_queue_sender().unwrap();
36    parabuilder.set_datas(datas).unwrap();
37    parabuilder.init_workspace().unwrap();
38    let (run_data, compile_error_datas, _processed_data_ids): (
39        JsonValue,
40        Vec<JsonValue>,
41        Vec<usize>,
42    ) = parabuilder.run().unwrap();
43    println!(
44        "run_data: {}",
45        serde_json::to_string_pretty(&run_data).unwrap()
46    );
47    println!("compile_error_datas: {:?}", compile_error_datas);
48}
Source

pub fn autosave_load( &mut self, start_time: String, ) -> (JsonValue, Vec<JsonValue>, Vec<usize>)

Load autosave data (run_datas, compile_error_datas, processed_data_ids)

Source

pub fn run( &self, ) -> Result<(JsonValue, Vec<JsonValue>, Vec<usize>), Box<dyn Error>>

run the build system

Examples found in repository?
examples/cuda_quick_start.rs (line 24)
4fn main() {
5    let project_path = "tests/example_cuda_project"; // your project path
6    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
7    let template_path = "src/main.cu"; // template file in the project
8    let target_executable_file = "build/main"; // target executable file
9    let datas = (0..20)
10        .into_iter()
11        .map(|_| JsonValue::Null)
12        .collect::<Vec<JsonValue>>();
13    let mut parabuilder = Parabuilder::new(
14        project_path,
15        workspaces_path,
16        template_path,
17        &[target_executable_file],
18    )
19    .in_place_template(true)
20    .build_workers(2)
21    .run_method(RunMethod::OutOfPlace(2));
22    parabuilder.set_datas(datas).unwrap();
23    parabuilder.init_workspace().unwrap();
24    parabuilder.run().unwrap();
25}
More examples
Hide additional examples
examples/quick_start.rs (line 22)
4fn main() {
5    let project_path = "tests/example_cmake_project"; // your project path
6    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
7    let template_path = "src/main.cpp.template"; // template file in the project
8    let target_executable_file = "build/main"; // target executable file
9    let datas = vec![json!({"N": "10"}), json!({"N": "20"})];
10    let mut parabuilder = Parabuilder::new(
11        project_path,
12        workspaces_path,
13        template_path,
14        &[target_executable_file],
15    );
16    parabuilder.set_datas(datas).unwrap();
17    parabuilder.init_workspace().unwrap();
18    let (run_data, _compile_error_datas, _processed_data_ids): (
19        JsonValue,
20        Vec<JsonValue>,
21        Vec<usize>,
22    ) = parabuilder.run().unwrap();
23    println!("{}", to_string_pretty(&run_data).unwrap());
24    /*
25    [
26        {
27            "data": {
28                "N": "10"
29            },
30            "status": 0,
31            "stderr": "",
32            "stdout": "10\n"
33        },
34        {
35            "data": {
36                "N": "20"
37            },
38            "status": 0,
39            "stderr": "",
40            "stdout": "20\n"
41        }
42    ]
43     */
44}
examples/complete_usage.rs (line 42)
6fn main() {
7    let project_path = "tests/example_run_time_consuming_project"; // your project path
8    let workspaces_path = "workspaces"; // where to store the workspaces, executables, etc.
9    let template_path = "src/main.cpp.template"; // template file in the project
10    let target_executable_file = "build/main"; // target executable file
11    let mut datas = (1..=100)
12        .map(|i| json!({"N": i}))
13        .collect::<Vec<JsonValue>>();
14    let error_data = json!({"N": "a"});
15    datas.push(error_data.clone());
16    let init_bash_script = r#"cmake -B build -S . -DPARABUILD=ON"#;
17    let compile_bash_script = r#"cmake --build build --target all -- -B"#;
18    let mut parabuilder = Parabuilder::new(
19        project_path,
20        workspaces_path,
21        template_path,
22        &[target_executable_file],
23    )
24    .init_bash_script(init_bash_script)
25    .compile_bash_script(compile_bash_script)
26    // .run_bash_script(format!(r#"./{}"#, target_executable_file).as_str())
27    .build_workers(4)
28    .run_method(RunMethod::OutOfPlace(2)) // 4 threads compile, 1 thread run
29    // .run_method(RunMethod::Exclusive) // 4 threads compile, 1 thread run
30    .compilation_error_handling_method(CompliationErrorHandlingMethod::Collect) // collect data that has compilation error
31    .auto_gather_array_data(true) // when each run thread finishes, gather the data into one array when every thread returns an array
32    .run_func(IGNORE_ON_ERROR_DEFAULT_RUN_FUNC)
33    .in_place_template(false)
34    .disable_progress_bar(false);
35    // let sender = parabuilder.get_data_queue_sender().unwrap();
36    parabuilder.set_datas(datas).unwrap();
37    parabuilder.init_workspace().unwrap();
38    let (run_data, compile_error_datas, _processed_data_ids): (
39        JsonValue,
40        Vec<JsonValue>,
41        Vec<usize>,
42    ) = parabuilder.run().unwrap();
43    println!(
44        "run_data: {}",
45        serde_json::to_string_pretty(&run_data).unwrap()
46    );
47    println!("compile_error_datas: {:?}", compile_error_datas);
48}
Source

pub fn gather_data( &self, run_data_array: Vec<JsonValue>, compile_error_datas: Vec<JsonValue>, processed_data_ids: Vec<usize>, ) -> Result<(JsonValue, Vec<JsonValue>, Vec<usize>), Box<dyn Error>>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.