Ticket #27830

Make BlasWrapper

Open Date: 2012-03-14 19:46 Last Update: 2012-10-09 17:53

Reporter:
Owner:
Status:
Closed
Component:
(None)
MileStone:
Priority:
7
Severity:
7
Resolution:
None
File:
None

Details

Blas and BlasWrapper is important to speed up MolDS.

Ticket History (3/6 Histories)

2012-03-14 19:46 Updated by: mikiya_fujii
  • New Ticket "Make BlasWrapper" created
2012-03-14 19:46 Updated by: mikiya_fujii
  • Type Update from Patches to Feature Requests
2012-03-14 19:50 Updated by: mikiya_fujii
  • Severity Update from 5 - Medium to 7
2012-10-09 14:40 Updated by: mikiya_fujii
  • Ticket Close date is changed to 2012-10-09 14:40
  • Status Update from Open to Closed
Comment

Completed at rev. 1056.

Wrappers for matrix*matirx (MolDS_wrappers::Blas::Dgemm) and matrix*vector(MolDS_wrappers::Blas::Dgemv) were only implemented. Two examples of simplest use are shown below.

For matrix*matrix (MolDS_wrappers::Blas::Dgemm):

    #include"../wrappers/Blas.h"  // <- change the relative path to the Blas.h

    // matrixC = matrixA * matrixB
    double** matrixA=NULL; //m*k-matrix
    double** matrixB=NULL; //k*n-matirx
    double** matrixC=NULL; //m*n-matirx
    int m=2;
    int n=3;
    int k=4;
    MallocerFreer::GetInstance()->Malloc<double>(&matrixA,m,k);
    MallocerFreer::GetInstance()->Malloc<double>(&matrixB,k,n);
    MallocerFreer::GetInstance()->Malloc<double>(&matrixC,m,n);
    
    for(int i=0; i<m; i++){
       for(int j=0; j<k; j++){
          matrixA[i][j] = 0.23*(i*j+1);
       }
    }
    for(int i=0; i<k; i++){
       for(int j=0; j<n; j++){
          matrixB[i][j] = (i*j+2)/2 * 0.09 - 1.0;
       }  
    }  
    
    MolDS_wrappers::Blas::GetInstance()->Dgemm(m, n, k, matrixA, matrixB, matrixC); // <- call BLAS-wrapper
    
    MallocerFreer::GetInstance()->Free<double>(&matrixA,m,k);
    MallocerFreer::GetInstance()->Free<double>(&matrixB,k,n);
    MallocerFreer::GetInstance()->Free<double>(&matrixC,m,n);

For matrix*vector (MolDS_wrappers::Blas::Dgemv):

    #include"../wrappers/Blas.h"  // <- change the relative path to the Blas.h

    // vectorY = matrixA * vectorX
    double** matrixA=NULL; // m*n-matrix
    double*  vectorX=NULL; // n-vector
    double*  vectorY=NULL; // m-vector
    int m=2;
    int n=3;
    
    MallocerFreer::GetInstance()->Malloc<double>(&matrixA,m,n);
    MallocerFreer::GetInstance()->Malloc<double>(&vectorX,n);
    MallocerFreer::GetInstance()->Malloc<double>(&vectorY,m);
 
    matrixA[0][0]=1.0;  matrixA[0][1]=-2.0; matrixA[0][2]=2.4;
    matrixA[1][0]=10.0; matrixA[1][1]=-0.3; matrixA[1][2]=1.4;
    vectorX[0]=3.0; vectorX[1]=2.2; vectorX[2]=-2.3;
    vectorY[0]=3.0; vectorY[1]=2.2;
 
    MolDS_wrappers::Blas::GetInstance()->Dgemv(m, n, matrixA, vectorX, vectorY); // <- call BLAS-wrapper
 
    MallocerFreer::GetInstance()->Free<double>(&matrixA,m,n);
    MallocerFreer::GetInstance()->Free<double>(&vectorX,n);
    MallocerFreer::GetInstance()->Free<double>(&vectorY,m);
2012-10-09 17:51 Updated by: mikiya_fujii
  • Status Update from Closed to Open
Comment

There is a bug in rev. 1056.

2012-10-09 17:53 Updated by: mikiya_fujii
  • Ticket Close date is changed to 2012-10-09 17:53
  • Status Update from Open to Closed
Comment

The bugs in rev. 1056 are fixed at rev. 1057.

Attachment File List

No attachments

Edit

Please login to add comment to this ticket » Login