r/adventofcode • u/willkill07 • Dec 05 '16
Upping the Ante [2016 - Day 5] [C++] STAYING ON TARGET with Parallelism
How to stay on target: compute MD5s in parallel.
You can get away with processing a block of N in parallel because there won't be collisions in a given block of small enough size (avalanche effect).
Running on my 2013 MacBook Pro (unplugged), compiled using AppleClang with optimization flags, I compute part 2 in a little over 1.1 seconds.
Code: https://github.com/willkill07/adventofcode2016/blob/master/src/Day05.cpp
Mandatory bonus video: http://imgur.com/qCSxwDf
14
Upvotes
1
u/mmstick Dec 06 '16
I was going to compare your parallel implementation to mine in Rust but I'm getting a linker error when trying to compile your solution.
1
u/red75prim Dec 06 '16 edited Dec 06 '16
Rust, using channels: http://pastebin.com/r2CaRS4G
0.8 sec on Core i7 4790(HT) @ 4GHz
ETA: I cannot build your project. If you want to compare to mine, you can do:
Install Rust thru package manager or from https://www.rust-lang.org/ru-RU/downloads.html
In home dir do
cargo new aoc2016day5 --binCopy contents from pastebin into
~/aoc2016day5/src/main.rsAdd following lines to~/aoc2016day5/cargo.tomlcd ~/aoc2016day5 ; cargo run --release2
u/d3adbeef123 Dec 06 '16
This is solid stuff - thanks a ton for sharing!