-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parallelize *Model.computeColor #2
Conversation
I actually did something similar before but didn't commit it. :) Any performance difference if you send results over a channel and aggregate them instead of using a mutex on shared variables? |
From a quick check: nope, it's roughly the same results. On Tue, Sep 20, 2016, 23:51 Michael Fogleman notifications@github.com
|
Cool, thanks. I'll look into this PR further later tonight! |
4fc3b9d
to
823200d
Compare
Rebased to fix conflict. |
One goroutine per line.
823200d
to
92fb6df
Compare
Hmm, I just ran your code and it was actually a little slower... (51 vs 50 seconds)
|
BTW, when I tried to do this, I created N workers and had them each process every Nth scanline, starting at 0, 1, 2, 3 if N=4. N was set to runtime.GOMAXPROCS(0). |
@hectorj Here's my attempt... https://github.com/fogleman/primitive/compare/parallel It seems that it does speed things up if the input image is relatively large, but it slows things down for 128x128px inputs, for example. |
This PR parallelizes *Model.computeColor.
One goroutine per line.
On my computer, in some very crude benchmark (owl.png, n=3) it shows a ~25% gain.
It does not alter the results (checked using https://github.com/hectorj/primitive/blob/basic-test/main_test.go).
(PS: I love your work, results look amazing)