calling Fortran BLAS Routines

calling Fortran BLAS Routines

Post by Johannes Ni » Thu, 23 Dec 1999 04:00:00



Hello,

I am trying to call the optimized (assembler-coded) BLAS routines
written by Kazushigi Goto from a C Program. He writes they are
entirely compatible to the Fortran originals, but I didn't manage to
call sdot_. All what I get out is zero. I tried also to compare with
f2c output but I don't know Fortran :-(.

I was trying this:

tdot.c:

--------------------
float s;
int n=5,inc=1;

float x[]= { .....};
float y[]= { .....};

s = sdot_(&n, x, &inc, y, &inc);
---------------------

gcc -o tdot tdot.c -ldot

All documentation I found regarding the BLAS Routines was like:

S - REAL
D - DOUBLE PRECISION
C - COMPLEX
Z - COMPLEX*16

FUNCTION xDOT (N, X, INCX, Y, INCY)               dot <- X^T*Y  x=S,D,DS
.......

anyone could help me?

BTW., is it possible to link this to object files compiled with ccc?

Does someone has suggestions for very fast vectorized signal
processing routines? Does there exist a standard library?

Johannes

 
 
 

calling Fortran BLAS Routines

Post by Tony Hammit » Fri, 24 Dec 1999 04:00:00



> Hello,

> I am trying to call the optimized (assembler-coded) BLAS routines
> written by Kazushigi Goto from a C Program. He writes they are
> entirely compatible to the Fortran originals, but I didn't manage to
> call sdot_. All what I get out is zero. I tried also to compare with
> f2c output but I don't know Fortran :-(.

> I was trying this:

> tdot.c:

> --------------------
> float s;
> int n=5,inc=1;

> float x[]= { .....};
> float y[]= { .....};

> s = sdot_(&n, x, &inc, y, &inc);
> ---------------------

> gcc -o tdot tdot.c -ldot

> All documentation I found regarding the BLAS Routines was like:

> S - REAL
> D - DOUBLE PRECISION
> C - COMPLEX
> Z - COMPLEX*16

> FUNCTION xDOT (N, X, INCX, Y, INCY)               dot <- X^T*Y  x=S,D,DS
> .......

> anyone could help me?

> BTW., is it possible to link this to object files compiled with ccc?

> Does someone has suggestions for very fast vectorized signal
> processing routines? Does there exist a standard library?

> Johannes

Johannes,

I have some C code that I wrote to interface to Goto-san's BLAS

it uses SGEMM but maybe it will be helpful.

Compaq has a whole signal processing library already written,

obtain the library.  It used used to be easily found through their
website, but since the fortran compiler went commercial, it is
hard to find.

(from their online docs)

CXML includes subroutines covering the areas of:
  * Basic Linear Algebra (BLAS) - includes BLAS 1, BLAS 1E, BLAS 1S,
      BLAS 2 and BLAS 3.
  * Linear and Eigen System Solvers (LAPACK)
  * Sparse Linear System Solvers: includes direct and iterative solvers
  * Signal Processing: includes FFTs, cos/sin transforms, convolution,
      correlations and digital filters

So, you might not have much work to do to implement signal processing
on you alpha box.  Then again, these routines aren't exactly portable
to another architecture so YMMV.

I've never seen any performance numbers for CXML.  I know Goto-san's
code is extremely fast, maybe all those high priced programmers at
Compaq can come close =-)

Regards,

Tony Hammitt



 
 
 

calling Fortran BLAS Routines

Post by Martin Kahle » Fri, 24 Dec 1999 04:00:00


[Posted and mailed]



Quote:

> Hello,
> I am trying to call the optimized (assembler-coded) BLAS routines
> written by Kazushigi Goto from a C Program. He writes they are
> entirely compatible to the Fortran originals, but I didn't manage to
> call sdot_. All what I get out is zero. I tried also to compare with
> f2c output but I don't know Fortran :-(.

Did you put a prototype in front of your call?
i.e. something like
float sdot_(const int*,const float*,const int*,const float*,const int*);
?

Without that, every C-compiler assumes that sdot_ will return an int,
which is a bit wrong...

Bye,
Martin.

--
The early bird gets the worm. If you want something else for      
breakfast, get up later.

 
 
 

1. Need help: call fortran routine in C programs



: >Need help! Can anybody tell how to call a fortran subroutine in a C
: >program? Or show me the address of some internet address so I can get
: >some materials on that?

: -----BEGIN PGP SIGNED MESSAGE-----

: This depends on the compilers and/or operating system.
: Alternatively, you might use f2c to translate everything into C.
: To make things portable, use a pair of portable compilers (e.g. GNU
: gcc and g77).

: Generally, in Fortran, all parameters are passed by reference.
: Fortran strings have a length (maybe passed by value as a hidden extra
: parameter).

: Fortran may let the callee (sub-program) pop the stack as the number
: of parameters is fixed.  In C, this is the responsibility of the
: caller as only the caller knows the number of parameters.

: Regards,
: Andy Robb.

: -----BEGIN PGP SIGNATURE-----
: Version: 2.6.2i

: iQCVAwUBMeHZsZPl4P16x9sNAQG0hwP/Zi3jHjClerHYRkxiWkitGT22n8eSdoJk
: 4FjNW214dXeOAhMrtpy2TclC8A7GU2t5Ux3FZN6lLS1yl75TKqiMn/E8b2F0TQUq
: h8Bi4ih7n8YF24hgIkvmQjKngaQ42Xga7d+zrOZESrcZ+fLKX2Fc+pUKQaSB7JPO
: SpJxF82d14U=
: =i/bq
: -----END PGP SIGNATURE-----

--
************begin r.s. response*****************

        (call fortran from 'c')

        the critical idea here is that
        the 'c' programming language defaults to
                call by value
        and
        fortran defaults to
                call by reference
        !

        by referencing
                the arguments
        in the
                function calls
        as
                variable addresses
                         ^^^^^^^^^
        operability of this
        may be achieved!

************end r.s. response*******************
Ralph Silverman

2. PCI - SCSI2 HD install

3. Call C++ routine in C and Fortran

4. Problems with pppd and pppoe using demand

5. Optimized BLAS/Lapack routine

6. FREE COMPUTER CONSULTING

7. Fast opmized BLAS(Level 1) routine is available

8. How secure is UNIX rm command?

9. Fast BLAS routine(Level 3)

10. BLAS and new LibFFM routine for Alpha

11. libffm patch and BLAS routine

12. Commercial Fortran (f77, f9x) compilers and BLAS libs for FreeBSD?

13. timing routine sous fortran Linux ?