unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Daniel Llorens <daniel.llorens@bluewin.ch>
To: guile-user@gnu.org
Subject: [ANN] guile-ffi-cblas
Date: Mon, 20 Oct 2014 07:46:17 +0200	[thread overview]
Message-ID: <800015A5-88E2-415C-8B7B-6E7BB26064BC@bluewin.ch> (raw)


Hello,

this is to announce that I've started a BLAS (Basic Linear Algebra Subprograms) wrapper for Guile using the FFI. The wrapper is actually for CBLAS, not that there's much difference.

https://gitorious.org/guile-ffi-cblas

Currently the wrapper covers: dot, axpy, nrm2, scal, asum, iamax, ger, gemv and gemm in all variants. There's a test suite that covers dot, axpy and partially gemv. I'll be adding the rest of the functions as I find the time.

The wrappers use the Guile array facility. This means that you don't need to give the size, inc and order arguments, because those are taken from the array object. E.g. rather than doing

(cblas_dgemv CblasRowMajor CblasNoTrans M N alpha A lda X incX beta Y incY)

you just do

(dgemv! alpha A CblasNoTrans X beta Y)

and instead of doing

(cblas_dgemv CblasRowMajor CblasTrans M N alpha A lda X incX beta Y incY)

you can do either of

(dgemv! alpha (transpose-array A 1 0) CblasNoTrans X beta Y)
(dgemv! alpha A CblasTrans X beta Y)

Here I've retained the TransA parameter because otherwise CblasConjTrans can't be done for free.

None of the wrappers do any copying or type conversion. This means that you can't pass an untyped array to dgemv! (it must be of type 'f64, likewise 'f32 for sgemv!, etc.) and also that some cases that BLAS doesn't support will fail, e.g. if both strides of A in dgemv! differ from 1. All arguments are checked, or should be.

I've looked at the Chicken wrappers: http://wiki.call-cc.org/eggref/4/blas. These take srfi4 vectors with explicit size & inc arguments, so the calls look closer to the original library. I haven't decided yet whether to add compatible exports. (ffi cblas) does export the raw library calls, but those are of course very dangerous to use.

There's no doc yet. Comments & contributions are welcome.

Regards

	Daniel




                 reply	other threads:[~2014-10-20  5:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=800015A5-88E2-415C-8B7B-6E7BB26064BC@bluewin.ch \
    --to=daniel.llorens@bluewin.ch \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).