Quantcast
Channel: Intel® Software - Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
Viewing all articles
Browse latest Browse all 3005

different results for LAPACKE_dgels between MKL and LAPACKE

$
0
0

Hi guys,

I wrote some code to do dgels originally using LAPACKE. I also tried to use MKL to do the dgels. From my understanding, with the exact same code base but just recompile/relink with MKL library would just do the job. Or  LD_PRELOAD=libmkl_rt.so can also work upon the test program built with LAPACKE. the programs run OK, but the final results are different.

Any one can tell me why? 

Below is the the test program source code as well as the MakeFile lines.

    lapack_int m = 10;
    lapack_int n = 5; 
    lapack_int nrhs = 5;
    lapack_int lda, ldb, returninfo;
    char trans = 'N';
    int matrix_order = LAPACK_COL_MAJOR;
    // row major: lda = n, ldb = hrhs
    // column major, lda = max(1,m), ldb = max(1,m,n)
    // use column major by default  b/c the lapack/magma_lapack use column major to reduce complexity
    lda = MAX(1, m);
    ldb = MAX(lda, n);

    // Allocate matrix a and b memory
    double *A = NULL;
    double *B = NULL;
    
    A = (double *)malloc(lda*n* sizeof(double));
    B = (double *)malloc(ldb*nrhs* sizeof(double));
    if ((A == NULL) || (B == NULL))
    {
        fprintf(stderr, "Unable to allocate memory!\n");
        free(A);
        free(B);
        exit(1);
    }
    fprintf(stderr, "Fill matrix with data\n"); 
    // Fill matrix A and B with values
    for (int i=0; i< lda*n; i++)
    {
        // just example data
        A[i] = i+0.50;
        
    }
    for (int i=0; i< ldb*nrhs; i++)
    {
        // just example data
        B[i] = 2*i+0.10; 

     }

    returninfo = LAPACKE_dgels(matrix_order, trans, m, n, nrhs, A, lda, B, ldb);
            
    fprintf(stderr, "Overwritten B\n");
    print_matrix_col(B, n, nrhs);

 

=========================================================

$(TARGET_LAPACKE_DGELS): simple_lapack.c 
    $(CC) $(CFLAGS)  $(OUTPUTFLAGS) -I$(COMMON_DIR) $^ -llapacke -llapack -lm -lrt

$(TARGET_MKL_DGELS): simple_lapack.c 
    $(CC) $(CFLAGS)  $(OUTPUTFLAGS) -I$(COMMON_DIR) $^ -L$(INTEL_MKL_LIB_DIR) -lmkl_rt -lm -lrt


Viewing all articles
Browse latest Browse all 3005

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>