bpglaser / red-mountain-resize

An image resize tool utilizing seam carving.
18 stars 2 forks source link

parallelize with rayon? #1

Open nikomatsakis opened 7 years ago

nikomatsakis commented 7 years ago

I've been looking to turn exactly this algorithm into a rayon benchmark. Any interest in trying to parallelize your code? I'd be happy to work with you a bit on it.

bpglaser commented 7 years ago

Definitely something I want to look into. I'll add it to the road map.

nikomatsakis commented 7 years ago

I had a brief look around. I was just looking (to start, at least) at the "compute energy" phase. The current code seems to iterate over indices and mutate a big map by writing into it. I think that, to make this work with rayon, you could do one of two things. To keep the current "iterate and mutate" structure you'd have to break up the big map from being a monolithic data structure into a vector of columns (or at least something where you can get a vector of columns), and you can mutate each column individually. Then you could do a par_iter_mut() over the columns.

(Alternatively, you could change the strategy, and rather than pre-allocating the map, you would instead do a collect or collect_into and build up a fresh map.)