Closed Crown421 closed 4 years ago
How can I call the functions? I don't get any speed up. Is the Base API replaced, and so I can call the functions like just normal names (log, exp
, etc)?
VML extends the base functions to e.g. sin(x::Array{Float64}), as the base functions don't take arrays but instead rely on broadcasting.
julia> using VML
julia> a = rand(10000);
julia>@time sin.(a);
0.159878 seconds (583.25 k allocations: 30.720 MiB, 2.78% gc time)
julia> @time sin(a);
0.000465 seconds (6 allocations: 781.484 KiB)
In short, if you call function with an array they go to vml, otherwise they use the base functions.
Oh yes, I was trying the wrong code! I thought it is possible to run something like sin(a)
in Julia Base. It would be nice to add this example to the Readme!
Great to see progress!
VML extends the base functions to e.g. sin(x::Array{Float64}), as the base functions don't take arrays
I didn't realise it did this, are we sure this the right way to go? Overloading Base functions on Base types. You must write Yeppp.sin
and AppleAccelerate.exp
etc. Perhaps the 1.0 update is a good moment to do likewise here?
Great to see progress!
VML extends the base functions to e.g. sin(x::Array{Float64}), as the base functions don't take arrays
I didn't realise it did this, are we sure this the right way to go? Overloading Base functions on Base types. You must write
Yeppp.sin
andAppleAccelerate.exp
etc. Perhaps the 1.0 update is a good moment to do likewise here?
I think this is beyond this pull request, and it will just lag using this package. Changing the API requires a completely different work
Great to see progress!
VML extends the base functions to e.g. sin(x::Array{Float64}), as the base functions don't take arrays
I didn't realise it did this, are we sure this the right way to go? Overloading Base functions on Base types. You must write
Yeppp.sin
andAppleAccelerate.exp
etc. Perhaps the 1.0 update is a good moment to do likewise here?
It does, when I updated the test suite I ran into some issues verifying that a given call actually belongs to Base or VML, to make sure that I am not comparing a function to itself in terms of accurate output.
Ideally I would like the option that using VML
extends Base and import VML
doesn't, like one would expect, but unfortunately there seem to be some restrictions in the way Julia itself works here.
I think that is appropriate for its own issue.
I can't seem to make this work, with MKL.jl. On a mac with Julia 1.3rc4 or 1.4, afetr installing MKL.jl, I can add & build VML (Crown421:master), but can't use it. Is this expected to work?
julia> using VML
[ Info: Precompiling VML [c8ce9da6-5d36-5c03-b118-5a70151be7bc]
ERROR: LoadError: LoadError: could not load library "libmkl_rt"
dlopen(libmkl_rt.dylib, 9): image not found
Stacktrace:
[1] #dlopen#3(::Bool, ::typeof(Libdl.dlopen), ::String, ::UInt32) at /Applications/Julia-1.3.app/Contents/Resources/julia/lib/julia/sys.dylib:?
[2] #dlopen#2 at /Applications/Julia-1.3.app/Contents/Resources/julia/share/julia/stdlib/v1.3/Libdl/src/Libdl.jl:109 [inlined]
[3] dlopen at /Applications/Julia-1.3.app/Contents/Resources/julia/share/julia/stdlib/v1.3/Libdl/src/Libdl.jl:105 [inlined]
[4] __init__() at /Users/me/.julia/dev/VML/src/setup.jl:3
julia> using Libdl
julia> dlopen(:libmkl_rt; throw_error=false) !== nothing
false
You are right, I only tested the standalone on Mac, not with MKL.jl. I get the same error on julia 1.1. I might have an idea about the problem, but it is likely something MKL.
So, I am not sure how to fix this better (yet), but for now
export DYLD_FALLBACK_LIBRARY_PATH=<path to MKL folder>/deps/usr/lib
will fix the issue.
Great, thank you. With that I can load VML, and have updated my tests in #19 .
julia> Base.pathof(MKL) # since I always forget
export DYLD_FALLBACK_LIBRARY_PATH=/Users/me/.julia/packages/MKL/goLVK/deps/usr/lib
I hope this is not abandoned again.
Added an ok fix to add the path of the shared libraries from MKL.jl to the search path. @mcabbott Do you want to add your changes to my repository, so that there is at least one usable/ complete repo?
@mcabbott Do you want to add your changes to my repository so that there is at least one usable/ complete repo?
I agree. Now that this may take a little more time to get merged, it is reasonable to merge that one too.
Sure, see if I did that right!
BTW the with the latest commit here I still seem to need to provide the path by hand. Error when trying without that, on Julia 1.2 with MKL.jl:
julia> using VML
[ Info: Precompiling VML [c8ce9da6-5d36-5c03-b118-5a70151be7bc]
ERROR: LoadError: LoadError: could not load library "libmkl_rt"
dlopen(libmkl_rt.dylib, 9): image not found
Stacktrace:
[1] #dlopen#3(::Bool, ::typeof(Libdl.dlopen), ::String, ::UInt32) at /Applications/Julia-1.2.app/Contents/Resources/julia/lib/julia/sys.dylib:?
[2] #dlopen#2 at /Applications/Julia-1.2.app/Contents/Resources/julia/share/julia/stdlib/v1.2/Libdl/src/Libdl.jl:109 [inlined]
[3] dlopen at /Applications/Julia-1.2.app/Contents/Resources/julia/share/julia/stdlib/v1.2/Libdl/src/Libdl.jl:105 [inlined]
[4] __init__() at /Users/me/.julia/dev/VML/src/setup.jl:3
Yes, I am working on that. After working once it now doesn't work anymore. I think I came up with a better solution, assuming I can get it to work.
@mcabbott Try using it now, I think I made it work now reasonably well. Readme comes next.
Thank you guys for the work.
I will test the functionality.
@KristofferC Would it be possible to merge this PR now? While still not perfect, I think this package is now ready for use.
I am going to create a PR to this branch and update the benchmarks code. https://github.com/aminya/VML.jl/tree/workingJulia1
The pull request is ready for merging! https://github.com/Crown421/VML.jl/pull/2
@Crown421 I am working on making AcuteBenchmark by using the approach we took for benchmarking the functions that get arrays. I will add some features such as trying different sizes, etc. So, for now, don't spend time on changing things in the benchmark code. Once that package is finished we can do a more extensive benchmark for VML.
I am not entirely sure what you mean with "approach for benchmarking the arrays" ?
That package is going to generate random arrays (as inputs) and benchmark the functions based on that. Similar to what we did in this package, but written in a general and reusable manner and with more features. I will post the source code once it is finished.
Feel free to check out the benchmarks
branch on my repo, which contains my first attempt at a rewrite (bm.jl
and bm_functions.jl
) from last week.
It also has some stuff for a more thorough job (bm_extended.jl
) from Sunday, which includes testing whether the speed-up is statistically significant, but currently suffers from unexplained high RAM usage.
Thank you. That is useful. I also have some code from Julia-Matlab-Benchmark, which overall will make a useful package (AcuteBenchmark).
@simonster @andreasnoack @ViralBShah Could you merge this PR?
@Crown421 @aminya I have invited you to have write access to the repo. Hope that helps with the management of this repo and keeping it updated. Thank you for the contributions!
Thank you! You're welcome.
Is there any update on this, MKL was updated recently https://github.com/JuliaComputing/MKL.jl, but it doesn't use VML functions (like exp, log) by itself.