Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

question about the blacs library in MKL

Ye_C_1
Beginner
700 Views

I can find a lot of examples use the syntax like Cblacs_get(...), Cblacs_pinfo(...), but I can not find the c-type declaration in the "mkl_cblacs.h". 

Is it legal to use this kind of c-wrapper function in mkl?

 

0 Kudos
5 Replies
Zhen_Z_Intel
Employee
700 Views

Hi Ye,

I am afraid there's no function call Cblas_get in MKL, but you could use BLACS_GET which in defined in mkl_blacs.h. They have same functionality. Could you please tell me where you find function called "Cblas_get" ? I know some opensource library, for instance, ACOUSTO redefined scalapack functions which contains Cblas_get, but it is not intel MKL function.

If you would like to use BLACS_GET, please learn more from following link:
https://software.intel.com/en-us/node/522196

Best regards,
Fiona

 

 

0 Kudos
Ye_C_1
Beginner
700 Views

Fiona Z. (Intel) wrote:

Hi Ye,

I am afraid there's no function call Cblas_get in MKL, but you could use BLACS_GET which in defined in mkl_blacs.h. They have same functionality. Could you please tell me where you find function called "Cblas_get" ? I know some opensource library, for instance, ACOUSTO redefined scalapack functions which contains Cblas_get, but it is not intel MKL function.

If you would like to use BLACS_GET, please learn more from following link:
https://software.intel.com/en-us/node/522196

Best regards,
Fiona
 

 

I saw an example on intel's form:

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include "mpi.h"

 

#define AA(i,j) AA[(i)*M+(j)]

 

 

int main(int argc, char **argv) {

   int i, j, k;

/************  MPI ***************************/

   int myrank_mpi, nprocs_mpi;

   MPI_Init( &argc, &argv);

   MPI_Comm_rank(MPI_COMM_WORLD, &myrank_mpi);

   MPI_Comm_size(MPI_COMM_WORLD, &nprocs_mpi);

/************  BLACS ***************************/

   int ictxt, nprow, npcol, myrow, mycol,nb;

   int info,itemp;

   int ZERO=0,ONE=1;

   nprow = 2; npcol = 2; nb =2;

   Cblacs_pinfo( &myrank_mpi, &nprocs_mpi ) ;

   Cblacs_get( -1, 0, &ictxt );

   Cblacs_gridinit( &ictxt, "Row", nprow, npcol );

   Cblacs_gridinfo( ictxt, &nprow, &npcol, &myrow, &mycol );

   int M=5;

   double *AA = (double*) malloc(M*M*sizeof(double));

   for(i=0;i<M;i++ )

     for(j=0;j<M;j++)

        AA[i*M+j]=(2*i+3*j+1);

 

   double *X = (double*) malloc(M*sizeof(double));

   X[0]=1;X[1]=1;X[2]=0;X[3]=0;X[4]=1;

 

   int descA[9],descx[9],descy[9];

   int mA = numroc_( &M, &nb, &myrow, &ZERO, &nprow );

   int nA = numroc_( &M, &nb, &mycol, &ZERO, &npcol );

   int nx = numroc_( &M, &nb, &myrow, &ZERO, &nprow );

   int my = numroc_( &M, &nb, &myrow, &ZERO, &nprow );

   descinit_(descA, &M,   &M,   &nb,  &nb,  &ZERO, &ZERO, &ictxt, &mA,  &info);

   descinit_(descx, &M, &ONE,   &nb, &ONE,  &ZERO, &ZERO, &ictxt, &nx, &info);

 

   descinit_(descy, &M, &ONE,   &nb, &ONE,  &ZERO, &ZERO, &ictxt, &my, &info);

   double *x = (double*) malloc(nx*sizeof(double));

   double *y = (double*) calloc(my,sizeof(double));

   double *A = (double*) malloc(mA*nA*sizeof(double));

   int sat,sut;

   for(i=0;i<mA;i++)

 

   for(j=0;j<nA;j++){

                sat= (myrow*nb)+i+(i/nb)*nb;

                sut= (mycol*nb)+j+(j/nb)*nb;

                A[j*mA+i]=AA(sat,sut);

        }

 

 

   for(i=0;i<nx;i++){

                sut= (myrow*nb)+i+(i/nb)*nb;

                x=X[sut];

        }

 

   double alpha = 1.0; double beta = 0.0;

   pdgemv_("N",&M,&M,&alpha,A,&ONE,&ONE,descA,x,&ONE,&ONE,descx,&ONE,&beta,y,&ONE,&ONE,descy,&ONE);

 

   Cblacs_barrier(ictxt,"A");

   for(i=0;i<my;i++)

   printf("rank=%d %.2f \n", myrank_mpi,y);

   Cblacs_gridexit( 0 );

   MPI_Finalize();

   return 0;

}


It seems to use the Cblacs_....version of the blacs library. Can you explain it more?
 
I gauss the program does not link to the mkl blacs library, but another library in PATH, Is it correct?
 
0 Kudos
Zhen_Z_Intel
Employee
700 Views

Hi Ye,

He might use some other library or redefined functions by self. If you could not make sure, you could compile this program, the system will notice undefined reference to "Cblacs_get", "Cblacs_pinfo"...

And there's no function called "pdgemv_" in MKL, the name should be "pdgemv" which is defined in mkl_pblas.h. Please use functions defined in MKL library. Thank you.

0 Kudos
Ye_C_1
Beginner
700 Views

Fiona Z. (Intel) wrote:

Hi Ye,

He might use some other library or redefined functions by self. If you could not make sure, you could compile this program, the system will notice undefined reference to "Cblacs_get", "Cblacs_pinfo"...

And there's no function called "pdgemv_" in MKL, the name should be "pdgemv" which is defined in mkl_pblas.h. Please use functions defined in MKL library. Thank you.

It's clear!

I will just follow the mkl manual.

 

0 Kudos
Ye_C_1
Beginner
700 Views

Fiona Z. (Intel) wrote:

Hi Ye,

He might use some other library or redefined functions by self. If you could not make sure, you could compile this program, the system will notice undefined reference to "Cblacs_get", "Cblacs_pinfo"...

And there's no function called "pdgemv_" in MKL, the name should be "pdgemv" which is defined in mkl_pblas.h. Please use functions defined in MKL library. Thank you.

It's clear!

I will just follow the mkl manual.

 

0 Kudos
Reply