-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It is now clearer how to use this library. The example(s) are built by default.
- Loading branch information
Connor-GH
committed
Oct 11, 2024
1 parent
4bb45f8
commit f7dcd7c
Showing
4 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "hpx-examples" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
hpx-sys = { path = "../hpx-sys", version = "0.1.0" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#![feature(vec_into_raw_parts)] | ||
#![feature(random)] | ||
use core::array::from_fn; | ||
use std::{process, random, ffi::c_char, env}; | ||
|
||
use hpx_sys as hpx; | ||
|
||
fn hpx_main(argc: i32, argv: *mut *mut c_char) -> i32 { | ||
|
||
let numbers: &[i32; 16384] = &from_fn(|_| random::random::<i32>()); | ||
let list: &mut Vec<i32> = &mut Vec::<i32>::from(numbers); | ||
println!("{:#?}", list); | ||
// Sort the array in parallel. | ||
hpx::hpx_sort_comp(list, |a, b| a < b); | ||
println!("{:#?}", list); | ||
hpx::finalize(); | ||
return 0; | ||
} | ||
fn main() { | ||
let args = env::args(); | ||
let (argc, argv) = hpx::create_c_args(&args | ||
.collect::<Vec<String>>() | ||
.iter() | ||
.map(|s| s.as_str()) | ||
.collect::<Vec<&str>>() | ||
); | ||
unsafe { | ||
process::exit(hpx::init(hpx_main, argc, argv | ||
.into_raw_parts() | ||
.0)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters