Patch for Matlisp with ATLAS from Debian (unstable) and SBCL on ia32(sse2)

Max-Gerd Retzlaff <[email protected]> Thu, 1 Mar 2007 16:19:13 +0100
Newsgroups gmane.lisp.matlisp.devel
Message-ID <[email protected]>
--===============1545383732==
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="nVMJ2NtxeReIH9PS"
Content-Disposition: inline


--nVMJ2NtxeReIH9PS
Content-Type: multipart/mixed; boundary="SUOF0GtieIMvvwua"
Content-Disposition: inline


--SUOF0GtieIMvvwua
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hello,

I have yesterday installed Matlisp on my system, and I'm very pleased
with it. The installation was really simple and judging from some first
tests, it seems to be just what I want. Thanks.


Then I've wanted to built it using the ATLAS libraries. I've tried
to achieve that with this call to configure:

 ./configure --with-lisp=3Dsbcl --with-lisp-exec=3Dsbcl --prefix=3D`pwd` --=
with-atlas=3D"/usr/lib/sse2"=20

(The desired libraries lie in /usrr/lib/sse2 on Debian.)

But the lapack library file of the Debian package atlas3-sse2-dev
is called liblapack_atlas.so not liblapack.so, so I changed that
in the ATLAS_LIBS variable in configure.in.

To have the libraries loaded on SBCL I've added some code
load-blas-&-lapack-libraries in lazy-loader.lisp.in. It's a bit longer
than on CMUCL as I have added code that extracts the library names from
the @ATLAS_LIBS@ string and the ATLAS directory from @ATLAS_DIR@, and
then loads the .so-files via sb-alien:load-shared-object.

I'm not exactly sure wheter this is the way to go.. At least it seems
to work, and even in a way that might probably work on other systems
than mine as well.

Other changes in the patch:
 - Changed the two definitions of ATLAS_P in configure.in
   from nil to "(or)" and from t to "(and)", respectively, so
   that one can use "#+@ATLAS_P@" in lib/lazy-loader.lisp.in,
   and it will also work for the "true" case.
 - "make distclean" will now also delete the files matlisp.mk,
   lib/lazy-loader.lisp, src/f77-mangling.lisp, and config.status,
   that are generated when calling configure.
 - Updated the paragraph on building Matlisp with ATLAS:
   When the ATLAS libraries have different names, the variable
   ATLAS_LIBS in configure.in should be changed, not the generated
   file lib/lazy-loader.lisp.

Bye,
Max

PS:
 This is Linux 2.6.15.1, ia32 (Pentium Mobile), SBCL 0.9.16.21,
 a Matlisp checkout of yesterday evening, atlas3-sse2-dev 3.6.0-20.6
 (Debian unstable), in the case someone is interested in this.

--=20
Max-Gerd Retzlaff <[email protected]>       http://blog.matroid.org

For your amusement:
Comedy, like Medicine, was never meant to be practiced by the general
public.

--SUOF0GtieIMvvwua
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="matlisp-mgr.patch"
Content-Transfer-Encoding: quoted-printable

--- Makefile.~1.6.~	2001-04-25 19:41:58.000000000 +0200
+++ Makefile	2007-03-01 15:35:09.000000000 +0100
@@ -89,3 +89,7 @@
 	\rm -f matlisp-cmu
 	\rm -f lib/libmatlispstatic.a
 	\rm -f lib/libmatlispshared.so
