Giter Site home page Giter Site logo

blas used on os x about gsl-ocaml HOT 10 CLOSED

mmottl avatar mmottl commented on May 29, 2024
blas used on os x

from gsl-ocaml.

Comments (10)

mmottl avatar mmottl commented on May 29, 2024

If I remember correctly, the GSL-provided BLAS/LAPACK libraries will be overridden by the OCaml GSL-bindings. gsl-ocaml links with the Accelerate framework by default. You can call otool -L on your executables to see whether they link with the Accelerate framework.

from gsl-ocaml.

nilsbecker avatar nilsbecker commented on May 29, 2024

ok, i get:

hmtree.native:
	/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
	/usr/local/opt/gsl/lib/libgsl.19.dylib (compatibility version 22.0.0, current version 22.0.0)
	/usr/local/opt/gsl/lib/libgslcblas.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)

which i find confusing since it links with accelerate but also shows the gsl-provided cblas if i'm not mistaken. in that program, also lacaml was used if that matters. maybe lacaml actually links accelerate and gsl-ocaml the cblas?

from gsl-ocaml.

mmottl avatar mmottl commented on May 29, 2024

Lacaml should only link with the Accelerate framework. I guess on Mac OS X it might be necessary to supply gsl-config --libs-without-cblas within the gsl-ocaml myocamlbuild.ml file. If you want, you can try it out by editing that file and replacing the --libs flag with the mentioned one. Maybe it makes a difference or not. You may need to run an example to find out.

from gsl-ocaml.

nilsbecker avatar nilsbecker commented on May 29, 2024

ok thanks, will try tomorrow.

from gsl-ocaml.

nilsbecker avatar nilsbecker commented on May 29, 2024

ok, i tried: i now have this in my local opam-pinned copy of gsl-ocaml:

          (*let ic = Unix.open_process_in "gsl-config --cflags --libs" in*)
          let ic = Unix.open_process_in "gsl-config --cflags --libs-without-cblas" in

i reinstalled the pinned version with opam. now the same program as before, with otool -L gives

hmtree.native:
	/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
	/usr/local/opt/gsl/lib/libgsl.19.dylib (compatibility version 22.0.0, current version 22.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)

so the cblas is gone. i have not tried if this program runs yet.

i have tried a toplevel with gsl loaded. calls to Gsl_blas (gemm) work, although in the open files for that process, nothing regarding accelerate was shown. but also the gsl-provided cblas was not shown anymore, so it seems to work to not link that.

so i think your suggestion works. i would think this should then be fixed in the opam package?

from gsl-ocaml.

mmottl avatar mmottl commented on May 29, 2024

The more important question is, does the change actually improve performance. If the Accelerate BLAS overrides the GSL-provided one anyway, the change won't be necessary. Maybe you can try out matrix multiplication as a test, which should likely show a significant performance difference.

from gsl-ocaml.

nilsbecker avatar nilsbecker commented on May 29, 2024

hmm it may be that cblas is linked but not used. i tried again with a minimal program which just uses gsl as its only package, and with the original opam-installed gsl. indeed cblas is linked, but so is accelerate, which is here not a byproduct of using lacaml.
probably performance testing would be the only way to decide.

from gsl-ocaml.

nilsbecker avatar nilsbecker commented on May 29, 2024

ok. it does seem to matter. i made a program that LU-inverts a 400x400 matrix 100 times. with the standard opam installation of gsl-ocaml this takes 5.9s to run. after pinning gsl-ocaml with the myocamlbuild change above, the same (recompiled) program does not link cblas anymore and runs in 3.0s

(in each case i reran a few times to be sure)

from gsl-ocaml.

nilsbecker avatar nilsbecker commented on May 29, 2024

for reference:

let a = Gsl.Matrix.create 400 400 in
let () = Gsl.Matrix.set_id a in
let () = Gsl.Matrix.set a 123 223 123. in
for i = 1 to 100 do
  ignore @@ Gsl.Linalg.invert_LU (`M a);
done;

from gsl-ocaml.

mmottl avatar mmottl commented on May 29, 2024

Ok, thanks for testing this. I've made a new release that will avoid linking with the "slow" library on Mac OS X, the reasonable assumption being that users will always want to use the Accelerate Framework on this platform.

from gsl-ocaml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.