Skip to content

Commit

Permalink
added flag for ppm meta data, use rayon git
Browse files Browse the repository at this point in the history
  • Loading branch information
willi-kappler committed Jan 24, 2016
1 parent 67dbe57 commit fe51a9c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ time = "0.1"
num = "0.1"
clap = "1"
scoped_threadpool = "0.1"
simple_parallel = "0.3.0"
rayon = "0.0.1"
simple_parallel = "0.3"
rayon = {git = "https://github.com/nikomatsakis/rayon.git"}
crossbeam = "0.2"
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ Using all cores (including virtual one due to hyper threading) rayon is the fast

# TODO:
- [ ] Check ArrayFire
- [ ] Check Collenchyma
- [ ] Check Timely Dataflow
- [ ] Check Crossbeam
- [ ] Use rust-fmt on source code (Thanks to matklad)
- [ ] Check docopt (instead of clap ? Thanks to matklad)

Expand Down
9 changes: 8 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct MandelConfig {
y_step: f64,
max_iter: u32,
img_size: u32,
write_meta_data: bool,
num_threads: u32
}

Expand All @@ -53,6 +54,7 @@ fn parse_arguments() -> MandelConfig {
--re2=[REAL2] 'right real part (default: 1.0)'
--img1=[IMAGINARY1] 'lower part (default: -1.50)'
--img2=[IMAGINARY2] 'upper part (default: 1.50)'
--write_meta_data 'write meta data like run time into the ppm file (default: off)'
--max_iter=[MAX_ITER] 'maximum number of iterations (default: 2048)'
--img_size=[IMAGE_SIZE] 'size of image in pixel (square, default: 1024, must be a power of two)'
--num_threads=[NUMBER_OF_THREADS] 'number of threads to use (default: 2)'")
Expand All @@ -62,6 +64,7 @@ fn parse_arguments() -> MandelConfig {
let re2 = value_t!(matches.value_of("REAL2"), f64).unwrap_or(1.0);
let img1 = value_t!(matches.value_of("IMAGINARY1"), f64).unwrap_or(-1.5);
let img2 = value_t!(matches.value_of("IMAGINARY2"), f64).unwrap_or(1.5);
let meta_data = matches.is_present("write_meta_data");
let max_iter = value_t!(matches.value_of("MAX_ITER"), u32).unwrap_or(2048);
let img_size = value_t!(matches.value_of("IMAGE_SIZE"), u32).unwrap_or(1024);
let num_threads = value_t!(matches.value_of("NUMBER_OF_THREADS"), u32).unwrap_or(2);
Expand All @@ -87,6 +90,7 @@ fn parse_arguments() -> MandelConfig {
y_step: y_step,
max_iter: max_iter,
img_size: img_size,
write_meta_data: meta_data,
num_threads: num_threads
}
}
Expand All @@ -113,7 +117,10 @@ fn write_image(file_name: &str, mandel_config: &MandelConfig, time_in_ms: f64, i

try!(buffer.write(b"P3\n"));
try!(write!(buffer, "# mandelbrot, max_iter: {}\n", mandel_config.max_iter));
try!(write!(buffer, "# computation time: {} ms\n", time_in_ms));
if mandel_config.write_meta_data {
// TODO: add more meta data: date and time, method, ...
try!(write!(buffer, "# computation time: {} ms\n", time_in_ms));
}
try!(write!(buffer, "{0} {0}\n", mandel_config.img_size));
try!(buffer.write(b"255\n"));

Expand Down

0 comments on commit fe51a9c

Please sign in to comment.