Hi,

I can't use dgemm with clines.
One of the arrays is destroy.
Is it possible to give a 2D long-float array
to an external library ?

Here is my test:
(from
http://lists.gnu.org/archive/html/gcl-devel/2005-05/msg00037.html)


(compile-file "lapack.lisp" :system-p t :c-file t)

# On debian with atlas 
(compiler::link (list "lapack.o") "saved_gcl" "" "-L/usr/lib/atlas
-llapack -lblas -latlas -lg2c" t)

(quit)
--------------------------------------------
./saved_gcl
(setq a (make-array '(500 500) :element-type
'long-float :initial-element 3.2))

(setq a (make-array '(500 500) :element-type
'long-float :initial-element 3.2))

(setq b (make-array '(500 500) :element-type
'long-float :initial-element 7.4))

(setq c (make-array '(500 500) :element-type
'long-float :initial-element 0.0))

(dgemm a b c)
(aref c 0 0)
(dgemm a b c)
(aref c 0 0)
b

Destroyed array with gcl-2.6.5 and gcl-2.6.6
from debian testing (emulated 32bit and 64bits (AMD))

Hope that this can be reproduced easily if it's a bug.

Cheers,

Greg

PJ: lapack.lisp (ddot and dgemm's test
(square row-major matrix))
(clines "

extern double ddot_(int *,double *,int *,double *,int *);

static double ddot(object x,object y,int n) {
        int one=1;
        return ddot_(&n,x->lfa.lfa_self,&one,y->lfa.lfa_self,&one);
}

extern int dgemm_(char *transa, char *transb, int *m, int *
                        n, int *k, double *alpha, double *a, int *lda,
                        double *b, int *ldb, double *beta, double *c__,
                        int *ldc);

static void dgemm(object x,object y,object z, int n){
                char ptrans = 'N';
                double alpha = 1;
                double beta = 0;
                 dgemm_(
                &ptrans,
                &ptrans,
                &n,
                &n,
                &n,
                &alpha,
                y->lfa.lfa_self,
                &n,
                x->lfa.lfa_self,
                &n,
                &beta,
                z->lfa.lfa_self,
                &n);
}


")

(defentry %ddot (object object int) (double "ddot"))

(defun ddot (x y) 
  (unless (and (typep x '(vector long-float)) (typep y '(vector long-float)))
    (error "Bad argument types ~a ~a~%" (type-of x) (type-of y)))
  (%ddot x y (min (length x) (length y))))

(defentry %dgemm (object object object int) (void "dgemm"))

(defun dgemm (x y z) 
  (unless (and 
                (typep x '(array long-float))
                (typep y '(array long-float)) 
                (typep z '(array long-float)) 
                (eql 2 (array-rank x))
                (eql 2 (array-rank y))
                (eql 2 (array-rank z)))
    (error "Bad argument types ~a ~a~%" (type-of x) (type-of y)))
  (%dgemm x y z (array-dimension x 0)))


_______________________________________________
Gcl-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gcl-devel

Reply via email to