timholy / ComputationalResources.jl

Julia package for selecting hardware, libraries, and algorithms for a computation
Other
34 stars 5 forks source link

How does the package compare to Requires.jl? #14

Closed juliohm closed 6 years ago

juliohm commented 6 years ago

Hi Tim,

I appreciate if you can clarify the mechanism of this package as compared to Requires.jl? I am trying to upgrade ImageQuilting.jl to Julia v0.7, and I will have to make OpenCL + CLFFT optional dependencies. As far as I understood the addresource command in this package plays the role of a "priority queue" of resources where GPUs have higher priority than CPUs? I wonder what is your recommendation for upgrading code in the long-term?

Thank you,

timholy commented 6 years ago

This package is really about choosing which resource you want for a specific computation. In ImageFiltering you can run imfilter(CPUThreads(), img, kernel) and imfilter(CPU1(), img, kernel) in the same session, and therefore accurately benchmark the difference.

With regards to loading "glue" code I would switch to Requires. The mechanism documented here was reliable back in an era when Requires was pretty hacky (it did some crazy stuff), but Requires has become a better citizen and it's now better to use it.

A PR to change the README would be most appreciated!

juliohm commented 6 years ago

Thank you, my short-term plan is to use Requires.jl to load both OpenCL.jl and CLFFT.jl as dependencies and load the related code in ImageQuilting.jl.

In the long-term, however, I would like to migrate the OpenCL imfilter implementation I have there to ImageFiltering.jl, and use ComputationalResources.jl to dispatch it: https://github.com/juliohm/ImageQuilting.jl/blob/master/src/imfilter_gpu.jl

Does it sound like a reasonable way forward?

timholy commented 6 years ago

That's precisely how it should work :smile:. Great plan.

juliohm commented 6 years ago

Closing this one as the plan is clear :+1: