Skip to content
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

Speed up LMS<->XYZ conversions by a factor of 20 #48

Closed
wants to merge 1 commit into from
Closed

Speed up LMS<->XYZ conversions by a factor of 20 #48

wants to merge 1 commit into from

Conversation

timholy
Copy link
Contributor

@timholy timholy commented Jul 24, 2014

Also gives a 2x speed boost to RGB<->XYZ. The slow ^ operation in
rgb_compand is the remaining bottleneck, but there's not an
easy way around that.

Note: this may be problematic once multithreading lands (the globals tmp1, tmp2 are not thread-safe), so I'm going to not hit the merge button on this one without review. CC @StefanKarpinski.

Also gives a 2x speed boost to RGB<->XYZ. The slow ^ operation in
`rgb_compand` is the remaining bottleneck, but there's not an
easy way around that.
@dcjones
Copy link
Contributor

dcjones commented Jul 25, 2014

Awesome speedup! I have to admit though, I'm not crazy about the tmp globals. Could we replace this pattern

gemv3!(tmp2, M_RGB_XYZ, tmp1)
XYZ(tmp2[1], tmp2[2], tmp2[3])

with a macro to do in place, like

XYZ(M_RGB_XYZ[1] * c.r + M_RGB_XYZ[2] * c.g + M_RGB_XYZ[3] * c.b,
    M_RGB_XYZ[4] * c.r + M_RGB_XYZ[5] * c.g + M_RGB_XYZ[6] * c.b,
    M_RGB_XYZ[7] * c.r + M_RGB_XYZ[8] * c.g + M_RGB_XYZ[9] * c.b)

I guess to do it in a generic way, well need to define getindex functions and index into the color like c[1] instead of c.r.

@timholy
Copy link
Contributor Author

timholy commented Jul 25, 2014

I belatedly had the very same thought. We can use getfield(c, 1) for indexing, if you don't want to define getindex. (Or would you rather have getindex anyway?)

I'll push a better version. In working on #42 I discovered that there are a whole bunch of other places this can be used (in conversions.jl).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants