The LAPACK forum has moved to https://github.com/Reference-LAPACK/lapack/discussions.

how to make the call of the sub-routines of blas from lapack

Open discussion regarding features, bugs, issues, vendors, etc.

how to make the call of the sub-routines of blas from lapack

Postby kirou11 » Fri Jul 06, 2007 4:04 am

please how to make the call of sub-routines of blas(level1,level2,leve3) from lapack
not: il have lapack instaled.
kirou11
 
Posts: 7
Joined: Mon Jun 04, 2007 8:54 am

Postby Julie » Mon Jul 09, 2007 2:40 pm

Kirou11,

do you have a BLAS library installed on your machine like ATLAS, GOTO or a vendor BLAS? see http://www.netlib.org/lapack/faq.html#2.5 if you need to install one.

LAPACK library needs a BLAS library.
For example if you are calling the DGETRF routine (computes an LU factorization of a general matrix), LAPACK will call the following BLAS routines: DGEMM, DLASWP, DTRSM.
To be able to call a BLAS routine:
- In your code, you need to declare them as EXTERNAL before calling them:
Code: Select all
*     .. External Subroutines ..
      EXTERNAL           DGEMM, DLASWP, DTRSM

- you need to link your code with the BLAS library.
Code: Select all
f77 mycode.f -o myprog.exe %BLASLIBRARY%
where %BLASLIBRARY% is the complete path of the BLAS library or
-L%PATHTOATLASLIB% -lf77blas -latlas if you are using ATLAS library or
-L%PATHTOGOTOLIB% -lgoto

Do not forget to add LAPACK first if you are using some LAPACK routines in your code:
Code: Select all
f77 mycode.f -o myprog.exe  %LAPACKLIBRARY% %BLASLIBRARY%

Hope it helps
Julie
Julie
 
Posts: 299
Joined: Wed Feb 23, 2005 12:32 am
Location: ICL, Denver. Colorado

Postby kirou11 » Tue Jul 10, 2007 8:48 am

hi,
but me I installed and I thus use Clapack I will like to know if the same thing, thanksjulie
kirou11
 
Posts: 7
Joined: Mon Jun 04, 2007 8:54 am

Postby kirou11 » Tue Jul 10, 2007 8:49 am

sorry,
but me I installed and I use Clapack I will like to know if the same thing.
kirou11
 
Posts: 7
Joined: Mon Jun 04, 2007 8:54 am

Postby Julie » Wed Jul 11, 2007 11:42 am

kirou11
It is the same for CLAPACK, you just have to link with your CBLAS or ATLAS or a vendor BLAS.
You will have something like this if you are using CBLAS:
Code: Select all
gcc prog.c ~/lib/clapack/libclapack.a ~/lib/clapack/libcblas.a -lm -lg2c

and like this if you are using ATLAS
Code: Select all
gcc prog.c ~/lib/clapack/libclapack.a -lcblas -latlas  -lm -lg2c


Julie
Julie
 
Posts: 299
Joined: Wed Feb 23, 2005 12:32 am
Location: ICL, Denver. Colorado

Postby kirou11 » Thu Jul 12, 2007 3:54 am

I did what you had said to me but I always have a problem here:

------------------------------------------------
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include "/home/student/Desktop/CLAPACK/include/f2c.h"
#include "/home/student/Desktop/CLAPACK/include/clapack.h"
#include "/home/student/Desktop/CLAPACK/include/cblas.h"

int main (void)
{
extern int cblas_sgemm();
int lda = 3;

float A[] = { 0.11, 0.12, 0.13,
0.21, 0.22, 0.23 };

int ldb = 2;

float B[] = { 1011, 1012,
1021, 1022,
1031, 1032 };

int ldc = 2;

float C[] = { 0.00, 0.00,
0.00, 0.00 };

/* Compute C = A B */

cblas_sgemm (CblasRowMajor,
CblasNoTrans, CblasNoTrans, 2, 2, 3,
1.0, A, lda, B, ldb, 0.0, C, ldc);

printf ("[ %g, %g\n", C[0], C[1]);
printf (" %g, %g ]\n", C[2], C[3]);

return 0;
}
---------------------------------------------------------------------
gcc matrice.c -o matrice -L/home/student/Desktop/CLAPACK/lib -ltmglib -llapack -lblas -lF77 -lI77 -lm
-------------------------------------------------
matrice.c: In function `main':
matrice.c:11: error: conflicting types for 'cblas_sgemm'
/home/student/Desktop/CLAPACK/include/cblas.h:415: error: previous declaration of 'cblas_sgemm' was here
student@MasterControl:~/Desktop/CLAPACK$
----------------------------------------------------------
kirou11
 
Posts: 7
Joined: Mon Jun 04, 2007 8:54 am

Postby Julien Langou » Thu Jul 12, 2007 10:50 am

You need to remove line 11 of your code.
cblas_sgemm is a priory already and correctly defined in cblas.h and you have
included cblas.h on line 7.
Julien Langou
 
Posts: 835
Joined: Thu Dec 09, 2004 12:32 pm
Location: Denver, CO, USA

Postby kirou11 » Fri Jul 13, 2007 3:59 am

if I remove line 11 I leave include.h I will have this error:
------------------------------------------------
/tmp/ccihquI6.o: In function `main':
matrice.c:(.text+0xa2): undefined reference to `cblas_sgemm'
collect2: ld returned 1 exit status
student@MasterControl:~/Desktop/CLAPACK$
------------------------------------------------
kirou11
 
Posts: 7
Joined: Mon Jun 04, 2007 8:54 am

Postby Julie » Fri Jul 13, 2007 10:15 am

kirou11
Code: Select all
 cblas_sgemm (CblasRowMajor,CblasNoTrans, CblasNoTrans, 2, 2, 3,1.0, A, lda, B, ldb, 0.0, C, ldc);

you are using cblas in your code, not blas,

so you need to link also with the CBLAS library.
gcc matrice.c -o matrice -L/home/student/Desktop/CLAPACK/lib -llapack -L/home/student/Desktop/CBLAS/lib -lcblas -lblas -g2c -lm

Julie
Julie
 
Posts: 299
Joined: Wed Feb 23, 2005 12:32 am
Location: ICL, Denver. Colorado


Return to User Discussion

Who is online

Users browsing this forum: No registered users and 4 guests