+	\rm -f matlisp.mk
+	\rm -f lib/lazy-loader.lisp
+	\rm -f src/f77-mangling.lisp
+	\rm -f config.status
--- configure.in.~1.18.~	2006-09-18 15:22:17.000000000 +0200
+++ configure.in	2007-02-28 23:52:02.000000000 +0100
@@ -196,13 +196,13 @@
 [
   # Building with ATLAS
   ATLAS_DIR=3D"-L$withval"
-  ATLAS_LIBS=3D"-llapack -lcblas -lf77blas -latlas"
-  ATLAS_P=3Dt
+  ATLAS_LIBS=3D"-llapack_atlas -lcblas -lf77blas -latlas"
+  ATLAS_P=3D"(and)"
 ],
 [
   # Building without ATLAS.  Need these objects from our own copy of=20
   # LAPACK.
-  ATLAS_P=3Dnil
+  ATLAS_P=3D"(or)"
 BLAS_OBJS=3D"dgemm.o dswap.o dtrmv.o lsame.o zdotu.o zhemv.o ztrmv.o dgemv=
.o  dsymv.o  dtrsm.o  zher2.o   ztrsm.o dasum.o  dger.o   dsyr.o   dtrsv.o =
  zdscal.o zher2k.o ztrsv.o daxpy.o  dsyr2.o  dzasum.o xerbla.o  zgemm.o  z=
herk.o dcabs1.o dnrm2.o  dsyr2k.o dznrm2.o  zaxpy.o  zgemv.o  zscal.o dcopy=
.o  drot.o   dsyrk.o  idamax.o  zcopy.o  zgerc.o  zswap.o ddot.o	 dscal.o  =
dtrmm.o  izamax.o  zdotc.o  zgeru.o  ztrmm.o dsymm.o"
 NO_ATLAS_LAPACK_OBJS=3D"dgetrf.o zgetrf.o dgetrs.o zgetrs.o dlaswp.o zlasw=
p.o dgesv.o zgesv.o"
 ]
--- lib/lazy-loader.lisp.in.~1.16.~	2005-06-24 06:04:08.000000000 +0200
+++ lib/lazy-loader.lisp.in	2007-03-01 15:24:09.000000000 +0100
@@ -183,7 +183,22 @@
=20
 #+:sbcl
 (defun load-blas-&-lapack-libraries ()
-  (sb-alien:load-shared-object "matlisp:lib;libmatlisp.so"))
+  #+@ATLAS_P@
+  (let ((atlas-dir (subseq "@ATLAS_DIR@" 2))
+        (atlas-libs "@ATLAS_LIBS@")
+        (start 0)
+        end
+        libs)
+    (do ((pos (search  "-l" atlas-libs  :start2 start)
+              (search  "-l" atlas-libs  :start2 start)))
+        ((not pos))
+      (incf start 2)
+      (setf end (search " " atlas-libs  :start2 start))
+      (push (subseq atlas-libs start end) libs)
+      (setf start (1+ (or end start))))
+    (dolist (lib libs)
+      (sb-alien:load-shared-object (format nil "~a/lib~a.so" atlas-dir lib=
))))
+  #+(not @ATLAS_P@) (sb-alien:load-shared-object "matlisp:lib;libmatlisp.s=
o"))
=20
=20
=20
--- INSTALL.~1.7.~	2005-08-19 17:03:35.000000000 +0200
+++ INSTALL	2007-03-01 16:05:41.000000000 +0100
@@ -89,8 +89,9 @@
 option --with-atlas=3D<libpath> to enable ATLAS support.  You need to
 specify the full path to where the ATLAS libraries are located.  The
 libraries themselves must be named liblapack, libf77blas, libatlas,
-and libcblas.  If other names are used, you'll have to manually change
-lazy-loader.lisp after configuring.
+and libcblas.  If other names are used, change the value of the
+variable ATLAS_LIBS in configure.in accordingly (before calling
+configure, of course).
=20
 MS Windows installation:
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

--SUOF0GtieIMvvwua--

--nVMJ2NtxeReIH9PS
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFF5u7xwrJIroEjnxIRArofAJ4zTyWLXKtgbbemUSsvlcrek9kObwCgo3k9
wx++K2m16BHoJPiJF9Mq3Mg=
=Jl8D
-----END PGP SIGNATURE-----

--nVMJ2NtxeReIH9PS--


--===============1545383732==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
--===============1545383732==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Matlisp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matlisp-devel

--===============1545383732==--