Skip to content

Commit

Permalink
Add eval-whens to make magicl compile as a monolithic bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-s committed Mar 25, 2022
1 parent f83aab4 commit 34bb1d9
Show file tree
Hide file tree
Showing 4 changed files with 579 additions and 575 deletions.
41 changes: 21 additions & 20 deletions src/extensions/blas/load-libs.lisp
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
(in-package #:magicl.foreign-libraries)

(cffi:define-foreign-library libblas
#+:magicl.use-accelerate
(:darwin "libBLAS.dylib" :search-path #P"/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Versions/A/")
#-:magicl.use-accelerate
(:darwin (:or "/usr/local/opt/lapack/lib/libblas.dylib" "libblas.dylib" ))
#+:magicl.use-mkl
(:unix "libmkl_rt.so")
#-:magicl.use-mkl
(:unix (:or "libblas.so"
"libblas.so.3"))
(t (:default "libblas")))
(eval-when (:compile-toplevel :load-toplevel :execute)
(cffi:define-foreign-library libblas
#+:magicl.use-accelerate
(:darwin "libBLAS.dylib" :search-path #P"/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Versions/A/")
#-:magicl.use-accelerate
(:darwin (:or "/usr/local/opt/lapack/lib/libblas.dylib" "libblas.dylib" ))
#+:magicl.use-mkl
(:unix "libmkl_rt.so")
#-:magicl.use-mkl
(:unix (:or "libblas.so"
"libblas.so.3"))
(t (:default "libblas")))

(pushnew 'libblas *foreign-libraries*)
(export 'libblas)
(pushnew 'libblas *foreign-libraries*)
(export 'libblas)

(defvar *blas-loaded* nil)
(defvar *blas-loaded* nil)

(unless *blas-loaded*
(cffi:load-foreign-library 'libblas)
(setf *blas-loaded* t))
(unless *blas-loaded*
(cffi:load-foreign-library 'libblas)
(setf *blas-loaded* t))

(magicl:define-backend :blas
:documentation "Backend for BLAS functionality written in Fortran."
:default t)
(magicl:define-backend :blas
:documentation "Backend for BLAS functionality written in Fortran."
:default t))
39 changes: 20 additions & 19 deletions src/extensions/expokit/load-libs.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,32 @@

(in-package #:magicl.foreign-libraries)

(cffi:define-foreign-library libexpokit
(:darwin (:or "libexpokit.dylib" "expokit.dylib"))
(:unix (:or "libexpokit.so" "expokit.so"))
(:windows (:or "libexpokit.dll" "expokit.dll"))
(t (:default "expokit")))
(eval-when (:compile-toplevel :load-toplevel :execute)
(cffi:define-foreign-library libexpokit
(:darwin (:or "libexpokit.dylib" "expokit.dylib"))
(:unix (:or "libexpokit.so" "expokit.so"))
(:windows (:or "libexpokit.dll" "expokit.dll"))
(t (:default "expokit")))

(pushnew 'libexpokit *foreign-libraries*)
(pushnew 'libexpokit *foreign-libraries*)


(pushnew (asdf:apply-output-translations (asdf:system-relative-pathname "magicl" "expokit"))
cffi:*foreign-library-directories*
:test #'equal)
(pushnew (asdf:apply-output-translations (asdf:system-relative-pathname "magicl" "expokit"))
cffi:*foreign-library-directories*
:test #'equal)

;; Keep above in sync with 'perform ((... compile-op) (... f->so))'
;; method in magicl.asd.
;; Keep above in sync with 'perform ((... compile-op) (... f->so))'
;; method in magicl.asd.


(export 'libexpokit)
(export 'libexpokit)

(defvar *expokit-libs-loaded* nil)
(defvar *expokit-libs-loaded* nil)

(unless *expokit-libs-loaded*
(cffi:load-foreign-library 'libexpokit)
(setf *expokit-libs-loaded* t))
(unless *expokit-libs-loaded*
(cffi:load-foreign-library 'libexpokit)
(setf *expokit-libs-loaded* t))

(magicl:define-backend :expokit
:documentation "Functions available from Expokit."
:default t)
(magicl:define-backend :expokit
:documentation "Functions available from Expokit."
:default t))
Loading

0 comments on commit 34bb1d9

Please sign in to comment.